Divide a negative with a positive
问题 Assume the following code: mov eax, 0 sub eax, 2 xor edx, edx idiv base where base equals to 8 (defined as const int base = 8 ). As a result, I expect to get 0 in eax and 2 (or −2) in edx . However, the result of the division is a big long number. Most likely, it is caused by overflow in eax registry, when I subtract 2 from it. I think eax is interpreted by idiv operation as unsigned int . How do I perform this division properly? I code in Visual Studio 2013 on x64 system. 回答1: The usual