Highlight 64-bit numbers in x86 assembler?

How can I subtract 64-bit numbers using 386 assembler?

+3
source share
1 answer

The idea is to use the instruction SBB(sub with loan). For example, 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 MSB for the lower digits. SBBdoes just that:

SBB dest, src means:

dest <-- dest - src - EFLAGS.CF

This is convenient because:

SUB dest, src means:

dest <-- dest - src
EFLAGS.CF <-- borrow from subtraction
+12
source

Source: https://habr.com/ru/post/1750359/


All Articles