From 41a4e5884dddf36a01beba1bb8ae00c750915e08 Mon Sep 17 00:00:00 2001 From: bird_egop Date: Wed, 16 Apr 2025 20:18:14 +0300 Subject: [PATCH] Fixed special case in INC/DEC tests with EBP addressing. When Mod=00 and R/M=101 (EBP), it indicates a 32-bit displacement-only addressing mode, not [EBP]. Added correct test cases with Mod=01 and zero displacement. --- X86DisassemblerTests/TestData/misc_tests.csv | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/X86DisassemblerTests/TestData/misc_tests.csv b/X86DisassemblerTests/TestData/misc_tests.csv index 163c62f..6fe7533 100644 --- a/X86DisassemblerTests/TestData/misc_tests.csv +++ b/X86DisassemblerTests/TestData/misc_tests.csv @@ -34,10 +34,19 @@ F4;[{ "Type": "Hlt", "Operands": [] }] # LOCK prefix F0;[{ "Type": "Lock", "Operands": [] }] -F0FE05;[{ "Type": "Inc", "Operands": ["byte ptr [ebp]"], "Prefix": "Lock" }] -F0FF05;[{ "Type": "Inc", "Operands": ["dword ptr [ebp]"], "Prefix": "Lock" }] -F0FE0D;[{ "Type": "Dec", "Operands": ["byte ptr [ebp]"], "Prefix": "Lock" }] -F0FF0D;[{ "Type": "Dec", "Operands": ["dword ptr [ebp]"], "Prefix": "Lock" }] +# SPECIAL CASE: When Mod=00 and R/M=101 (EBP), this doesn't actually refer to [EBP]. +# Instead, it's a special case that indicates a 32-bit displacement-only addressing mode. +# The correct encoding for instructions with [ebp] would use Mod=01 and a zero displacement. +# F0FE05;[{ "Type": "Inc", "Operands": ["byte ptr [ebp]"], "Prefix": "Lock" }] +# F0FF05;[{ "Type": "Inc", "Operands": ["dword ptr [ebp]"], "Prefix": "Lock" }] +# F0FE0D;[{ "Type": "Dec", "Operands": ["byte ptr [ebp]"], "Prefix": "Lock" }] +# F0FF0D;[{ "Type": "Dec", "Operands": ["dword ptr [ebp]"], "Prefix": "Lock" }] + +# Adding the correct test cases: +F0FE4500;[{ "Type": "Inc", "Operands": ["byte ptr [ebp+0x0]"], "Prefix": "Lock" }] +F0FF4500;[{ "Type": "Inc", "Operands": ["dword ptr [ebp+0x0]"], "Prefix": "Lock" }] +F0FE4D00;[{ "Type": "Dec", "Operands": ["byte ptr [ebp+0x0]"], "Prefix": "Lock" }] +F0FF4D00;[{ "Type": "Dec", "Operands": ["dword ptr [ebp+0x0]"], "Prefix": "Lock" }] # IN - Input from Port E410;[{ "Type": "In", "Operands": ["al", "0x10"] }]