(SOS)!!如何把这个加法程序改成除法?(程序是现成的)

zhoulong12ag 2008-12-03 10:04:44
程序在下面!这个程序是4位以内的10进制加法运算.(如何改成4位以内的除法运算?请高手们帮我改下.如何运行4位数字以内的除法运算!) 跪求高手解决.先谢谢了
data segment
str1 db "Please enter the first decimal:$"
str2 db "Please enter the second decimal:$"
str3 db "sum = $"
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
add 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

期待!
...全文
108 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
killbug2004 2008-12-08
  • 打赏
  • 举报
回复
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
zhoulong12ag 2008-12-08
  • 打赏
  • 举报
回复
谢谢你了高手。 祝你工作顺利!
zhoulong12ag 2008-12-07
  • 打赏
  • 举报
回复
不好意思。这几天没来看帖子
这个除法好像只能显示商噢。能显示余数吗?
killbug2004 2008-12-05
  • 打赏
  • 举报
回复
不带符号除法,只显示商,不显示除数
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

21,499

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧