2010-12-05 137 views
1

例如,我有数量6C0000h = 7077888d打印双字数目为10进制

除以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: 
    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 DIV 10 ..

注意:我必须使用16位寄存器

+1

作业我想! – 2010-12-05 15:52:50

回答

2

除以10的每个单词,然后保存在堆栈在这种情况下不工作的余数,因为双字的下部是0000

没有它的确不会。你需要做的是用两个词来实现你的大量代表的划分。也就是说,您需要实施多精度分割,并将其用于除法。

有关如何操作的提示,请查看this question的接受答案。

1

为什么不分工?你知道,你可以将0分为10。

+1

因为他正在与一个巨大的数字表示分为两个单词。当然,司的工作,但分工需要执行这种表示。 – 2010-12-05 13:58:50

+0

啊,是的,我现在可以通过代码告诉。当我回答我的答案时,那还没有。 :) – GolezTrol 2010-12-05 18:17:27