-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
It's not really that easy to do 64-bit subtraction because SBX is screwed up.
The 1.7 spec says:
3 | 0x1b | SBX b, a | sets b to b-a+EX, sets EX to 0xFFFF if there is an underflow, 0x0 otherwise
Here's some test code:
SET A, 0x0123
SET B, 0x4567
SET C, 0x89ab
SET X, 0xcdef
SET Y, 0x0123
SET Z, 0x4567
SET I, 0x89ab
SET J, 0xcdf0
; Find ABCX - YZIJ (should be 0xffffffffffffffff, or -1, since YZIJ = ABCX + 1)
SUB X, J
SBX C, I
SBX B, Z
SBX A, Y
This is similar to the 64-bit addition code, which uses ADD and ADXlike that. Unfortunately, because SBX works improperly (it sets EX to 1 after the second underflow, so it adds 1 rather than borrowing 1) we get incorrect results.
This was discussed here: http://0x10cforum.com/forum/page/1/m/4932880/viewthread/2964261-which-result-correct-for-sbx
Metadata
Metadata
Assignees
Labels
No labels