switch to capstone on master
This commit is contained in:
1
.gitmodules
vendored
1
.gitmodules
vendored
@@ -1,7 +1,6 @@
|
||||
[submodule "external/capstone"]
|
||||
path = external/capstone
|
||||
url = https://github.com/capstone-engine/capstone/
|
||||
branch = next
|
||||
[submodule "external/nativefiledialog-extended"]
|
||||
path = external/nativefiledialog-extended
|
||||
url = https://github.com/btzy/nativefiledialog-extended/
|
||||
|
||||
2
external/capstone
vendored
2
external/capstone
vendored
Submodule external/capstone updated: 0d0e684358...fee83fcc1a
2
external/nativefiledialog-extended
vendored
2
external/nativefiledialog-extended
vendored
Submodule external/nativefiledialog-extended updated: 3311592818...31df8e30cc
@@ -88,6 +88,27 @@ inline void HandleInterrupt(Registers& regs) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void Cpu::disassembly(u32 instr) const {
|
||||
size_t count;
|
||||
cs_insn *insn;
|
||||
|
||||
u8 code[4];
|
||||
//u32 temp = bswap_32(instr);
|
||||
memcpy(code, &instr, 4);
|
||||
|
||||
count = cs_disasm(handle, code, 4, regs.pc, 0, &insn);
|
||||
|
||||
if (count > 0) {
|
||||
size_t j;
|
||||
for (j = 0; j < count; j++) {
|
||||
fmt::print("0x{:016X}:\t{}\t\t{}\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
|
||||
}
|
||||
|
||||
cs_free(insn, count);
|
||||
} else
|
||||
printf("ERROR: Failed to disassemble given code!\n");
|
||||
}
|
||||
|
||||
void Cpu::Step(Mem& mem) {
|
||||
regs.gpr[0] = 0;
|
||||
|
||||
@@ -96,6 +117,8 @@ void Cpu::Step(Mem& mem) {
|
||||
|
||||
u32 instruction = mem.Read32(regs, regs.pc, regs.pc);
|
||||
|
||||
disassembly(instruction);
|
||||
|
||||
regs.oldPC = regs.pc;
|
||||
regs.pc = regs.nextPC;
|
||||
regs.nextPC += 4;
|
||||
|
||||
@@ -7,23 +7,21 @@
|
||||
namespace n64 {
|
||||
struct Cpu {
|
||||
Cpu() {
|
||||
//log = fopen("disasm.txt", "w");
|
||||
//if(cs_open(CS_ARCH_MIPS, CS_MODE_MIPS64, &handle) != CS_ERR_OK) {
|
||||
// util::panic("Could not initialize capstone!\n");
|
||||
//}
|
||||
if(cs_open(CS_ARCH_MIPS, CS_MODE_MIPS64, &handle) != CS_ERR_OK) {
|
||||
util::panic("Could not initialize capstone!\n");
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
~Cpu() {
|
||||
//fclose(log);
|
||||
//cs_close(&handle);
|
||||
cs_close(&handle);
|
||||
}
|
||||
void Reset();
|
||||
void Step(Mem&);
|
||||
Registers regs;
|
||||
private:
|
||||
csh handle;
|
||||
FILE* log;
|
||||
void disassembly(u32 instr) const;
|
||||
friend struct Cop1;
|
||||
|
||||
void special(Mem&, u32);
|
||||
|
||||
Reference in New Issue
Block a user