• Advertisement
Sign in to follow this  

32 bit add in ASM

This topic is 3943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement