Skip to content

Commit

Permalink
unittests: Add test for carry inversion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bylaws committed Nov 18, 2024
1 parent a69135c commit 6baad30
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions unittests/32Bit_ASM/FEX_bugs/InvertedCarrySet.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "1"
},
"Mode": "32BIT"
}
%endif

; FEX had a bug where inverting CF to match the ABI when flushing the register cache didn't mark CF as possibly being set.
; This caused accesses relying on that flag to be set correctly to return wrong values.

mov esp, 0xe0000020
mov al, 3
mov cl, 2
mov ecx, 1
mov eax, 1

and al, cl ; Zeros CF, non-inverted
push ecx ; Triggers a register cache flush
inc eax ; Tries to preserve CF, but would encounter the bug and set it instead
jnb succ
mov eax, 0
hlt
succ:
mov eax, 1
hlt

0 comments on commit 6baad30

Please sign in to comment.