Skip to content

Commit

Permalink
Merge pull request #3471 from Sonicadvance1/another_3421_bug
Browse files Browse the repository at this point in the history
ASM: Another sign extend bug in #3421
  • Loading branch information
alyssarosenzweig authored Mar 1, 2024
2 parents 009ae55 + b3489d7 commit b7984e8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions unittests/32Bit_ASM/FEX_bugs/SignExtendBug.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
{
"RegData": {
"RAX": "0x41424344",
"RBX": "0x41424344"
"RBX": "0x41424344",
"RCX": "0x51525354"
},
"MemoryRegions": {
"0x00fd0000": "4096",
"0xf0000000": "4096"
},
"MemoryData": {
"0xf0000000": "0x41424344"
"0xf0000000": "0x41424344",
"0x00fd0000": "0x51525354"
},
"Mode": "32BIT"
}
Expand All @@ -27,4 +30,14 @@ jmp .test
.test:
mov ebx, [ebx+ecx]

; Ensures that zext occurs correctly with SIB indexing with second argument not having sign bit set but "index" having sign bit.
; Originally saw in Metal Gear Rising Revengeance with a `jmp dword [ecx*4+0xfdbf10]` instruction.
; With ecx = 0xfffffff4 = -12. This is them loading a switch table's branches just before the switch base.
mov ecx, -12

; Break the block so it can't optimize through.
jmp .test2
.test2:

mov ecx, [ecx*4+0x00fd_0030]
hlt

0 comments on commit b7984e8

Please sign in to comment.