Heya..
I needed a little macro for calculating modulus.
It preserves ecx and trashes eax and edx.
Remove the push and pop of ecx if you don't mind trashing it too.

If you wanted eg X=115 mod 28
use it like this:
mov Answer, _mod (115,28)

You can of course use variable names instead of or as well as immediate values.

_mod MACRO val1:REQ, val2:REQ
push ecx
mov eax,val1
mov ecx,val2
xor edx,edx
div ecx
pop ecx
exitm <edx>
endm
Posted on 2004-01-10 17:11:31 by Homer