You are on page 1of 2

Practical No: 14

;ALP to find if number is positive or ;ALP to count positive & negative


negative number in an array
Program:- Program:-
assume cs:code assume cs:code
assume ds:data assume ds:data

data segment data segment


num db 12h arr db -24h,23h,10h,-25h,50h
msg1 db "number is positive $" pos db ?
msg2 db "number is negative $" ng db ?
data ends data ends
code segment
code segment start:
start: mov ax,data
mov ax,data mov ds,ax
mov ds,ax mov ax,0000h
mov ax,0000h lea si,arr
mov al,num mov cl,05h
cmp al,00h up:
js neg mov al,[si]
lea dx,msg1 inc si
mov ah,09h cmp al,00h
int 21h js n
jmp exit inc dl
neg: loop up
lea dx,msg2 jmp exit
mov ah,09h n:
int 21h inc dh
exit: loop up
mov ah,4ch exit:
int 21h mov ng,dh
code ends mov pos,dl
end start int 03h
code ends
end start
Output:-

You might also like