src/musashi/m68kcpu.h

branch
experimental_memory_mapper_v2
changeset 128
3246b74d96bc
parent 110
acea4b2f396f
     1.1 --- a/src/musashi/m68kcpu.h	Wed Jan 16 00:41:51 2013 +0000
     1.2 +++ b/src/musashi/m68kcpu.h	Fri Jan 18 17:03:48 2013 +0000
     1.3 @@ -1,4 +1,5 @@
     1.4  #include <stdio.h>
     1.5 +#include <ctype.h>
     1.6  /* ======================================================================== */
     1.7  /* ========================= LICENSING & COPYRIGHT ======================== */
     1.8  /* ======================================================================== */
     1.9 @@ -1652,6 +1653,41 @@
    1.10  INLINE void m68ki_exception_trapN(uint vector)
    1.11  {
    1.12  	uint sr = m68ki_init_exception();
    1.13 +
    1.14 +#ifdef MC68K_TRAP_SYSCALLS
    1.15 +	if (vector == 32) {
    1.16 +		printf(">>> TRAP #0 = SYSCALL #%d%s\n", REG_D[0] & 63, REG_D[0] > 63 ? "!!!" : "");
    1.17 +		// d0 = syscall number
    1.18 +		printf("\t d0:%08X    d1:%08X    d2:%08X    d3:%08X\n", REG_D[0], REG_D[1], REG_D[2], REG_D[3]);
    1.19 +		printf("\t d4:%08X    d5:%08X    d6:%08X    d7:%08X\n", REG_D[4], REG_D[5], REG_D[6], REG_D[7]);
    1.20 +		printf("\t a0:%08X    a1:%08X    a2:%08X    a3:%08X\n", REG_A[0], REG_A[1], REG_A[2], REG_A[3]);
    1.21 +		printf("\t a4:%08X    a5:%08X    a6:%08X    sp:%08X\n", REG_A[4], REG_A[5], REG_A[6], REG_USP);
    1.22 +		printf("\t pc:%08X    sr:%08X\n", REG_PC, sr);
    1.23 +
    1.24 +		/*
    1.25 +		// dump stack -- but syscalls use registers to pass parameters
    1.26 +		for (int i=-128; i<128; i+=4) {
    1.27 +			printf("  sp%s%02d: %08X\n", i<0?"":"+", i, m68k_read_disassembler_32(REG_SP+i));
    1.28 +		}
    1.29 +		*/
    1.30 +		for (int r=0; r<2; r++) {
    1.31 +			printf("  *a%d: [", r);
    1.32 +			if (REG_A[r] == 0x00) {
    1.33 +				printf("NullPointer]\n");
    1.34 +				continue;
    1.35 +			}
    1.36 +			for (int i=0; i<32; i++) {
    1.37 +				unsigned char c = m68k_read_disassembler_8(REG_A[r]+i);
    1.38 +				if (isprint(c))
    1.39 +					putchar(c);
    1.40 +				else
    1.41 +					putchar('.');
    1.42 +			}
    1.43 +			printf("]\n");
    1.44 +		}
    1.45 +	}
    1.46 +#endif // MC68K_TRAP_SYSCALLS
    1.47 +
    1.48  	m68ki_stack_frame_0000(REG_PC, sr, vector);
    1.49  	m68ki_jump_vector(vector);
    1.50