--- M6502/perl.c 2007/07/30 21:00:36 33 +++ M6502/perl.c 2007/07/30 21:34:30 34 @@ -3,7 +3,7 @@ #include "M6502.h" #include "config.h" -#ifdef DEBUGF +#if DEBUGF #define debugf(x) do { \ PerlIO_stdoutf x ; \ } while (0) @@ -15,17 +15,16 @@ static M6502 *R; -#if 0 +#if DUMP_R #define dump_R printf("# PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", R->PC.W, R->A, R->P, R->X, R->Y, R->S ); #else #define dump_R #endif void update_R(M6502 *R) { - printf("--0\n"); R->A = SvIV( get_sv("M6502::A", FALSE) ); - printf("--1\n"); - R->P = atoi( SvPV_nolen( get_sv("M6502::P", FALSE) ) ); + printf("--%d", get_sv("M6502::A", FALSE) ); + R->P = SvIV( get_sv("M6502::P", FALSE) ); R->X = atoi( SvPV_nolen( get_sv("M6502::X", FALSE) ) ); R->Y = atoi( SvPV_nolen( get_sv("M6502::Y", FALSE) ) ); R->S = atoi( SvPV_nolen( get_sv("M6502::S", FALSE) ) ); @@ -64,13 +63,14 @@ byte = SvIV(sv); FREETMPS; LEAVE; - debugf(("Rd6502(%04x) = %02x\n", Addr, byte)); + //debugf(("mem(%04x) = %02x\n", Addr, byte)); return byte; } byte Rd6502(register word Addr) { byte Value; Value = mem(Addr); + debugf(("Rd6502(%04x) = %02x\n", Addr, Value)); return Value; } @@ -145,8 +145,6 @@ exit(1); } - update_R(R); - printf("reset CPU\n"); Reset6502(R); @@ -155,6 +153,7 @@ PUSHMARK(SP); call_pv("Arch::init", G_DISCARD | G_NOARGS ); + update_R(R); printf("run CPU\n"); Run6502(R);