11/* *************************** disasm2.cpp ********************************
22* Author: Agner Fog
33* Date created: 2007-02-25
4- * Last modified: 2023-03-29
4+ * Last modified: 2025-08-26
55* Project: objconv
66* Module: disasm2.cpp
77* Description:
88* Module for disassembler containing file output functions
99*
1010* Changes that relate to assembly language syntax should be done in this file only.
1111*
12- * Copyright 2007-2023 GNU General Public License http://www.gnu.org/licenses
12+ * Copyright 2007-2025 GNU General Public License http://www.gnu.org/licenses
1313*****************************************************************************/
1414#include " stdafx.h"
1515
@@ -72,7 +72,7 @@ SIntTxt AsmWarningTexts1[] = {
7272 {8 , " Displacement could be made smaller by sign extension" },
7373 {0x10 , " SIB byte unnecessary here" },
7474 {0x20 , " A shorter instruction exists for register operand" },
75- {0x40 , " Length-changing prefix causes delay on Intel processors" },
75+ {0x40 , " Length-changing prefix causes delay on old Intel processors" },
7676 {0x80 , " Address size prefix should be avoided" },
7777 {0x100 , " Same prefix occurs more than once" },
7878 {0x200 , " Prefix valid but unnecessary" },
@@ -91,7 +91,7 @@ SIntTxt AsmWarningTexts1[] = {
9191 {0x400000 , " Memory operand is misaligned. Performance penalty" },
9292 {0x800000 , " Alignment fault. Memory operand must be aligned" },
9393 {0x1000000 , " Multi-byte NOP. Replace with ALIGN" },
94- {0x2000000 , " Bogus length-changing prefix causes delay on Intel processors here" },
94+ {0x2000000 , " Bogus length-changing prefix causes delay on old Intel processors here" },
9595 {0x4000000 , " Non-default size for stack operation" },
9696 {0x8000000 , " Function does not end with ret or jmp" },
9797 {0x10000000 , " No jump seems to point here" },
@@ -1098,6 +1098,9 @@ void CDisassembler::WriteImmediateOperand(uint32_t Type) {
10981098 if ((s.Operands [0 ] & 0xFFF ) <= 0xA && s.Operands [0 ] != 0 || (s.Operands [0 ] & 0xF0 ) == 0xA0 ) {
10991099 // Destination is general purpose register
11001100 OSize = s.OperandSize ;
1101+ if ((s.Operands [0 ] & 0x0F ) < 3 ) {
1102+ OSize = (s.Operands [0 ] & 0x0F ) << 3 ;
1103+ }
11011104 }
11021105 else {
11031106 // Constant probably unrelated to destination size
@@ -1108,8 +1111,8 @@ void CDisassembler::WriteImmediateOperand(uint32_t Type) {
11081111
11091112 // Check if sign extended
11101113 if (OSize > s.ImmediateFieldSize * 8 ) {
1111- if (WriteFormat == 2 && Value >= 0 ) {
1112- // Hexadecimal sign extended, not negative:
1114+ if (WriteFormat == 2 && Value >= 0 ) {
1115+ // Hexadecimal sign extended
11131116 // Does not need full length
11141117 OSize = s.ImmediateFieldSize * 8 ;
11151118 }
0 commit comments