diff options
author | David Guillen Fandos | 2021-04-03 00:37:42 +0200 |
---|---|---|
committer | David Guillen Fandos | 2021-04-03 00:37:42 +0200 |
commit | 5b5a4db6c2963ba72a3adcace6ec055ac65f2f3d (patch) | |
tree | db7cd4db7d0c146a382e997f9f704a1983446e28 /arm | |
parent | 8c14ac96192f6d966ac0ad252003a8dd3c61667a (diff) | |
download | picogpsp-5b5a4db6c2963ba72a3adcace6ec055ac65f2f3d.tar.gz picogpsp-5b5a4db6c2963ba72a3adcace6ec055ac65f2f3d.tar.bz2 picogpsp-5b5a4db6c2963ba72a3adcace6ec055ac65f2f3d.zip |
Add instruction tracing, for testing purposes
Diffstat (limited to 'arm')
-rw-r--r-- | arm/arm_emit.h | 24 | ||||
-rw-r--r-- | arm/arm_stub.S | 23 |
2 files changed, 43 insertions, 4 deletions
diff --git a/arm/arm_emit.h b/arm/arm_emit.h index a5dc930..a6951c2 100644 --- a/arm/arm_emit.h +++ b/arm/arm_emit.h @@ -1227,6 +1227,30 @@ u32 execute_store_cpsr_body(u32 _cpsr, u32 store_mask, u32 address) return 0; } +#ifdef TRACE_INSTRUCTIONS + void trace_instruction(u32 pc) + { + printf("Executed %x\n", pc); + } + + #define emit_trace_instruction(pc) \ + generate_save_flags(); \ + ARM_LDR_IMM(0, ARMREG_SP, reg_base, 34*4); \ + ARM_STMDB_WB(0, ARMREG_SP, 0x500C); \ + arm_load_imm_32bit(reg_a0, pc); \ + generate_function_call(trace_instruction); \ + ARM_LDMIA_WB(0, ARMREG_SP, 0x500C); \ + arm_load_imm_32bit(ARMREG_SP, (u32)reg); \ + generate_restore_flags(); + #define emit_trace_thumb_instruction(pc) \ + emit_trace_instruction(pc) + #define emit_trace_arm_instruction(pc) \ + emit_trace_instruction(pc) +#else + #define emit_trace_thumb_instruction(pc) + #define emit_trace_arm_instruction(pc) +#endif + #define arm_psr_load_new_reg() \ generate_load_reg(reg_a0, rm) \ diff --git a/arm/arm_stub.S b/arm/arm_stub.S index 9779aa5..b8651cf 100644 --- a/arm/arm_stub.S +++ b/arm/arm_stub.S @@ -168,10 +168,25 @@ defsymbl(arm_indirect_branch_##mode) ;\ execute_pc_##mode: ;\ bic r0, r0, #(align) /* Align PC */;\ mov r1, r0, lsr #24 /* Get region */;\ - cmp r1, #2 ;\ - beq 1f /* ewram */;\ - cmp r1, #3 ;\ - beq 2f /* iwram */;\ + ldr pc, [pc, r1, lsl #2] ;\ + nop ;\ + .long 3f /* 0 BIOS (like ROM) */;\ + .long 3f /* 1 Bad region */;\ + .long 1f /* 2 EWRAM */;\ + .long 2f /* 3 IWRAM */;\ + .long 3f /* 4 Not supported */;\ + .long 3f /* 5 Not supported */;\ + .long 3f /* 6 Not supported */;\ + .long 3f /* 7 Not supported */;\ + .long 3f /* 8 ROM */;\ + .long 3f /* 9 ROM */;\ + .long 3f /* A ROM */;\ + .long 3f /* B ROM */;\ + .long 3f /* C ROM */;\ + .long 3f /* D ROM */;\ + .long 3f /* E ROM */;\ + .long 3f /* F Bad region */;\ + ;\ 3: ;\ call_c_function(block_lookup_address_##mode) ;\ restore_flags() ;\ |