Can anyone help me on this problem? I am trying to divide a negative and a posive number in asembler using the IDIV command. Say i divide -9/3 the result should be -3, but it outputs a strange number?
Any ideas? Much help appreciated.
Can anyone help me on this problem? I am trying to divide a negative and a posive number in asembler using the IDIV command. Say i divide -9/3 the result should be -3, but it outputs a strange number?
Any ideas? Much help appreciated.
You're probably not promoting the ax/eax sign into dx/edx. Using 32bits, it'd should look something like -
Code:int i=3; int j=-9; _asm { mov eax,j cdq idiv i mov j,eax }
Thanks, that works for 32bit, but it has got to be done in 8086 16bit; with the correct answer for any combination of positive or negative numbers. It is really annoying me this.
Then try -
Code:_asm { mov ax,-9 cwd idiv i mov j,ax }
Cheers, soz to blother you again is the remainder still being stored in the ah register i'm using this code to get it out:
short r;
mov cl,ah
mov r, cx
Got!!! Remainder stored in dx. Thanks for your help, how do you learn this???
V.greatful!!!