--- M6502/perl.c 2007/07/30 14:23:22 26 +++ M6502/perl.c 2007/07/30 15:45:03 27 @@ -33,10 +33,43 @@ byte Value; Value = 0x42; printf("Rd6502(%04x,%02x)\n", Addr, Value); + + int count; + dSP; + ENTER; + SAVETMPS; + PUSHMARK(SP); + XPUSHs( sv_2mortal( newSViv( Value ) ) ); + PUTBACK; + count = call_pv("M6502::read", G_ARRAY ); + if ( count != 1 ) { + printf("expect 1 return value, got %d", count); + exit(1); + } + printf("got %d values\n", count); + SPAGAIN; + SV *sv; + sv = POPs; + Value = SvIV(sv); +// Value = savepv(SvPV_nolen(POPs)); + FREETMPS; + LEAVE; + printf("Rd6502(%04x) = %02x\n", Addr, Value); + return Value; } void Wr6502(register word Addr,register byte Value) { printf("Wr6502(%04x,%02x)\n", Addr, Value); + dSP; + ENTER; + SAVETMPS; + PUSHMARK(SP); + XPUSHs( sv_2mortal( newSViv( Addr ) ) ); + XPUSHs( sv_2mortal( newSViv( Value ) ) ); + PUTBACK; + call_pv("M6502::write", G_DISCARD ); + FREETMPS; + LEAVE; } byte Op6502(register word Addr) {