mirror of
https://github.com/Decompollaborate/rabbitizer.git
synced 2025-02-06 03:39:56 +00:00
cleanup
This commit is contained in:
parent
c1a6abe186
commit
5b04520269
@ -26,6 +26,22 @@ typedef enum RabbitizerOperandType {
|
|||||||
#undef RAB_DEF_OPERAND
|
#undef RAB_DEF_OPERAND
|
||||||
|
|
||||||
|
|
||||||
|
struct RabbitizerInstruction;
|
||||||
|
|
||||||
|
typedef size_t (*OperandCallback)(const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
||||||
|
|
||||||
|
extern const OperandCallback instrOpercandCallbacks[];
|
||||||
|
|
||||||
|
|
||||||
|
#define RAB_DEF_OPERAND(prefix, operand) size_t RabbitizerOperandType_process_##prefix##_##operand (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
||||||
|
|
||||||
|
#include "instructions/operands/RabbitizerOperandType_cpu.inc"
|
||||||
|
#include "instructions/operands/RabbitizerOperandType_rsp.inc"
|
||||||
|
#include "instructions/operands/RabbitizerOperandType_r5900.inc"
|
||||||
|
|
||||||
|
#undef RAB_DEF_OPERAND
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
5
setup.py
5
setup.py
@ -12,8 +12,9 @@ setup(
|
|||||||
"rabbitizer/enums/rabbitizer_type_Enum.c", "rabbitizer/enums/enums_utils.c", "rabbitizer/enums/rabbitizer_enum_InstrCategory.c", "rabbitizer/enums/rabbitizer_enum_InstrId.c", "rabbitizer/enums/rabbitizer_enum_Abi.c", "rabbitizer/enums/rabbitizer_enum_OperandType.c",
|
"rabbitizer/enums/rabbitizer_type_Enum.c", "rabbitizer/enums/enums_utils.c", "rabbitizer/enums/rabbitizer_enum_InstrCategory.c", "rabbitizer/enums/rabbitizer_enum_InstrId.c", "rabbitizer/enums/rabbitizer_enum_Abi.c", "rabbitizer/enums/rabbitizer_enum_OperandType.c",
|
||||||
"rabbitizer/enums/registers/rabbitizer_enum_GprO32.c", "rabbitizer/enums/registers/rabbitizer_enum_GprN32.c",
|
"rabbitizer/enums/registers/rabbitizer_enum_GprO32.c", "rabbitizer/enums/registers/rabbitizer_enum_GprN32.c",
|
||||||
"src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c",
|
"src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c",
|
||||||
"src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c", "src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c",
|
"src/instructions/RabbitizerInstructionCpu/RabbitizerInstructionCpu_OperandType.c",
|
||||||
"src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c", "src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c",
|
"src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c", "src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c", "src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_OperandType.c",
|
||||||
|
"src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c", "src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c", "src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c",
|
||||||
"src/instructions/RabbitizerInstrDescriptor.c", "src/instructions/RabbitizerInstrId.c", "src/instructions/RabbitizerRegister.c", "src/instructions/RabbitizerInstrSuffix.c",
|
"src/instructions/RabbitizerInstrDescriptor.c", "src/instructions/RabbitizerInstrId.c", "src/instructions/RabbitizerRegister.c", "src/instructions/RabbitizerInstrSuffix.c",
|
||||||
"src/analysis/RabbitizerTrackedRegisterState.c", "src/analysis/RabbitizerRegistersTracker.c", "src/analysis/RabbitizerLoPairingInfo.c",
|
"src/analysis/RabbitizerTrackedRegisterState.c", "src/analysis/RabbitizerRegistersTracker.c", "src/analysis/RabbitizerLoPairingInfo.c",
|
||||||
"src/common/Utils.c", "src/common/RabbitizerVersion.c", "src/common/RabbitizerConfig.c"],
|
"src/common/Utils.c", "src/common/RabbitizerVersion.c", "src/common/RabbitizerConfig.c"],
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
/* SPDX-License-Identifier: MIT */
|
/* SPDX-License-Identifier: MIT */
|
||||||
|
|
||||||
#include "instructions/RabbitizerInstruction.h"
|
#include "instructions/RabbitizerInstruction.h"
|
||||||
#include "instructions/RabbitizerInstructionRsp.h"
|
|
||||||
#include "instructions/RabbitizerInstructionR5900.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -14,784 +12,6 @@
|
|||||||
#include "instructions/RabbitizerRegister.h"
|
#include "instructions/RabbitizerRegister.h"
|
||||||
#include "instructions/RabbitizerInstrSuffix.h"
|
#include "instructions/RabbitizerInstrSuffix.h"
|
||||||
|
|
||||||
typedef size_t (*OperandCallback)(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_rs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rs(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_rt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rt(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_rd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rd(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_zero(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
|
||||||
UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameGpr(0);
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_cop0d(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameCop0(RAB_INSTR_GET_cop0d(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_fs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameCop1(RAB_INSTR_GET_fs(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_ft(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameCop1(RAB_INSTR_GET_ft(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_fd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameCop1(RAB_INSTR_GET_fd(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_cop1cs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameCop1Control(RAB_INSTR_GET_cop1cs(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_cop2t(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameCop2(RAB_INSTR_GET_cop2t(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_sa(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
// TODO: consider making this a proper configuration
|
|
||||||
#if 0
|
|
||||||
if (RAB_INSTR_GET_sa(self) < 10) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_sa(self));
|
|
||||||
} else {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", RAB_INSTR_GET_sa(self));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_sa(self));
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_op(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
// TODO: consider making this a proper configuration
|
|
||||||
#if 0
|
|
||||||
if (RAB_INSTR_GET_op(self) < 10) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_op(self));
|
|
||||||
} else {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", RAB_INSTR_GET_op(self));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%02X", RAB_INSTR_GET_op(self));
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_code(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
int code = RAB_INSTR_GET_code_upper(self);
|
|
||||||
int lower = RAB_INSTR_GET_code_lower(self);
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", code);
|
|
||||||
if (lower) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, ", %i", lower);
|
|
||||||
}
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_code_lower(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
|
||||||
UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
int code_lower = RAB_INSTR_GET_code_lower(self);
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", code_lower);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_copraw(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", RAB_INSTR_GET_copraw(self));
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_label(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
if ((immOverride != NULL) && (immOverrideLength > 0)) {
|
|
||||||
memcpy(dst, immOverride, immOverrideLength);
|
|
||||||
return immOverrideLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "func_%06X", RabbitizerInstruction_getInstrIndexAsVram(self));
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_immediate(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
int32_t number;
|
|
||||||
|
|
||||||
if ((immOverride != NULL) && (immOverrideLength > 0)) {
|
|
||||||
memcpy(dst, immOverride, immOverrideLength);
|
|
||||||
return immOverrideLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
number = RabbitizerInstruction_getProcessedImmediate(self);
|
|
||||||
if (RabbitizerConfig_Cfg.misc.omit0XOnSmallImm) {
|
|
||||||
if (number > -10 && number < 10) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", number);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (number < 0) {
|
|
||||||
if (RabbitizerConfig_Cfg.misc.upperCaseImm) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%X", -number);
|
|
||||||
} else {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%x", -number);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (RabbitizerConfig_Cfg.misc.upperCaseImm) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", number);
|
|
||||||
} else {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", number);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_branch_target_label(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
if ((immOverride != NULL) && (immOverrideLength > 0)) {
|
|
||||||
memcpy(dst, immOverride, immOverrideLength);
|
|
||||||
return immOverrideLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, ". + 4 + (");
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, NULL, 0));
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, " << 2)");
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_cpu_immediate_base(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
// TODO: consider making this a proper configuration
|
|
||||||
#if 0
|
|
||||||
if ((immOverride != NULL) && (immOverrideLength > 0) || RAB_INSTR_GET_immediate(self) != 0) {
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_rs(self, dst, immOverride, immOverrideLength));
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_rs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rs(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_rt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rt(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_rd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rd(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_cop0d(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameRspCop0(RAB_INSTR_GET_cop0d(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_cop2t(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameRspCop2(RAB_INSTR_RSP_GET_cop2t(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_cop2cd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameRspCop2Control(RAB_INSTR_RSP_GET_cop2cd(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_vs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_RSP_GET_vs(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_vt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_RSP_GET_vt(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_vd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_RSP_GET_vd(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_vt_elementhigh(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t element;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vt(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
element = RAB_INSTR_RSP_GET_elementhigh(self);
|
|
||||||
if (element != 0) {
|
|
||||||
if ((element & 0x8) == 0x8) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", element & 7);
|
|
||||||
} else if ((element & 0xC) == 0x4) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%ih]", element & (~0xC));
|
|
||||||
} else if ((element & 0xE) == 0x2) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%iq]", element & (~0xE));
|
|
||||||
} else {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_vt_elementlow(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vt(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", RAB_INSTR_RSP_GET_elementlow(self));
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_vd_de(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t de;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vd(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
de = RAB_INSTR_RSP_GET_de(self);
|
|
||||||
if ((de & 0x8) == 0x8) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", de & (~0x8));
|
|
||||||
} else if ((de & 0xC) == 0x4) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%ih]", de & (~0xC));
|
|
||||||
} else if ((de & 0xE) == 0x2) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%iq]", de & (~0xE));
|
|
||||||
} else {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", de);
|
|
||||||
}
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_vs_index(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vs(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", RAB_INSTR_RSP_GET_index(self));
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_offset_rs(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", RabbitizerInstructionRsp_GetOffsetVector(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_rs(self, dst, immOverride, immOverrideLength));
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_rsp_immediate_base(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
// TODO: consider making this a proper configuration
|
|
||||||
#if 0
|
|
||||||
if ((immOverride != NULL) && (immOverrideLength > 0) || RAB_INSTR_GET_immediate(self) != 0) {
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_rs(self, dst, immOverride, immOverrideLength));
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_I(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
|
||||||
UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, "$I");
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_Q(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
|
||||||
UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, "$Q");
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_R(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
|
||||||
UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, "$R");
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_ACC(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
|
||||||
UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, "$ACC");
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_ACCxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_ACC(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_x(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_y(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_z(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_w(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w');
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameR5900VF(RAB_INSTR_R5900_GET_vfs(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vft(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameR5900VF(RAB_INSTR_R5900_GET_vft(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameR5900VF(RAB_INSTR_R5900_GET_vfd(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfsxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_x(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_y(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_z(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_w(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w');
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vftxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_x(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_y(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_z(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_w(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w');
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfdxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_x(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_y(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_z(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z');
|
|
||||||
}
|
|
||||||
if (RAB_INSTR_R5900_GET_xyzw_w(self)) {
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w');
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfsn(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
n = RAB_INSTR_R5900_GET_n(self);
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vftn(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
n = RAB_INSTR_R5900_GET_n(self);
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfdn(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
n = RAB_INSTR_R5900_GET_n(self);
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfsl(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
n = RAB_INSTR_R5900_GET_l(self);
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vftl(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
n = RAB_INSTR_R5900_GET_l(self);
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfdl(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
n = RAB_INSTR_R5900_GET_l(self);
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfsm(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
n = RAB_INSTR_R5900_GET_m(self);
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vftm(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
n = RAB_INSTR_R5900_GET_m(self);
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vfdm(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
uint8_t n;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
n = RAB_INSTR_R5900_GET_m(self);
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vis(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameR5900VI(RAB_INSTR_R5900_GET_vis(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vit(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameR5900VI(RAB_INSTR_R5900_GET_vit(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vid(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
const char *reg = RabbitizerRegister_getNameR5900VI(RAB_INSTR_R5900_GET_vid(self));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vis_predecr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vis(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vit_predecr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vit(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vid_predecr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vid(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vis_postincr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vis(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vit_postincr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vit(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_vid_postincr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vid(self, dst, immOverride, immOverrideLength));
|
|
||||||
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
|
||||||
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
|
||||||
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t RabbitizerOperandType_process_r5900_immediate5(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
|
||||||
size_t totalSize = 0;
|
|
||||||
int32_t number;
|
|
||||||
|
|
||||||
if ((immOverride != NULL) && (immOverrideLength > 0)) {
|
|
||||||
memcpy(dst, immOverride, immOverrideLength);
|
|
||||||
return immOverrideLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
number = RAB_INSTR_R5900_GET_imm5(self);
|
|
||||||
if (RabbitizerConfig_Cfg.misc.omit0XOnSmallImm) {
|
|
||||||
if (number > -10 && number < 10) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", number);
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (number < 0) {
|
|
||||||
if (RabbitizerConfig_Cfg.misc.upperCaseImm) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%X", -number);
|
|
||||||
} else {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%x", -number);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (RabbitizerConfig_Cfg.misc.upperCaseImm) {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", number);
|
|
||||||
} else {
|
|
||||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", number);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return totalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RAB_DEF_OPERAND(prefix, operand) [RAB_OPERAND_##prefix##_##operand] = RabbitizerOperandType_process_##prefix##_##operand,
|
#define RAB_DEF_OPERAND(prefix, operand) [RAB_OPERAND_##prefix##_##operand] = RabbitizerOperandType_process_##prefix##_##operand,
|
||||||
|
|
||||||
|
@ -0,0 +1,231 @@
|
|||||||
|
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
|
||||||
|
/* SPDX-License-Identifier: MIT */
|
||||||
|
|
||||||
|
#include "instructions/RabbitizerInstruction.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "common/Utils.h"
|
||||||
|
#include "common/RabbitizerConfig.h"
|
||||||
|
#include "instructions/RabbitizerRegister.h"
|
||||||
|
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_rs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rs(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_rt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rt(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_rd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rd(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_zero(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
||||||
|
UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameGpr(0);
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_cop0d(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameCop0(RAB_INSTR_GET_cop0d(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_fs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameCop1(RAB_INSTR_GET_fs(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_ft(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameCop1(RAB_INSTR_GET_ft(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_fd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameCop1(RAB_INSTR_GET_fd(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_cop1cs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameCop1Control(RAB_INSTR_GET_cop1cs(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_cop2t(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameCop2(RAB_INSTR_GET_cop2t(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_sa(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
// TODO: consider making this a proper configuration
|
||||||
|
#if 0
|
||||||
|
if (RAB_INSTR_GET_sa(self) < 10) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_sa(self));
|
||||||
|
} else {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", RAB_INSTR_GET_sa(self));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_sa(self));
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_op(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
// TODO: consider making this a proper configuration
|
||||||
|
#if 0
|
||||||
|
if (RAB_INSTR_GET_op(self) < 10) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_op(self));
|
||||||
|
} else {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", RAB_INSTR_GET_op(self));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%02X", RAB_INSTR_GET_op(self));
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_code(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
int code = RAB_INSTR_GET_code_upper(self);
|
||||||
|
int lower = RAB_INSTR_GET_code_lower(self);
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", code);
|
||||||
|
if (lower) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, ", %i", lower);
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_code_lower(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
||||||
|
UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
int code_lower = RAB_INSTR_GET_code_lower(self);
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", code_lower);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_copraw(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", RAB_INSTR_GET_copraw(self));
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_label(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
if ((immOverride != NULL) && (immOverrideLength > 0)) {
|
||||||
|
memcpy(dst, immOverride, immOverrideLength);
|
||||||
|
return immOverrideLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "func_%06X", RabbitizerInstruction_getInstrIndexAsVram(self));
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_immediate(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
int32_t number;
|
||||||
|
|
||||||
|
if ((immOverride != NULL) && (immOverrideLength > 0)) {
|
||||||
|
memcpy(dst, immOverride, immOverrideLength);
|
||||||
|
return immOverrideLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
number = RabbitizerInstruction_getProcessedImmediate(self);
|
||||||
|
if (RabbitizerConfig_Cfg.misc.omit0XOnSmallImm) {
|
||||||
|
if (number > -10 && number < 10) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", number);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (number < 0) {
|
||||||
|
if (RabbitizerConfig_Cfg.misc.upperCaseImm) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%X", -number);
|
||||||
|
} else {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%x", -number);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (RabbitizerConfig_Cfg.misc.upperCaseImm) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", number);
|
||||||
|
} else {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_branch_target_label(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
if ((immOverride != NULL) && (immOverrideLength > 0)) {
|
||||||
|
memcpy(dst, immOverride, immOverrideLength);
|
||||||
|
return immOverrideLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, ". + 4 + (");
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, NULL, 0));
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, " << 2)");
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_cpu_immediate_base(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
// TODO: consider making this a proper configuration
|
||||||
|
#if 0
|
||||||
|
if ((immOverride != NULL) && (immOverrideLength > 0) || RAB_INSTR_GET_immediate(self) != 0) {
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_rs(self, dst, immOverride, immOverrideLength));
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
@ -0,0 +1,413 @@
|
|||||||
|
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
|
||||||
|
/* SPDX-License-Identifier: MIT */
|
||||||
|
|
||||||
|
#include "instructions/RabbitizerInstructionR5900.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "common/Utils.h"
|
||||||
|
#include "common/RabbitizerConfig.h"
|
||||||
|
#include "instructions/RabbitizerRegister.h"
|
||||||
|
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_I(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
||||||
|
UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, "$I");
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_Q(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
||||||
|
UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, "$Q");
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_R(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
||||||
|
UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, "$R");
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_ACC(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride,
|
||||||
|
UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, "$ACC");
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_ACCxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_ACC(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_x(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_y(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_z(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_w(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w');
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameR5900VF(RAB_INSTR_R5900_GET_vfs(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vft(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameR5900VF(RAB_INSTR_R5900_GET_vft(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameR5900VF(RAB_INSTR_R5900_GET_vfd(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfsxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_x(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_y(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_z(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_w(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w');
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vftxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_x(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_y(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_z(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_w(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w');
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfdxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_x(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_y(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_z(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z');
|
||||||
|
}
|
||||||
|
if (RAB_INSTR_R5900_GET_xyzw_w(self)) {
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w');
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfsn(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t n;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
n = RAB_INSTR_R5900_GET_n(self);
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vftn(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t n;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
n = RAB_INSTR_R5900_GET_n(self);
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfdn(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t n;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
n = RAB_INSTR_R5900_GET_n(self);
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfsl(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t n;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
n = RAB_INSTR_R5900_GET_l(self);
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vftl(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t n;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
n = RAB_INSTR_R5900_GET_l(self);
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfdl(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t n;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
n = RAB_INSTR_R5900_GET_l(self);
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfsm(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t n;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
n = RAB_INSTR_R5900_GET_m(self);
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vftm(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t n;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
n = RAB_INSTR_R5900_GET_m(self);
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vfdm(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t n;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
n = RAB_INSTR_R5900_GET_m(self);
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]);
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vis(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameR5900VI(RAB_INSTR_R5900_GET_vis(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vit(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameR5900VI(RAB_INSTR_R5900_GET_vit(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vid(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameR5900VI(RAB_INSTR_R5900_GET_vid(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vis_predecr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vis(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vit_predecr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vit(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vid_predecr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-');
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vid(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vis_postincr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vis(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vit_postincr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vit(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_vid_postincr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vid(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+');
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_r5900_immediate5(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
int32_t number;
|
||||||
|
|
||||||
|
if ((immOverride != NULL) && (immOverrideLength > 0)) {
|
||||||
|
memcpy(dst, immOverride, immOverrideLength);
|
||||||
|
return immOverrideLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
number = RAB_INSTR_R5900_GET_imm5(self);
|
||||||
|
if (RabbitizerConfig_Cfg.misc.omit0XOnSmallImm) {
|
||||||
|
if (number > -10 && number < 10) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", number);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (number < 0) {
|
||||||
|
if (RabbitizerConfig_Cfg.misc.upperCaseImm) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%X", -number);
|
||||||
|
} else {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%x", -number);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (RabbitizerConfig_Cfg.misc.upperCaseImm) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", number);
|
||||||
|
} else {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalSize;
|
||||||
|
}
|
@ -0,0 +1,172 @@
|
|||||||
|
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
|
||||||
|
/* SPDX-License-Identifier: MIT */
|
||||||
|
|
||||||
|
#include "instructions/RabbitizerInstructionRsp.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "common/Utils.h"
|
||||||
|
#include "common/RabbitizerConfig.h"
|
||||||
|
#include "instructions/RabbitizerRegister.h"
|
||||||
|
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_rs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rs(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_rt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rt(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_rd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rd(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_cop0d(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameRspCop0(RAB_INSTR_GET_cop0d(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_cop2t(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameRspCop2(RAB_INSTR_RSP_GET_cop2t(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_cop2cd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameRspCop2Control(RAB_INSTR_RSP_GET_cop2cd(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_vs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_RSP_GET_vs(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_vt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_RSP_GET_vt(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_vd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_RSP_GET_vd(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_vt_elementhigh(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t element;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vt(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
element = RAB_INSTR_RSP_GET_elementhigh(self);
|
||||||
|
if (element != 0) {
|
||||||
|
if ((element & 0x8) == 0x8) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", element & 7);
|
||||||
|
} else if ((element & 0xC) == 0x4) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%ih]", element & (~0xC));
|
||||||
|
} else if ((element & 0xE) == 0x2) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%iq]", element & (~0xE));
|
||||||
|
} else {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_vt_elementlow(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vt(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", RAB_INSTR_RSP_GET_elementlow(self));
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_vd_de(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
uint8_t de;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vd(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
de = RAB_INSTR_RSP_GET_de(self);
|
||||||
|
if ((de & 0x8) == 0x8) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", de & (~0x8));
|
||||||
|
} else if ((de & 0xC) == 0x4) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%ih]", de & (~0xC));
|
||||||
|
} else if ((de & 0xE) == 0x2) {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%iq]", de & (~0xE));
|
||||||
|
} else {
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", de);
|
||||||
|
}
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_vs_index(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vs(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", RAB_INSTR_RSP_GET_index(self));
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_offset_rs(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", RabbitizerInstructionRsp_GetOffsetVector(self));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_rs(self, dst, immOverride, immOverrideLength));
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
||||||
|
return totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t RabbitizerOperandType_process_rsp_immediate_base(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) {
|
||||||
|
size_t totalSize = 0;
|
||||||
|
|
||||||
|
// TODO: consider making this a proper configuration
|
||||||
|
#if 0
|
||||||
|
if ((immOverride != NULL) && (immOverrideLength > 0) || RAB_INSTR_GET_immediate(self) != 0) {
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength));
|
||||||
|
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '(');
|
||||||
|
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_rs(self, dst, immOverride, immOverrideLength));
|
||||||
|
RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')');
|
||||||
|
|
||||||
|
return totalSize;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user