CRLF MACRO
MOV AH,02H
MOV DL,0DH
INT 21H
MOV AH,02H
MOV DL,0AH
INT 21H
ENDM
data segment
M dw 8
N DW 16
result dw 0
y dw 10
output1 dw 0
K dw 0
s1 db \"Please input a number as 'M': s2 db \"Please input a number as 'N': s3 db \"The result is : $\"
data ends
stack segment
s dw 1000 dup(?)
stack ends
code segment
assume cs:code,ds:data,ss:stack
$\"
$\"
start:
push ds
mov ax,0
push ax
mov ax,data
mov ds,ax
lea dx,s1
mov ah,09h
int 21h
call intput
mov ax,K
mov M,ax
mov K,0
crlf
lea dx,s2
mov ah,09h
int 21h
call intput
mov ax,K
mov N,ax
mov K,0
crlf
call ouji
mov ax,result
mov output1,ax
lea dx,s3
mov ah,09h
int 21h
call output
mov output1,0
ret
ouji proc near
xor dx,dx
mov ax,m
mov bx,n
T: cmp ax,bx
jge U
xchg ax,bx
U: mov cx,ax
div bx
cmp dx,0
jnz G
mov result,bx
jmp NEXT
G: mov ax,dx
xor dx,dx
jmp T
NEXT: ret
ouji endp
intput proc near
in_1: mov ah,01h
int 21h
xor ah,ah
cmp ax,0dh
je in_out
cmp ax,30h
jb in_out
cmp ax,39h
jG in_out
sub ax,30h
mov di,ax
mov ax,K
mul y
mov K,ax
add K,di
loop in_1
in_out:ret
intput endp
output proc near
mov ax,output1
xor dx,dx
mov di,0
p1: div y
push dx
inc di
xor dx,dx
cmp ax,10
jb output_n1
jmp p1
output_n1: cmp ax,0
jz output_n2
push ax
inc di
output_n2: mov cx,di
p2: pop dx
add dx,30h
mov ah,02h
int 21h
loop p2
mov ah,4ch
int 21h
output endp
code ends
end start