1

例如我有数字 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:
    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 位寄存器

4

2 回答 2

2

在这种情况下,将每个字除以 10,然后将余数保存在堆栈中是行不通的,因为双字的下半部分是 0000。

不,确实不会。你需要做的是用两个词来实现一个大数的除法。即,您需要实现多精度除法,并将其用于除以 10。

有关如何执行此操作的提示,请查看此问题的已接受答案。

于 2010-12-05T14:02:40.887 回答
1

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

于 2010-12-05T10:53:40.790 回答