How can I substract 64 bit numbers using 3开发者_如何学编程86 assembler?
The idea is to use the SBB
(sub with borrow) instruction. For instance, if I have two numbers:
edx:eax
ecx:ebx
then this will put the difference in edx:eax
:
sub eax, ebx
sbb edx, ecx
The idea is that you can subtract each part separately, but you need to borrow from the MSBs to the LSBs. SBB
does just that:
SBB dest, src
means:
dest <-- dest - src - EFLAGS.CF
Which is convenient because:
SUB dest, src
means:
dest <-- dest - src
EFLAGS.CF <-- borrow from subtraction
精彩评论