[英]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.