getProcessedImmediate

This commit is contained in:
Angie 2022-07-06 20:12:37 -04:00
parent 6fc7be4517
commit c129447463
4 changed files with 10 additions and 0 deletions

View File

@ -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);

View File

@ -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: ...

View File

@ -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, ""),

View File

@ -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);