diff --git a/include/instructions/RabbitizerInstruction.h b/include/instructions/RabbitizerInstruction.h index b6ce43e..71d372e 100644 --- a/include/instructions/RabbitizerInstruction.h +++ b/include/instructions/RabbitizerInstruction.h @@ -126,6 +126,7 @@ void RabbitizerInstruction_processUniqueId(RabbitizerInstruction *self); uint32_t RabbitizerInstruction_getRaw(const RabbitizerInstruction *self); uint32_t RabbitizerInstruction_getImmediate(const RabbitizerInstruction *self); +int32_t RabbitizerInstruction_getProcessedImmediate(const RabbitizerInstruction *self); uint32_t RabbitizerInstruction_getInstrIndex(const RabbitizerInstruction *self); uint32_t RabbitizerInstruction_getInstrIndexAsVram(const RabbitizerInstruction *self); diff --git a/rabbitizer/rabbitizer.pyi b/rabbitizer/rabbitizer.pyi index 9577bcb..8cfb597 100644 --- a/rabbitizer/rabbitizer.pyi +++ b/rabbitizer/rabbitizer.pyi @@ -25,6 +25,7 @@ class Instruction: def getRaw(self) -> int: ... def getImmediate(self) -> int: ... + def getProcessedImmediate(self) -> int: ... def getInstrIndexAsVram(self) -> int: ... def getBranchOffset(self) -> int: ... def getGenericBranchOffset(self, currentVram: int) -> int: ... diff --git a/rabbitizer/rabbitizer_type_Instruction.c b/rabbitizer/rabbitizer_type_Instruction.c index 1288213..e7dc23f 100644 --- a/rabbitizer/rabbitizer_type_Instruction.c +++ b/rabbitizer/rabbitizer_type_Instruction.c @@ -142,6 +142,7 @@ static PyGetSetDef Instr_getsetters[] = { DEF_METHOD_GET_UINT(getRaw) DEF_METHOD_GET_UINT(getImmediate) +DEF_METHOD_GET_INT(getProcessedImmediate) DEF_METHOD_GET_UINT(getInstrIndexAsVram) DEF_METHOD_GET_INT(getBranchOffset) @@ -295,6 +296,7 @@ static PyObject *rabbitizer_type_Instruction_disassemble(PyRabbitizerInstruction static PyMethodDef Instr_methods[] = { METHOD_NO_ARGS(getRaw, ""), METHOD_NO_ARGS(getImmediate, ""), + METHOD_NO_ARGS(getProcessedImmediate, ""), METHOD_NO_ARGS(getInstrIndexAsVram, ""), METHOD_NO_ARGS(getBranchOffset, ""), METHOD_ARGS(getGenericBranchOffset, ""), diff --git a/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c b/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c index 63a645e..e4727f6 100644 --- a/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c +++ b/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c @@ -37,6 +37,12 @@ uint32_t RabbitizerInstruction_getRaw(const RabbitizerInstruction *self) { uint32_t RabbitizerInstruction_getImmediate(const RabbitizerInstruction *self) { return RAB_INSTR_GET_immediate(self); } +int32_t RabbitizerInstruction_getProcessedImmediate(const RabbitizerInstruction *self) { + if (RabbitizerInstrDescriptor_isUnsigned(self->descriptor)) { + return RAB_INSTR_GET_immediate(self); + } + return RabbitizerUtils_From2Complement(RAB_INSTR_GET_immediate(self), 16); +} uint32_t RabbitizerInstruction_getInstrIndex(const RabbitizerInstruction *self) { return RAB_INSTR_GET_instr_index(self);