Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
countingnumbers
;nasm 2.11.08 %macro cmn 4 mov rax,%1 mov rdi,%2 mov rsi,%3 mov rdx,%4 syscall %endmacro section .data msg1 db 10, "the count of 0" msg1len equ $-msg1 msg2 db 10, "the count of positive" msg2len equ $-msg2 msg3 db 10, "the count of negative" msg3len equ $-msg3 array db -04h, 00h, 50h, -21h, 00h countz db 00 countp db 00 countn db 00 section .bss dispnum resb 02h section .text global _start _start: mov cl,05h mov rsi,array cont: mov al,[rsi] cmp al,00h je labelz rol al,01h jc labeln inc byte[countp] jmp final labelz: inc byte[countz] jmp final labeln: inc byte[countn] jmp final final: inc rsi dec cl jnz cont mov al,[countz] push rax cmn 1,1,msg1,msg1len pop rax call displayno mov al,[countp] push rax cmn 1,1,msg2,msg2len pop rax call displayno mov al,[countn] push rax cmn 1,1,msg3,msg3len pop rax call displayno call exit displayno: mov rsi,dispnum+1 xor rcx,rcx mov cl,02h label1: xor rdx,rdx xor rbx,rbx xor rbx,10h div rbx cmp dl,09h jbe less09 add dl,07h less09: add dl,30h mov [rsi],dl dec rsi dec cl jnz label1 mov rax,1 mov rdi,1 mov rsi,dispnum mov rdx,02h syscall ret exit: mov rax,60 mov rdi,0 syscall ret
run
|
edit
|
history
|
help
0
sdffdsafadssdf
dssdffdsafsd
Hello World
count poistive and Nehative no.
dfdfsfdgdffddf
helloLab
dsfdsffdafdssd
p1.asm
CMSC313 First Program Group Lab
Hello