i'll have to rethink the branches and jumps

This commit is contained in:
irisz64
2025-07-06 20:31:42 +02:00
parent 451ff7c4aa
commit 46c2aa2994
3 changed files with 22 additions and 22 deletions

View File

@@ -82,7 +82,7 @@ int JIT::Step() {
code.push(code.rbp);
code.mov(code.rbp, reinterpret_cast<uintptr_t>(this)); // Load context pointer
cs_insn *insn;
//cs_insn *insn;
Util::trace("\tMIPS code (guest PC = 0x{:016X}):", blockPC);
while (!instrInDelaySlot) {
// CheckCompareInterrupt();
@@ -106,7 +106,7 @@ int JIT::Step() {
const u32 instruction = mem.Read<u32>(regs, paddr);
u32 bswapped = bswap(instruction);
/*u32 bswapped = bswap(instruction);
auto count = cs_disasm(disassemblerMips, reinterpret_cast<const u8 *>(&bswapped), 4, blockPC, 0, &insn);
if (count > 0) {
@@ -116,7 +116,7 @@ int JIT::Step() {
Util::trace("\t\tCould not disassemble 0x{:08X} due to error {}\n", instruction, (int)cs_errno(disassemblerMips));
}
/*if(ShouldServiceInterrupt()) {
if(ShouldServiceInterrupt()) {
regs.cop0.FireException(ExceptionCode::Interrupt, 0, blockPC);
return 1;
}*/
@@ -150,23 +150,24 @@ int JIT::Step() {
code.mov(code.rax, blockPC);
code.mov(REG(qword, pc), code.rax);
}
code.mov(code.rax, instructionsInBlock);
code.pop(code.rbp);
code.add(code.rsp, 8);
code.ret();
code.setProtectModeRE();
static auto blockInfoSize = 0;
blockInfoSize = code.getSize() - blockInfoSize;
//static auto blockInfoSize = 0;
//blockInfoSize = code.getSize() - blockInfoSize;
Util::trace("\tX86 code (block address = 0x{:016X}):", (uintptr_t)block);
auto count = cs_disasm(disassemblerX86, blockInfo, blockInfoSize, (uintptr_t)block, 0, &insn);
if (count > 0) {
for (size_t j = 0; j < count; j++) {
Util::trace("\t\t0x{:016X}:\t{}\t\t{}\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
}
cs_free(insn, count);
}
//Util::trace("\tX86 code (block address = 0x{:016X}):", (uintptr_t)block);
//auto count = cs_disasm(disassemblerX86, blockInfo, blockInfoSize, (uintptr_t)block, 0, &insn);
//if (count > 0) {
// for (size_t j = 0; j < count; j++) {
// Util::trace("\t\t0x{:016X}:\t{}\t\t{}\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
// }
//
// cs_free(insn, count);
//}
// const auto dump = code.getCode();
// Util::WriteFileBinary(dump, code.getSize(), "jit.dump");
// Util::panic("");