Write an assembly program for division of two eight bit no. at 4000H=2CH and 4001H=30H and
save result at 4002H=quotient and 4003H= remainder.
; DosBox
DATA SEGMENT
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
; 4000H=2CH
mov di,4000h ; address
mov al,2Ch ; al = number1=2Ch
mov [di],al ; save number1 in memory: 4000H=2Ch
; 4001H=30H
mov di,4001h ; address
mov al,30h ; al = number2=30h
mov [di],al ; save number2 in memory: 4001H=30h
mov si,4000h ; address
mov al,[si] ; number1= al=2Ch
mov si,4001h ; address
mov cl,[si] ; number2= cl=30h
; number1/number2
; 4002H = quotient and 4003H = remainder
div cl ; al=al/cl, ah=al%cl
mov di,4002h ; address
mov [di],al ; save al=quotient: 4002H=quotient
mov di,4003h ; address
mov [di],ah ; save ah=remainder: 4003H=remainder
EXIT_PROG: ; Program is terminated
MOV AH,4CH
INT 21H
CODE ENDS
END START
Comments
Leave a comment