Pract 4

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Practical no.

%macro print 2
mov rax,1
mov rdi,1
mov rsi,%1
mov rdx,%2
syscall
%endmacro

section .data
msg db 10,"count number of posite and negative numbers",10
msg_len equ $ - msg

msg1 db 10,"poistive numbers are",10


msg1_len equ $ - msg1

msg2 db 10,"negative numbers are",10


msg2_len equ $ - msg2

array dq 123456789ABCDEFh, -123444400000000Fh, -123444400000000h, -


123456789ABDCEAh, 223456789ABCDEFh
pcnt db 0
ncnt db 0
newline db 0xa

section .bss
output resb 1

section .text
global _start
_start:
print msg,msg_len

mov rsi,array
mov rcx,05

again:
bt qword[rsi],63
jnc pnxt
inc byte[ncnt]
jmp pskip
pnxt: inc byte[pcnt]
pskip: add rsi,08

loop again
print msg1,msg1_len
mov al,[pcnt]

call display
print newline,1

print msg2,msg2_len
mov al,[ncnt]
call display
print newline,1

mov rax,60
mov rdi,0
syscall

display:
mov rbx,rax
;mov ch, 16
;mov cl,04h
mov cx,1004h

ll6:
rol rbx,cl
mov rdx,rbx
and rdx,0fh
add rdx,30h
cmp rdx,039h
jbe skip4
add rdx,7
skip4:

mov byte[output],dl
push rcx
print output,1
pop rcx
dec ch
jnz ll6
ret

You might also like