Hello, I need to calculate modulo and trying to find best and short way to do it for example:
9%5=4 beacause 9=1*5+4
8%4=0 because 8=2*4+0
So far I found that way:
Given 11 % 3 how would you find the remainder? Well how would you do divide?
11 - 3 = +1 cycle with 8 left over
8 is > 3 so keep going
8 - 3 = +1 cycle with 5 left over
5 > 3 so...
5 - 3 = +1 cycle with 2 left over
2 is < 3 and > 0 so the remainder is 2 after 11 % 3
Is there any better way ?
Thank you
mov eax, 9
mov ecx, 5
div ecx
modulous in edx
It works thank you :) just needed to zero the DX prior dividing :)
xor dx, dx