From 64239b756554f792be74a7a03fce4604963b01ae Mon Sep 17 00:00:00 2001 From: Angie Date: Thu, 7 Jul 2022 00:16:21 -0400 Subject: [PATCH] Simplify logic of RabbitizerOperandType_processImmediate --- .../RabbitizerInstruction_Disassemble.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c index 3fe730d..c60b540 100644 --- a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c +++ b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c @@ -158,24 +158,19 @@ size_t RabbitizerOperandType_processLabel(const RabbitizerInstruction *self, cha size_t RabbitizerOperandType_processImmediate(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { size_t totalSize = 0; - uint32_t imm; + int32_t number; if (immOverride != NULL) { memcpy(dst, immOverride, immOverrideLength); return immOverrideLength; } - imm = RabbitizerInstruction_getImmediate(self); - if (!self->descriptor->isUnsigned) { - int32_t number = RabbitizerUtils_From2Complement(imm, 16); - - if (number < 0) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%X", -number); - return totalSize; - } + number = RabbitizerInstruction_getProcessedImmediate(self); + if (number < 0) { + RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%X", -number); + } else { + RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", number); } - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", imm); return totalSize; }