flat assembler
Message board for the users of flat assembler.

Index > Main > Subtracting two 64bit values?

Author
Thread Post new topic Reply to topic
Karl20001



Joined: 10 Nov 2005
Posts: 11
Karl20001
If i have a 64bit value in edx:eax, and another one in ecx:ebx

Code:
sub eax,ebx
subb edx, ecx

;result in edx:eax
    


If eax>ebx no problem, if ebx>eax the borrow helps to give correct edx.
But then eax would be a negative number, that cant be right?!
Post 05 Feb 2006, 18:34
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
You just look at them as unsigned numbers. This is the right way to do 64-bit arithmetic:
Code:
add eax,ebx
adc edx,ecx
;edx:eax holds the result

sub eax,ebx
sbb edx,ecx
;edx:eax holds the result

;if carry occurs the eax would wrap around to 0FFFFFFFFh which is 4294967295
;in unsigned world but if you want you can consider it -1 too

multiplication is a bit harder and division a lot harder Smile
    
Post 05 Feb 2006, 22:42
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Karl20001



Joined: 10 Nov 2005
Posts: 11
Karl20001
Hi, thx for your answer Smile
Post 06 Feb 2006, 21:07
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.