00cc9309cb
de6e324bdseparate emu thread10d3daf86Roms List improvements95d202f37Let's make the rom list process on a separate thread so the emulator doesnt take ages to load.fc306967fWow the ROM Header was just completely busted. Game list view works nowbad1691eefuck this shit2b59e5f46game list in progressd26417b83remappable inputs in progressac4af8106inpute72abc240update readme430139dc9Qt6 frontend3080d4d45Fix this small bug too08cd13b85Cop0 unused functions do not actually pose a threat (as per manual). They don't do anything, so shall we.61bb4fb44make idle loop detection a little more specific with where the load goesb037de4c3SAZDFsdff12e81e73eneed to figure out why n64-systemtest loops indefinitely at some address that appears to be valid (i think it's me not invalidating the cache properly)204f0e13bidle skipping seems to work!cb8bb634asdkfjlasdf58e5c89c1Fix compilation issue on my machine (no idea)24fb2898eattempting more serious idle skipping214719577Place rsp.Step inside cached interpreter. Gains about 3 more fpsbb97dcc23mmmmm920b77d38wjkhasdfjhkasdf430ccdab4it's a start...4f42a673aCached interpreter plays Mario 64. Start looking into RSP as wellc9a030787idle skipping works!5fbda03cenew idea366637abaIdle skipping... maybe?609fa2fb0Cache instructions implemented but broken lmao. Commented out for nowe140a6d12- Stop using inheritance for CPU, instead use composition. - Introduce KAIZEN_JIT_ENABLED optional define instead of relying on __aarch64__ and the like. - More cache work68e613057prep cache impl811b4d809fix clang formatfda755f7didkd5024ebbfsmall MI refactor in preparation of (eventually) implementing the RDRAM interface properly694b45341Merge commit '206dcdedf195fb320913584180edb12c7731e396' as 'external/SDL'206dcdedfSquashed 'external/SDL/' content from commit 4d17b99d0a4d16e1cb4need to update sdl848b19920Fix compilation errordb61b5299Merge commit 'e94a94559f28e49678fbcf72199a5258137b0fe9' as 'external/imgui'e94a94559Squashed 'external/imgui/' content from commit 02e9b8cac52edb3757need to update imguic1a705e86Emulate weird JALR behaviour4b4c32f4bFix exception for "unusable COP1" in 4 instructions i missed accidentally (again)df5828142Bug putting 0s in the log everywheref8b580048Make isviewer a sink to file8241e9735Fix exception for "unusable COP1" in 4 instructions i missed accidentallyb29715f20small changesd9a620bc1make use of my new small utility library0d1aa938eAdd 'external/ircolib/' from commit 'ce3cd726c8df8388d554abf8bb55d55020eb4450'e64eb40b3Fuck git git-subtree-dir: external/ircolib git-subtree-split:de6e324bde
248 lines
7.8 KiB
C
248 lines
7.8 KiB
C
//===-- XCoreInstPrinter.cpp - Convert XCore MCInst to assembly syntax --------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This class prints an XCore MCInst to a .s file.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/* Capstone Disassembly Engine */
|
|
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2015 */
|
|
|
|
#ifdef CAPSTONE_HAS_XCORE
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <capstone/platform.h>
|
|
|
|
#include "XCoreInstPrinter.h"
|
|
#include "../../MCInst.h"
|
|
#include "../../utils.h"
|
|
#include "../../SStream.h"
|
|
#include "../../MCRegisterInfo.h"
|
|
#include "../../MathExtras.h"
|
|
#include "XCoreMapping.h"
|
|
|
|
static const char *getRegisterName(unsigned RegNo);
|
|
|
|
void XCore_post_printer(csh ud, cs_insn *insn, SStream *insn_asm, MCInst *mci)
|
|
{
|
|
/*
|
|
if (((cs_struct *)ud)->detail != CS_OPT_ON)
|
|
return;
|
|
*/
|
|
}
|
|
|
|
// stw sed, sp[3]
|
|
void XCore_insn_extract(MCInst *MI, const char *code)
|
|
{
|
|
int id;
|
|
char *p, *p2;
|
|
char tmp[128];
|
|
|
|
strncpy(tmp, code, sizeof(tmp) - 1); // safe because code is way shorter than 128 bytes
|
|
|
|
// find the first space
|
|
p = strchr(tmp, ' ');
|
|
if (p) {
|
|
p++;
|
|
// find the next ','
|
|
p2 = strchr(p, ',');
|
|
if (p2) {
|
|
*p2 = '\0';
|
|
id = XCore_reg_id(p);
|
|
if (id) {
|
|
// register
|
|
if (MI->csh->detail_opt) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].type = XCORE_OP_REG;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].reg = id;
|
|
MI->flat_insn->detail->xcore.op_count++;
|
|
}
|
|
}
|
|
// next should be register, or memory?
|
|
// skip space
|
|
p2++;
|
|
while(*p2 && *p2 == ' ')
|
|
p2++;
|
|
if (*p2) {
|
|
// find '['
|
|
p = p2;
|
|
while(*p && *p != '[')
|
|
p++;
|
|
if (*p) {
|
|
// this is '['
|
|
*p = '\0';
|
|
id = XCore_reg_id(p2);
|
|
if (id) {
|
|
// base register
|
|
if (MI->csh->detail_opt) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].type = XCORE_OP_MEM;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.base = (uint8_t)id;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.index = XCORE_REG_INVALID;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.disp = 0;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.direct = 1;
|
|
}
|
|
|
|
p++;
|
|
p2 = p;
|
|
// until ']'
|
|
while(*p && *p != ']')
|
|
p++;
|
|
if (*p) {
|
|
*p = '\0';
|
|
// p2 is either index, or disp
|
|
id = XCore_reg_id(p2);
|
|
if (id) {
|
|
// index register
|
|
if (MI->csh->detail_opt) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.index = (uint8_t)id;
|
|
}
|
|
} else {
|
|
// a number means disp
|
|
if (MI->csh->detail_opt) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.disp = atoi(p2);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (MI->csh->detail_opt) {
|
|
MI->flat_insn->detail->xcore.op_count++;
|
|
}
|
|
}
|
|
} else {
|
|
// a register?
|
|
id = XCore_reg_id(p2);
|
|
if (id) {
|
|
// register
|
|
if (MI->csh->detail_opt) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].type = XCORE_OP_REG;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].reg = id;
|
|
MI->flat_insn->detail->xcore.op_count++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
id = XCore_reg_id(p);
|
|
if (id) {
|
|
// register
|
|
if (MI->csh->detail_opt) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].type = XCORE_OP_REG;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].reg = id;
|
|
MI->flat_insn->detail->xcore.op_count++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static void set_mem_access(MCInst *MI, bool status, int reg)
|
|
{
|
|
if (MI->csh->detail_opt != CS_OPT_ON)
|
|
return;
|
|
|
|
MI->csh->doing_mem = status;
|
|
if (status) {
|
|
if (reg != 0xffff && reg != -0xffff) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].type = XCORE_OP_MEM;
|
|
if (reg) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.base = (uint8_t)reg;
|
|
} else {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.base = XCORE_REG_INVALID;
|
|
}
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.index = XCORE_REG_INVALID;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.disp = 0;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.direct = 1;
|
|
} else {
|
|
// the last op should be the memory base
|
|
MI->flat_insn->detail->xcore.op_count--;
|
|
uint8_t base = MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].reg;
|
|
memset(&MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count], 0, sizeof(cs_xcore_op));
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].type = XCORE_OP_MEM;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.base = base;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.index = XCORE_REG_INVALID;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.disp = 0;
|
|
if (reg > 0)
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.direct = 1;
|
|
else
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.direct = -1;
|
|
}
|
|
} else {
|
|
if (reg) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.index = (uint8_t)reg;
|
|
// done, create the next operand slot
|
|
MI->flat_insn->detail->xcore.op_count++;
|
|
}
|
|
}
|
|
}
|
|
|
|
static void _printOperand(MCInst *MI, MCOperand *MO, SStream *O)
|
|
{
|
|
if (MCOperand_isReg(MO)) {
|
|
unsigned reg;
|
|
|
|
reg = MCOperand_getReg(MO);
|
|
SStream_concat0(O, getRegisterName(reg));
|
|
|
|
if (MI->csh->detail_opt) {
|
|
if (MI->csh->doing_mem) {
|
|
if (MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.base == ARM_REG_INVALID)
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.base = (uint8_t)reg;
|
|
else
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.index = (uint8_t)reg;
|
|
} else {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].type = XCORE_OP_REG;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].reg = reg;
|
|
MI->flat_insn->detail->xcore.op_count++;
|
|
}
|
|
}
|
|
} else if (MCOperand_isImm(MO)) {
|
|
int32_t Imm = (int32_t)MCOperand_getImm(MO);
|
|
|
|
printInt32(O, Imm);
|
|
|
|
if (MI->csh->detail_opt) {
|
|
if (MI->csh->doing_mem) {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].mem.disp = Imm;
|
|
} else {
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].type = XCORE_OP_IMM;
|
|
MI->flat_insn->detail->xcore.operands[MI->flat_insn->detail->xcore.op_count].imm = Imm;
|
|
MI->flat_insn->detail->xcore.op_count++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static void printOperand(MCInst *MI, int OpNum, SStream *O)
|
|
{
|
|
if (OpNum >= MI->size)
|
|
return;
|
|
|
|
_printOperand(MI, MCInst_getOperand(MI, OpNum), O);
|
|
}
|
|
|
|
static void printInlineJT(MCInst *MI, int OpNum, SStream *O)
|
|
{
|
|
}
|
|
|
|
static void printInlineJT32(MCInst *MI, int OpNum, SStream *O)
|
|
{
|
|
}
|
|
|
|
#define PRINT_ALIAS_INSTR
|
|
#include "XCoreGenAsmWriter.inc"
|
|
|
|
void XCore_printInst(MCInst *MI, SStream *O, void *Info)
|
|
{
|
|
printInstruction(MI, O, Info);
|
|
set_mem_access(MI, false, 0);
|
|
}
|
|
|
|
#endif
|