Skip to content

Commit

Permalink
unittests/ASM: Adds tests for loop instruction address size overrides
Browse files Browse the repository at this point in the history
32-bit test would fail if the 16-bit address size override wasn't
respected.
  • Loading branch information
Sonicadvance1 committed Mar 22, 2024
1 parent 824f122 commit 9ab930c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
27 changes: 27 additions & 0 deletions unittests/32Bit_ASM/FEX_bugs/LoopAddressSizeCheck.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0x0000000000000001",
"RBX": "0x0000000000010001"
},
"Mode": "32BIT"
}
%endif

; FEX-Emu had a bug where a16 loop instructions weren't treating the input RCX register as 16-bit.
; Effectively always treating it as 32-bit.
; Little test that operates at 16-bit and 32-bit sizes to ensure it is correctly handled.
mov eax, 0
mov ebx, 0
mov ecx, 0x0001_0001

.test:
inc eax
a16 loop .test

mov ecx, 0x0001_0001
.test2:
inc ebx
a32 loop .test2

hlt
25 changes: 25 additions & 0 deletions unittests/ASM/FEX_bugs/LoopAddressSizeCheck.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0x0000000000010001",
"RBX": "0x0000000000000001"
}
}
%endif

; FEX-Emu had a bug in the 32-bit implementation of LOOP where it didn't handle 16-bit RCX correctly.
; For test coverage on the 64-bit side, ensure that both 64-bit and 32-bit operation works correctly.
mov rax, 0
mov rbx, 0
mov rcx, 0x0001_0001

.test:
inc rax
a64 loop .test

mov rcx, 0x1_0000_0001
.test2:
inc rbx
a32 loop .test2

hlt

0 comments on commit 9ab930c

Please sign in to comment.