开发者

Substracting 64bit numbers in x86 assembler?

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:

  1. edx:eax
  2. 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜