32 bit add in ASM

Started by
1 comment, last by Sante05 16 years, 11 months ago
Hi, I'm having some problems when adding 2 32-bit registers in ASM (using VC++ 6.0):

mov eax, 2
mov ebx, 4886718345
add eax, ebx	
When doing this, the eax register returns with 591751051 instead of the correct result (4886718347). It seems it's only adding the lower 16 bits. (Note: the numbers are in decimal)
-----DevZing Blog (in Spanish)
Advertisement
This is because 4886718345 is out of the range of a 32-bit unsigned int. If you modulo this with 2^32 you get 591751049 which when added to 2 gives you the result you are getting.
Thanks! My mistake
-----DevZing Blog (in Spanish)

This topic is closed to new replies.

Advertisement