21,499
社区成员
发帖
与我相关
我的任务
分享data segment
str1 db "Please enter the first decimal :$"
str2 db "Please enter the second decimal:$"
str3 db "Quotient = $"
str4 db "Remainder = $"
temp dw ?
data ends
decihex segment
assume cs:decihex,ds:data
main proc far
nexts:
mov ax,data
mov ds,ax
lea dx,str1
mov ah,09h
int 21h
call decibin
mov temp,bx
call crlf
lea dx,str2
mov ah,09h
int 21h
call decibin
mov ax,temp
xor dx,dx
div bx
push dx
mov bx,ax
call crlf
mov dx,offset str3
mov ah,09h
int 21h
mov ax,bx
call ShowTheNum
call crlf
mov dx,offset str4
mov ah,09h
int 21h
pop ax
call ShowTheNum
call crlf
jmp nexts
main endp
decibin proc near
mov cx,4
mov bx,0
newchar:
mov ah,1
int 21h
sub al,30h
jl exit
cbw
xchg ax,bx
mov dx,10d
mul dx
xchg ax,bx
add bx,ax
loop newchar
exit:
ret
decibin endp
crlf proc near
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
ret
crlf endp
ShowTheNum proc near
xor cx,cx
mov bx,10
DoDiv:
xor dx,dx
cwd
div bx
push dx
inc cx
cmp ax,0
jnz DoDiv
DoPrt:
pop dx
add dl,30h
mov ah,2
int 21h
loop DoPrt
ret
ShowTheNum endp
decihex ends
end main
data segment
str1 db "Please enter the first decimal:$"
str2 db "Please enter the second decimal:$"
str3 db "Quotient = $"
temp dw ?
data ends
decihex segment
assume cs:decihex,ds:data
main proc far
nexts:
mov ax,data
mov ds,ax
lea dx,str1
mov ah,09h
int 21h
call decibin
mov temp,bx
call crlf
lea dx,str2
mov ah,09h
int 21h
call decibin
mov ax,temp
xor dx,dx
div bx
mov bx,ax
call crlf
mov dx,offset str3
mov ah,09h
int 21h
mov ax,bx
call ShowTheNum
call crlf
jmp nexts
main endp
decibin proc near
mov cx,4
mov bx,0
newchar:
mov ah,1
int 21h
sub al,30h
jl exit
cbw
xchg ax,bx
mov dx,10d
mul dx
xchg ax,bx
add bx,ax
loop newchar
exit:
ret
decibin endp
crlf proc near
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
ret
crlf endp
ShowTheNum proc near
xor cx,cx
mov bx,10
DoDiv:
xor dx,dx
cwd
div bx
push dx
inc cx
cmp ax,0
jnz DoDiv
DoPrt:
pop dx
add dl,30h
mov ah,2
int 21h
loop DoPrt
ret
ShowTheNum endp
decihex ends
end main