print macro msg
lea dx,msg
mov ah,09h
int 21h
endm
read macro msg,r1,loo
r1:mov ah,01h
int 21h
cmp al,0dh
jz loo
sub al,30h
mov cl,al
mov ax,msg
mov dx,10
mul dx
mov ch,00
add ax,cx
mov msg,ax
jmp r1
loo:mov f,00
endm
.model small
.stack 100h
.data
s1 db 10,13,'GCD $'
s2 db 10,13,'Enter the number $'
data1 dw 0
data2 dw 0
sm dw 0
rem dw 0
count dw 2
gcd dw 1
f dw 0
.code
mov ax,@data
mov ds,ax
print s2
read data1,l1,l2
print s2
read data2,l3,l4
mov bx,data1
mov cx,data2
cmp bx,cx
jc l5
je l6
mov sm,cx
jmp l7
l5:mov sm,bx
l7:mov dx,00
mov ax,data1
mov bx,count
div bx
mov rem,dx
mov dx,00
mov ax,data2
mov bx,count
div bx
mov ax,rem
or ax,dx
jnz l8
mov bx,count
mov gcd,bx
l8:inc count
mov cx,sm
cmp cx,count
jnc l7
jmp l9
l6:mov cx,data1
mov gcd,cx
l9:mov cx,00
mov dx,00
loo:mov ax,gcd
mov bx,10
div bx
mov gcd,ax
push dx
inc cx
mov dx,00
cmp gcd,dx
jnz loo
print s1
lo2:pop dx
add dl,30h
mov ah,02
int 21h
loop lo2
stop:mov ah,4ch
int 21h
end
No comments:
Post a Comment