问题
I'm trying to do a simple division:
mov ebx, 10
mov eax, 1111111111 ;(10 times)
mov edx, 0
idiv bx
Supposedly I want to get the following results:
edx = 1
eax = 111111111 (9 times)
But the results I'm getting are:
edx = 7
eax = 1111098720
Does anyone know what the problem might be?
Thanks
回答1:
mov ebx, 10 mov eax, 1111111111 ;(10 times) mov edx, 0 idiv bx
What immediately strikes me is that you setup all registers for 32-bit operation but then perform a 16-bit division.
Changing it to the following will give the desired results:
mov ebx, 10
mov eax, 1111111111
cdq
idiv ebx
来源:https://stackoverflow.com/questions/37552056/idiv-in-assembly-isnt-giving-me-the-wanted-result-nasm