Assembly 打印双字号,以10为底
例如,我的数字是6C0000h=7077888d 在这种情况下,将每个单词除以10,然后将剩余部分保存在堆栈上是行不通的,因为双字的下半部分是0000 任何提示都将不胜感激 谢谢 例如Assembly 打印双字号,以10为底,assembly,dos,tasm,Assembly,Dos,Tasm,例如,我的数字是6C0000h=7077888d 在这种情况下,将每个单词除以10,然后将剩余部分保存在堆栈上是行不通的,因为双字的下半部分是0000 任何提示都将不胜感激 谢谢 例如 ;number = 6c0000h mov ax,word ptr number ;after this mov ax is 0000 ;dividing by ten will mean dx = 0 and ax = 0 and 0 is saved on the stack mov cx,0 repeat:
;number = 6c0000h
mov ax,word ptr number
;after this mov ax is 0000
;dividing by ten will mean dx = 0 and ax = 0 and 0 is saved on the stack
mov cx,0
repeat:
mov dx,0
div ten ;ten = 10
inc cx
push dx
cmp ax,0
ja repeat
mov ax,word ptr number+2
;after this ax is 6Ch
;i think this part is alright
repeat2:
mov dx,0
div ten
inc cx
push dx
cmp ax,0
ja repeat2
display:
pop dx
add dl,'0'
mov ah,02h
int 21h
loop display
此代码显示:1080,而不是预期结果的7077888
108=6Ch,结尾0从0000第10部分开始
注意:我必须使用16位寄存器为什么不分割工作?你知道,你可以把0除以10 在这种情况下,将每个单词除以10,然后将剩余部分保存在堆栈上是行不通的,因为双字的下半部分是0000 不,的确不会。你需要做的是用两个词来表示一个大数字,实现除法。也就是说,您需要实现多精度除法,并将其用于10的除法
关于如何做到这一点的提示,请查看已被接受的答案。因为他正在处理一个巨大的数字,该数字被表示为分成两个单词。除法当然有效,但是除法需要为这种表示实现。啊,是的,我现在可以从代码中看出。当我发布我的答案时,那还没有出现。:)我会调查的。谢谢,是的,这是家庭作业。