The MASM Forum

General => The Campus => Topic started by: kejt on January 27, 2013, 06:24:11 AM

Title: How to divide signed numbers?
Post by: kejt on January 27, 2013, 06:24:11 AM
Hi,
I have some problems with dividing signed number.

include /masm32/include/masm32rt.inc

.data?
stop db ?
.data

.code
start:
xor edx, edx
mov eax, -10
mov ebx, 2
idiv ebx

print str$(eax)

push 1
push offset stop
call StdIn

push 0
call ExitProcess

end start


in the result i get 2147483643. It should be -5. What I'm doing wrong?
Title: Re: How to divide signed numbers?
Post by: jj2007 on January 27, 2013, 06:40:15 AM
                        ; xor                edx, edx
                        mov                eax, -10
                        cdq

->\masm32\help\Opcodes.chm  ;)
Title: Re: How to divide signed numbers?
Post by: kejt on January 27, 2013, 07:02:38 AM
Now it works. Thanks.