mov rax, rdi
mov rbx, [_j]
idiv rbx
There was a dividend in RDI
register and a divisor in the BSS section variable j
. To get the calculation result of RDI % j
, I wrote the code like the upper example while expecting there would be the remainder in RDX
.
However, there was only 0x0
value in RDX register when RDI
was having 5
and j
was having 2
. It seems that the code is not conducting the division calculation as I expected. Can you let me know which point I'm misunderstanding in the division in Assembly?
(My environment: Ubuntu 22.04, 64-bit, WSL2, Windows 11, Intel CPU 64bit/NASM v2.15.05)