Question Details

No question body available.

Tags

assembly x86-64 nasm signed integer-division

Answers (1)

Accepted Answer Available
Accepted Answer
February 7, 2026 Score: 7 Rep: 4,565 Quality: High Completeness: 40%

The signed dividend is the 128-bit number in rdx:rax. So to represent -10, you need to set rdx to -1, not to zero. There is the CQO instruction that sets rdx using the sign bit of rax.

You might want to use this code instead:

mov rax, -10 cqo mov rbx, 5 idiv rbx