33 |
byte Value; |
byte Value; |
34 |
Value = 0x42; |
Value = 0x42; |
35 |
printf("Rd6502(%04x,%02x)\n", Addr, Value); |
printf("Rd6502(%04x,%02x)\n", Addr, Value); |
36 |
|
|
37 |
|
int count; |
38 |
|
dSP; |
39 |
|
ENTER; |
40 |
|
SAVETMPS; |
41 |
|
PUSHMARK(SP); |
42 |
|
XPUSHs( sv_2mortal( newSViv( Value ) ) ); |
43 |
|
PUTBACK; |
44 |
|
count = call_pv("M6502::read", G_ARRAY ); |
45 |
|
if ( count != 1 ) { |
46 |
|
printf("expect 1 return value, got %d", count); |
47 |
|
exit(1); |
48 |
|
} |
49 |
|
printf("got %d values\n", count); |
50 |
|
SPAGAIN; |
51 |
|
SV *sv; |
52 |
|
sv = POPs; |
53 |
|
Value = SvIV(sv); |
54 |
|
// Value = savepv(SvPV_nolen(POPs)); |
55 |
|
FREETMPS; |
56 |
|
LEAVE; |
57 |
|
printf("Rd6502(%04x) = %02x\n", Addr, Value); |
58 |
|
return Value; |
59 |
} |
} |
60 |
|
|
61 |
void Wr6502(register word Addr,register byte Value) { |
void Wr6502(register word Addr,register byte Value) { |
62 |
printf("Wr6502(%04x,%02x)\n", Addr, Value); |
printf("Wr6502(%04x,%02x)\n", Addr, Value); |
63 |
|
dSP; |
64 |
|
ENTER; |
65 |
|
SAVETMPS; |
66 |
|
PUSHMARK(SP); |
67 |
|
XPUSHs( sv_2mortal( newSViv( Addr ) ) ); |
68 |
|
XPUSHs( sv_2mortal( newSViv( Value ) ) ); |
69 |
|
PUTBACK; |
70 |
|
call_pv("M6502::write", G_DISCARD ); |
71 |
|
FREETMPS; |
72 |
|
LEAVE; |
73 |
} |
} |
74 |
|
|
75 |
byte Op6502(register word Addr) { |
byte Op6502(register word Addr) { |