diff --git a/unittests/32Bit_ASM/Primary/Primary_60_2.asm b/unittests/32Bit_ASM/Primary/Primary_60_2.asm index c8fc84163..941f91f38 100644 --- a/unittests/32Bit_ASM/Primary/Primary_60_2.asm +++ b/unittests/32Bit_ASM/Primary/Primary_60_2.asm @@ -24,7 +24,11 @@ mov ebp, 4 mov esi, 5 mov edi, 6 -o16 pusha +; operand-size override prefix +; Nasm complains if o16 is used +; `warning: invalid operand size prefix o16, must be o32` +db 0x66 +pusha ; Invert the order mov ax, [esp + 2 * 0] diff --git a/unittests/32Bit_ASM/Primary/Primary_61_2.asm b/unittests/32Bit_ASM/Primary/Primary_61_2.asm index cbf41ea39..a7c155aea 100644 --- a/unittests/32Bit_ASM/Primary/Primary_61_2.asm +++ b/unittests/32Bit_ASM/Primary/Primary_61_2.asm @@ -33,6 +33,10 @@ push word 0x2 push word 0x1 push word 0x0 -o16 popa +; operand-size override prefix +; Nasm complains if o16 is used +; `warning: invalid operand size prefix o16, must be o32` +db 0x66 +popa hlt diff --git a/unittests/ASM/Displacement_Encoding.asm b/unittests/ASM/Displacement_Encoding.asm deleted file mode 100644 index a7a945abc..000000000 --- a/unittests/ASM/Displacement_Encoding.asm +++ /dev/null @@ -1,41 +0,0 @@ -%ifdef CONFIG -{ - "RegData": { - "RAX": "0x4142434445464748", - "RBX": "0x5152535455565758", - "RCX": "0x5152535455565758" - }, - - "MemoryRegions": { - "0x7FFFF000": "4096" - }, - - "MemoryData": { - "0x7FFFF000": "48 47 46 45 44 43 42 41" - } -} -%endif - -; Tests to ensure that 64-bit displacement encoding works correctly without being RIP relative. -; x86-64 has two displacement encodings, one is RIP relative, one is 32-bit (signed) displacement only. -; modrm.mod = 0b00 && modrm.rm = 0b101: Means no SIB, but address mode is RIP + disp32. -; modrm.mod = 0b00 && modrm.rm = 0b100: Means SIB, but address mode is disp32. -; - if SIB.base = 0b101 && SIB.index = 0b100. Which means no registers for base and index. -; Test disp32 by mapping a page at the limit of 2GB and read data from it. Also store and load. -; If we were accidentally using RIP relative, then it would be 2GB + , which won't be mapped. - -; Test disp32 load. -mov rax, [0x7FFF_F000] - -mov rbx, 0x5152535455565758 - -; LEA with disp32. -lea rcx, [0x7FFF_FFF8] - -; Test store with disp32 store. -mov [0x7FFF_FFF8], rbx - -; Load back with the LEA to ensure it's correct. -mov rcx, [rcx] - -hlt diff --git a/unittests/ASM/FEX_bugs/BitConditionCheck.asm b/unittests/ASM/FEX_bugs/BitConditionCheck.asm index 282bd92de..2b9805ea0 100644 --- a/unittests/ASM/FEX_bugs/BitConditionCheck.asm +++ b/unittests/ASM/FEX_bugs/BitConditionCheck.asm @@ -19,7 +19,7 @@ %rep 2000 add qword [rel data], rbx %endrep - lea rax, [%%top] + lea rax, [rel %%top] jpe %%top %endmacro diff --git a/unittests/ASM/FEX_bugs/BranchConditionCheck.asm b/unittests/ASM/FEX_bugs/BranchConditionCheck.asm index c22758402..238374f1f 100644 --- a/unittests/ASM/FEX_bugs/BranchConditionCheck.asm +++ b/unittests/ASM/FEX_bugs/BranchConditionCheck.asm @@ -20,7 +20,7 @@ %rep 37500 add qword [rel data], rbx %endrep - lea rax, [%%top] + lea rax, [rel %%top] jnz %%top %endmacro diff --git a/unittests/ASM/MemoryData.asm b/unittests/ASM/MemoryData.asm index c41b74944..66f34b767 100644 --- a/unittests/ASM/MemoryData.asm +++ b/unittests/ASM/MemoryData.asm @@ -14,5 +14,5 @@ ; Simple test to prove that config loader's MemoryData is working -mov rax, [0x10000000] +mov rax, [abs 0x10000000] hlt diff --git a/unittests/ASM/Primary/Primary_63_2.asm b/unittests/ASM/Primary/Primary_63_2.asm index ac4ef67b4..cd1bfa929 100644 --- a/unittests/ASM/Primary/Primary_63_2.asm +++ b/unittests/ASM/Primary/Primary_63_2.asm @@ -18,7 +18,11 @@ mov rsp, 0x6666666681828384 ; Default: 0x48, 0x63, 0xc4 movsxd rax, esp ; Default with o16 prefix: 0x66, 0x48, 0x63, 0xc4 -o16 movsxd rbx, esp +; operand-size override prefix +; Nasm complains if o16 is used +; `warning: invalid operand size prefix o16, must be o64` +db 0x66 +movsxd rbx, esp ; No-rex widening prefix db 0x63, 0xcc ; movsxd ecx, esp ; o16 prefix with no-rex widening diff --git a/unittests/ASM/Primary/Primary_87_Atomic16.asm b/unittests/ASM/Primary/Primary_87_Atomic16.asm index df6c376b7..1e75f9aa5 100644 --- a/unittests/ASM/Primary/Primary_87_Atomic16.asm +++ b/unittests/ASM/Primary/Primary_87_Atomic16.asm @@ -32,27 +32,27 @@ mov [r15 + 8 * 9], rax ; Test 1 byte offset within 4byte boundary mov rax, 1 -lock xchg word [r15 + 8 * 0 + 1], ax +xchg word [r15 + 8 * 0 + 1], ax mov r14, rax ; Test 3 byte offset across 4byte boundary mov rax, 1 -lock xchg word [r15 + 8 * 0 + 3], ax +xchg word [r15 + 8 * 0 + 3], ax mov r13, rax ; Test 7 byte offset across 8byte boundary mov rax, 1 -lock xchg word [r15 + 8 * 0 + 7], ax +xchg word [r15 + 8 * 0 + 7], ax mov r12, rax ; Test 15 byte offset across 16byte boundary mov rax, 1 -lock xchg word [r15 + 8 * 0 + 15], ax +xchg word [r15 + 8 * 0 + 15], ax mov r11, rax ; Test 63 byte offset across cacheline boundary mov rax, 1 -lock xchg word [r15 + 8 * 0 + 63], ax +xchg word [r15 + 8 * 0 + 63], ax mov r10, rax mov rax, qword [r15 + 8 * 0] diff --git a/unittests/ASM/Primary/Primary_87_Atomic32.asm b/unittests/ASM/Primary/Primary_87_Atomic32.asm index 186e925a4..ff2944459 100644 --- a/unittests/ASM/Primary/Primary_87_Atomic32.asm +++ b/unittests/ASM/Primary/Primary_87_Atomic32.asm @@ -31,22 +31,22 @@ mov [r15 + 8 * 9], rax ; Test 3 byte offset across 4byte boundary mov rax, 1 -lock xchg dword [r15 + 8 * 0 + 3], eax +xchg dword [r15 + 8 * 0 + 3], eax mov r13, rax ; Test 7 byte offset across 8byte boundary mov rax, 1 -lock xchg dword [r15 + 8 * 0 + 7], eax +xchg dword [r15 + 8 * 0 + 7], eax mov r12, rax ; Test 15 byte offset across 16byte boundary mov rax, 1 -lock xchg dword [r15 + 8 * 0 + 15], eax +xchg dword [r15 + 8 * 0 + 15], eax mov r11, rax ; Test 63 byte offset across cacheline boundary mov rax, 1 -lock xchg dword [r15 + 8 * 0 + 63], eax +xchg dword [r15 + 8 * 0 + 63], eax mov r10, rax mov rax, qword [r15 + 8 * 0] diff --git a/unittests/ASM/Primary/Primary_87_Atomic64.asm b/unittests/ASM/Primary/Primary_87_Atomic64.asm index e887bd305..ebb94f6b9 100644 --- a/unittests/ASM/Primary/Primary_87_Atomic64.asm +++ b/unittests/ASM/Primary/Primary_87_Atomic64.asm @@ -30,17 +30,17 @@ mov [r15 + 8 * 9], rax ; Test 7 byte offset across 8byte boundary mov rax, 1 -lock xchg qword [r15 + 8 * 0 + 7], rax +xchg qword [r15 + 8 * 0 + 7], rax mov r13, rax ; Test 15 byte offset across 16byte boundary mov rax, 1 -lock xchg qword [r15 + 8 * 0 + 15], rax +xchg qword [r15 + 8 * 0 + 15], rax mov r12, rax ; Test 63 byte offset across cacheline boundary mov rax, 1 -lock xchg qword [r15 + 8 * 0 + 63], rax +xchg qword [r15 + 8 * 0 + 63], rax mov r11, rax mov rax, qword [r15 + 8 * 0] diff --git a/unittests/ASM/Primary/Primary_C8_o16.asm b/unittests/ASM/Primary/Primary_C8_o16.asm index 9f487ccea..57454c939 100644 --- a/unittests/ASM/Primary/Primary_C8_o16.asm +++ b/unittests/ASM/Primary/Primary_C8_o16.asm @@ -10,6 +10,10 @@ mov rsp, 0xe0001000 mov rbp, 0xe0001000 -o16 enter 0x10, 0 +; operand-size override prefix +; Nasm complains if o16 is used +; `warning: invalid operand size prefix o16, must be o64` +db 0x66 +enter 0x10, 0 hlt diff --git a/unittests/ASM/Primary/Primary_C9_o16.asm b/unittests/ASM/Primary/Primary_C9_o16.asm index 149adc6d2..b9ca868c3 100644 --- a/unittests/ASM/Primary/Primary_C9_o16.asm +++ b/unittests/ASM/Primary/Primary_C9_o16.asm @@ -20,7 +20,12 @@ jmp .end .target: mov rax, 1 -o16 leave + +; operand-size override prefix +; Nasm complains if o16 is used +; `warning: invalid operand size prefix o16, must be o64` +db 0x66 +leave .end: hlt diff --git a/unittests/ASM/Secondary/07_XX_04.asm b/unittests/ASM/Secondary/07_XX_04.asm index 6b961539b..cf0262931 100644 --- a/unittests/ASM/Secondary/07_XX_04.asm +++ b/unittests/ASM/Secondary/07_XX_04.asm @@ -36,11 +36,16 @@ smsw cx smsw [rsi] mov rdx, [rsi] -o16 smsw rdi +; operand-size override prefix +; Nasm complains if o16 is used +; `warning: invalid operand size prefix o16, must be o64` +db 0x66 +smsw rdi repe smsw rsp repne smsw rbp -o16 smsw r8w +db 0x66 +smsw r8w repe smsw r9w repne smsw r10w