summaryrefslogtreecommitdiff
path: root/x86
diff options
context:
space:
mode:
authorDavid Guillen Fandos2021-04-03 00:37:42 +0200
committerDavid Guillen Fandos2021-04-03 00:37:42 +0200
commit5b5a4db6c2963ba72a3adcace6ec055ac65f2f3d (patch)
treedb7cd4db7d0c146a382e997f9f704a1983446e28 /x86
parent8c14ac96192f6d966ac0ad252003a8dd3c61667a (diff)
downloadpicogpsp-5b5a4db6c2963ba72a3adcace6ec055ac65f2f3d.tar.gz
picogpsp-5b5a4db6c2963ba72a3adcace6ec055ac65f2f3d.tar.bz2
picogpsp-5b5a4db6c2963ba72a3adcace6ec055ac65f2f3d.zip
Add instruction tracing, for testing purposes
Diffstat (limited to 'x86')
-rw-r--r--x86/x86_emit.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/x86/x86_emit.h b/x86/x86_emit.h
index 68930e1..ef79110 100644
--- a/x86/x86_emit.h
+++ b/x86/x86_emit.h
@@ -96,6 +96,7 @@ typedef enum
x86_opcode_push_reg = 0x50,
x86_opcode_push_rm = 0xFF,
x86_opcode_push_imm = 0x0668,
+ x86_opcode_pop_reg = 0x58,
x86_opcode_call_offset = 0xE8,
x86_opcode_ret = 0xC3,
x86_opcode_test_rm_imm = 0x00F7,
@@ -266,6 +267,12 @@ typedef enum
#define x86_emit_idiv_eax_reg(source) \
x86_emit_opcode_1b_ext_reg(idiv_eax_rm, source) \
+#define x86_emit_pop_reg(regn) \
+ x86_emit_opcode_1b(pop_reg, regn) \
+
+#define x86_emit_push_reg(regn) \
+ x86_emit_opcode_1b(push_reg, regn) \
+
#define x86_emit_push_mem(base, offset) \
x86_emit_opcode_1b_mem(push_rm, 0x06, base, offset) \
@@ -523,6 +530,28 @@ typedef enum
generate_function_call(execute_##name##_##flags_op##_reg); \
generate_mov(ireg, rv) \
+#ifdef TRACE_INSTRUCTIONS
+ void function_cc trace_instruction(u32 pc)
+ {
+ printf("Executed %x\n", pc);
+ }
+
+ #define emit_trace_thumb_instruction(pc) \
+ x86_emit_push_reg(eax); \
+ x86_emit_push_reg(ecx); \
+ x86_emit_push_reg(edx); \
+ x86_emit_mov_reg_imm(eax, pc); \
+ generate_function_call(trace_instruction); \
+ x86_emit_pop_reg(edx); \
+ x86_emit_pop_reg(ecx); \
+ x86_emit_pop_reg(eax);
+ #define emit_trace_arm_instruction(pc) \
+ emit_trace_thumb_instruction(pc)
+#else
+ #define emit_trace_thumb_instruction(pc)
+ #define emit_trace_arm_instruction(pc)
+#endif
+
u32 function_cc execute_lsl_no_flags_reg(u32 value, u32 shift)
{
if(shift != 0)