[英]Proper way to subtract two 64 bit numbers in x86 assembly
我使用的是32位系统,并且在EDX:EAX中保存了64位数字。 我试图减去保存在ESI中的数字:EDI是否正确? 我很确定不是,因为经过3次迭代后结果不正确。
sub %esi, %edx #Subtract two 64 bit numbers
sub %edi, %eax
您需要进行两项更改:
borrow
位,则需要从高阶位中再减去一个。 幸运的是,CPU会记住是否有借位(在carry flag
CF中),并且有一条指令通过借位减SBB
这是最终代码
sub %edi, %eax # Subtract low order 32-bits, borrow reflected in CF
sbb %esi, %edx # Subtract high order 32-bits, and the borrow if there was one
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.