You are on page 1of 2

Division: assume cs:_code,ds:_data

.model small start:mov ax,@data

.stack 200h mov ds,ax

printmsg macro msg printmsg msg1

push dx call readnum

push ax mov cx,num

lea dx,msg printmsg msg2

mov ah,09h call readnum

int 21h mov bx,num

pop ax mov ax,cx

pop dx div bx

endm mov sum1,ax

_data segment printmsg msg3

msg1 db 0dh,0ah,"enter the first call print


number:$"
mov sum1,dx
msg2 db 0dh,0ah,"enter the second
printmsg msg4
number:$"
call print
msg3 db 0dh,0ah," quotient is:$"
stop:mov ah,4ch
msg4 db 0dh,0ah,"remainder is:$"
int 21h
sum1 dw 0

cnt dw 0
readnum proc near
num dw 0
push ax
_data ends
push cx

push bx
_code segment
mov num,00h mov ax,sum1

next1:mov ah,01h mov bx,10

int 21h next3:mov dx,00h

cmp al,0dh div bx

je next2 push dx

sub al,30h inc cnt

mov cx,ax cmp ax,00h

and cx,00ffh jne next3

mov ax,num next4:cmp cnt,00h

mov bx,10 je next5

mul bx pop dx

mov num,ax dec cnt

add num,cx add dl,30h

jmp next1 mov ah,02h

next2:pop bx int 21h

pop cx jne next4

pop ax next5:pop bx

ret pop ax

readnum endp pop dx

print proc near pop cx

push cx ret

push dx print endp

push ax _code ends

push bx end start

You might also like