Sign in to follow this  
Sante05

32 bit add in ASM

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this