FEX/unittests/ASM/Primary/Primary_8C_2.asm
Ryan Houdek 6b7a84bef2 OpcodeDispatcher: Fixes weirdo edge case in segment moving
Just noticed this while casually reading the x86 architecture manuals.
The move segment registers instructions ignore the REX.R prefix on the
segment register.

Previously this was expected to create an invalid register selection.
A little bit silly but sure, support it.
2022-02-07 21:12:53 -08:00

46 lines
639 B
NASM

%ifdef CONFIG
{
"RegData": {
"RAX": "0x4142",
"RBX": "0x4143",
"RCX": "0x4144"
}
}
%endif
; This relies on some behaviour that isn't guaranteed in 64bit mode
; Technically this can result in an invalid selector which can cause faults
; We currently don't do any selector validation to enforce this
mov rax, 0x4142
db 0x44 ; REX.R
mov es, ax
inc rax
db 0x44 ; REX.R
mov ss, ax
inc rax
db 0x44 ; REX.R
mov ds, ax
; Can't test FS/GS here
; Behaviour is ill-defined and needs to be worked through
mov rax, 0
mov rbx, 0
mov rcx, 0
db 0x44 ; REX.R
mov ax, es
db 0x44 ; REX.R
mov bx, ss
db 0x44 ; REX.R
mov cx, ds
hlt