SE Comp Sem-II MIL Prac-3 (Finding negetive nos)

;negative no's

disp macro msg
   lea dx,msg
   mov ah,09h
   int 21h

endm

.model small
.stack
.data
   arr    db 10h,30h,40h,70h,80h,90h
   arrp   db 6 dup(0)
   arrn   db 6 dup(0)
   p      db 00h
   n      db 00h
   msg0   db 10,13,'-------MENU------ $'
   msg1   db 10,13,'TOTAL NEGATIVE NO: $'
   msg2   db 10,13,'TOTAL POSITIVE NO: $'
   msg3   db 10,13,'NEGATIVE NO: $'
   msg4   db 10,13,'POSITIVE NO: $'
   msgn   db 10,13,'$'

.code
   main proc
       mov ax,@data
       mov ds,ax

       lea bx,arr
       lea si,arrp
       lea di,arrn           

       mov cl,06h
a1:    mov al,[bx]
       mov ah,al
       and al,80h
       jnz a2               ;if neg
       mov [si],ah
       inc p
       inc si
       inc bx
       dec cl
       jnz a1
 
a2:
       mov [di],ah          ;storing negative no
       inc n
       inc di
       inc bx
       dec cl
       jnz a1

       disp msg1            ;display count negative
       mov dl,n
       add dl,30h
       mov ah,02h
       int 21h

       disp msg2            ;display count positive
       mov dl,p
       add dl,30h
       mov ah,02h
       int 21h

       disp msg3            ;display negative no's
       mov cl,n
       lea di,arrn
a3:    disp msgn
       mov al,[di]
       mov ah,00h
       call hex
       inc di
       dec cl
       jnz a3

       disp msg4            ;display positive no's
       mov cl,p
       lea si,arrp
a4:    disp msgn
       mov al,[si]
       mov ah,00h
       call hex
       inc si
       dec cl
       jnz a4

      mov ax,4c00h
      int 21h
  endp

;hex to deci conv
hex proc near
push bx
push cx

        mov cx,0000h
        mov bx,0010h
   d1:
        mov dx,0000h
        div bx
        push dx
        inc cx
        cmp ax,00h
        jne d1
   d2:
        pop dx
        add dl,30h
        mov ah,02h
        int 21h
        dec cx
        jnz d2

pop cx
pop bx

ret
endp

end

No comments:

Post a Comment