Write an ALP to count no. of positive and negative numbers from the array

section .data
welmsgdb 10,'Welcome to count +ve and -ve numbers in an array',10
welmsg_lenequ $-welmsg
pmsgdb 10,'Count of +ve numbers::'
pmsg_lenequ $-pmsg
nmsgdb 10,'Count of -ve numbers::'
nmsg_lenequ $-nmsg
nwlinedb 10
array dw 8505h,90ffh,87h,88h,8a9fh,0adh,02h
arrcntequ 7
pcntdb 0
ncntdb 0
section .bss
dispbuffresb 2
%macro  print   2
moveax, 4
movebx, 1
movecx, %1
movedx, %2
int   80h
%endmacro
section .text
global _start
start:
print welmsg,welmsg_len
movesi,array
movecx,arrcnt
up1:
bt word[esi],15
jncpnxt
inc byte[ncnt]
jmppskip
pnxt: inc byte[pcnt]
pskip: incesi
incesi
loop up1
print pmsg,pmsg_len
movbl,[pcnt]
call disp8num
print nmsg,nmsg_len
movbl,[ncnt]
call disp8num
print nwline,1
exit:
mov eax,01
mov ebx,0
int 80h
disp8num:
mov ecx,2
movedi,dispbuff
dup1:
rol bl,4
moval,bl
and al,0fh
cmp al,09
jbedskip
add al,07h
dskip: add al,30h
mov [edi],al
incedi
loop dup1
print dispbuff,2
ret


Output

;[mahendra@(none) alp]$ nasm -f elf64 msmalb08.asm
;[mahendra@(none) alp]$ ld -o msmalb08 msmalb08.o
;[mahendra@(none) alp]$ ./msmalb08

;Welcome to count +ve and -ve numbers in an array

;Count of +ve numbers::04
;Count of -ve numbers::03
;[mahendra@(none) alp]$

Comments