--- a/src/in_2sf/desmume/arm_jit.cpp
+++ b/src/in_2sf/desmume/arm_jit.cpp
@@ -50,9 +50,28 @@
#if LOG_JIT_LEVEL > 0
#define LOG_JIT 1
#define JIT_COMMENT(...) c.comment(__VA_ARGS__)
+#define printJIT(buf, val) \
+{ \
+ JIT_COMMENT("printJIT(\""##buf"\", val);"); \
+ GpVar txt = c.newGpVar(kX86VarTypeGpz); \
+ GpVar data = c.newGpVar(kX86VarTypeGpz); \
+ GpVar io = c.newGpVar(kX86VarTypeGpd); \
+ c.lea(io, dword_ptr_abs(stdout)); \
+ c.lea(txt, dword_ptr_abs(&buf)); \
+ c.mov(data, *reinterpret_cast<GpVar *>(&val)); \
+ X86CompilerFuncCall* prn = c.call(reinterpret_cast<uintptr_t>(fprintf)); \
+ prn->setPrototype(ASMJIT_CALL_CONV, FuncBuilder3<void, void *, void *, uint32_t>()); \
+ prn->setArgument(0, io); \
+ prn->setArgument(1, txt); \
+ prn->setArgument(2, data); \
+ X86CompilerFuncCall *prn_flush = c.call(reinterpret_cast<uintptr_t>(fflush)); \
+ prn_flush->setPrototype(ASMJIT_CALL_CONV, FuncBuilder1<void, void *>()); \
+ prn_flush->setArgument(0, io); \
+}
#else
#define LOG_JIT 0
#define JIT_COMMENT(...)
+#define printJIT(buf, val)
#endif
#ifdef MAPPED_JIT_FUNCS
@@ -1392,6 +1411,7 @@
#define OP_MSR_(reg, args, sw) \
GpVar operand = c.newGpVar(kX86VarTypeGpd); \
args; \
+ c.mov(operand, rhs); \
switch ((i >> 16) & 0xF) \
{ \
case 0x1: /* bit 16 */ \
@@ -1411,7 +1431,6 @@
ctx->setArgument(0, bb_cpu); \
ctx->setArgument(1, mode); \
} \
- c.mov(operand, rhs); \
Mem xPSR_memB = cpu_ptr_byte(reg, 0); \
c.mov(xPSR_memB, operand.r8Lo()); \
changeCPSR; \
@@ -1426,7 +1445,6 @@
c.and_(mode, 0x1F); \
c.cmp(mode, USR); \
c.je(__skip); \
- c.mov(operand, rhs); \
Mem xPSR_memB = cpu_ptr_byte(reg, 1); \
c.shr(operand, 8); \
c.mov(xPSR_memB, operand.r8Lo()); \
@@ -1442,7 +1460,6 @@
c.and_(mode, 0x1F); \
c.cmp(mode, USR); \
c.je(__skip); \
- c.mov(operand, rhs); \
Mem xPSR_memB = cpu_ptr_byte(reg, 2); \
c.shr(operand, 16); \
c.mov(xPSR_memB, operand.r8Lo()); \
@@ -1452,7 +1469,6 @@
} \
case 0x8: /* bit 19 */ \
{ \
- c.mov(operand, rhs); \
Mem xPSR_memB = cpu_ptr_byte(reg, 3); \
c.shr(operand, 24); \
c.mov(xPSR_memB, operand.r8Lo()); \
@@ -1485,7 +1501,6 @@
ctx->setArgument(1, mode); \
} \
/* cpu->CPSR.val = (cpu->CPSR.val & ~byte_mask) | (operand & byte_mask); */ \
- c.mov(operand, rhs); \
c.mov(xPSR, xPSR_mem); \
c.and_(operand, byte_mask); \
c.and_(xPSR, ~byte_mask); \
@@ -1494,7 +1509,6 @@
c.jmp(__done); \
/* mode == USR */ \
c.bind(__USR); \
- c.mov(operand, rhs); \
c.mov(xPSR, xPSR_mem); \
c.and_(operand, byte_mask_USR); \
c.and_(xPSR, ~byte_mask_USR); \
@@ -4199,10 +4213,10 @@
scratchptr = scratchpad;
#endif
printf("CPU mode: %s\n", enable ? "JIT" : "Interpreter");
- printf("JIT max block size %d instruction(s)\n", CommonSettings.jit_max_block_size);
if (enable)
{
+ printf("JIT max block size %d instruction(s)\n", CommonSettings.jit_max_block_size);
#ifdef MAPPED_JIT_FUNCS
// these pointers are allocated by asmjit and need freeing
#define JITFREE(x) for (size_t iii = 0; iii < ARRAY_SIZE((x)); ++iii) if ((x)[iii]) AsmJit::MemoryManager::getGlobal()->free(reinterpret_cast<void *>((x)[iii])); memset((x), 0, sizeof((x)));