--- M6502/perl.c 2007/07/30 22:06:13 36 +++ M6502/perl.c 2007/07/30 23:28:25 38 @@ -21,20 +21,38 @@ #define dump_R #endif -void update_R(M6502 *R) { +void pull_R(M6502 *R) { R->A = SvIV( get_sv("M6502::A", 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) ) ); - R->PC.W = atoi( SvPV_nolen( get_sv("M6502::PC", FALSE) ) ); - R->IPeriod = atoi( SvPV_nolen( get_sv("M6502::IPeriod", FALSE) ) ); + R->X = SvIV( get_sv("M6502::X", FALSE) ); + R->Y = SvIV( get_sv("M6502::Y", FALSE) ); + R->S = SvIV( get_sv("M6502::S", FALSE) ); + R->PC.W = SvIV( get_sv("M6502::PC", FALSE) ); + R->IPeriod = SvIV( get_sv("M6502::IPeriod", FALSE) ); // ICount IRequest IAutoReset TrapBadOps Trap Trace - printf("update_r finished\n"); + printf("pull_R finished\n"); dump_R; } +void push_R(M6502 *R) { + dSP; + ENTER; + SAVETMPS; + PUSHMARK(SP); + XPUSHs( sv_2mortal( newSViv( R->A ) ) ); + XPUSHs( sv_2mortal( newSViv( R->P ) ) ); + XPUSHs( sv_2mortal( newSViv( R->X ) ) ); + XPUSHs( sv_2mortal( newSViv( R->Y ) ) ); + XPUSHs( sv_2mortal( newSViv( R->S ) ) ); + XPUSHs( sv_2mortal( newSViv( R->PC.W ) ) ); + PUTBACK; + call_pv("M6502::_push_R", G_DISCARD ); + printf("push_R called\n"); + dump_R; + FREETMPS; + LEAVE; +} + /** Rd6502()/Wr6502/Op6502() *********************************/ /** These functions are called when access to RAM occurs. **/ /** They allow to control memory access. Op6502 is the same **/ @@ -153,9 +171,13 @@ PUSHMARK(SP); call_pv("Arch::init", G_DISCARD | G_NOARGS ); - update_R(R); + pull_R(R); printf("run CPU\n"); - Run6502(R); + dump_R; + //Run6502(R); + Exec6502(R, 10); + dump_R; + push_R(R); printf("end of CPU run\n"); } free(R);