Okay, this is embarrassing.
I'm trying to implement the MOD operator as an ASM routine using the definition given in the BB4W docs:
A MOD B = A - ( A DIV B ) * B
For my purposes, A is a signed 32-bit integer (so it may be negative), and B is always a positive integer never greater than 16 bits.
Things are fine until one supplies a negative A, because I can't work out how to convert a signed 64-bit integer to a signed 32-bit integer (the absolute value of the signed 64-bit integer is assumed never to exceed 32 bits, or 31 bits, strictly speaking).
So, doing the A DIV B part, I've got:
Code:; EAX = A, EBX = B
xor edx, edx
idiv ebx
How do I convert the possibly negative 64-bit value in EDX:EAX to a signed 32-bit value (again bearing in mind the absolute value in EDX:EAX doesn't exceed 32 bits)?
I did try using floating point instructions, but without success.
David.