Re: itoa assembly version
- From: leon800219@xxxxxxxxx
- Date: 30 May 2006 08:59:58 -0700
Frank Kotler 写道:
"div bx" divides dx:ax by bx, not just ax. If the result won't fit inI have set the dx to zero before divide operation. So "div bx" turn out
ax, which it won't if dx>=bx, it causes an exception.
Most common newbie error in existance!
to be divide 0000:ax by bx. And I figure that will not cause any
"divide overflow"
And the code changed to:
assume cs:code,ds:data
data segment
dw 12, 23, 34, 45, 56, 12666
data ends
display segment
db '000000000000000', 0
display ends
stack segment
db '0000000000'
stack ends
code segment
start:
mov ax, data
mov es, ax
mov ax, display
mov ds, ax
call dtoc
mov si, 0
mov dh, 8
mov dl, 3
mov cl, 2
call show_str
mov ax,4c00h
int 21h
dtoc:
mov di, 0
mov cx, 6
s:
push cx
mov ax, es:[di]
mov bx, 0AH
s0: div bx
mov cx, ax
jcxz ok
add dl, 30h
mov byte ptr ds:[si], dl
mov dx, 0
inc si
jmp short s0
ok:add dl, 30h
mov byte ptr ds:[si], dl
inc si
add di, 2
mov dx, 0
pop cx
loop s
ret
I have debugged it in protected mode and found that
ds:0 contains 213243546566621 which is quite what I want, though in
reverse order, I could use stack to implement that. But the question is
when I run this program in real mode(because I want it to displayon
screen), I still experience "divide overflow", how this could be?
.
- Follow-Ups:
- Re: itoa assembly version
- From: Frank Kotler
- Re: itoa assembly version
- References:
- Re: itoa assembly version
- From: Frank Kotler
- Re: itoa assembly version
- Prev by Date: Re: MASM Expert needed immediately
- Next by Date: Re: NASM
- Previous by thread: Re: itoa assembly version
- Next by thread: Re: itoa assembly version
- Index(es):
Relevant Pages
|