real mode div turn out to err
Posted: Thu Aug 26, 2010 11:50 pm
hi,
i've been programming for long, but how stupid today!
my code to print decade in real mode:
it died at " div ebx" , bochsdbg showed that it went wrong here(for that the next instruction executed is IRET).
but why? it do not use fpu, divider is not zero, why?
and if i use " div bl ", no better. and if mov bl,123 previously, it do not die anymore.
help stupid me, thanks!
i've been programming for long, but how stupid today!
my code to print decade in real mode:
Code: Select all
printd:
pusha
mov bp,sp
mov cx,10 ;at most 10 decade numbers
.div:
clc
mov ebx,10
div ebx
push edx
loop .div
mov cx,10
.try0:
pop eax
or eax,eax
jz .try0
.prt:
add al,'0'
mov bl,2
mov ah,0x0e
int 0x10
pop eax
loop .prt
mov sp,bp
popa
ret
but why? it do not use fpu, divider is not zero, why?
and if i use " div bl ", no better. and if mov bl,123 previously, it do not die anymore.
help stupid me, thanks!