6 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
7 |
use Carp qw/confess/; |
use Carp qw/confess/; |
8 |
use Exporter 'import'; |
use Exporter 'import'; |
9 |
our @EXPORT = qw'@mem $PC $A $P $X $Y $S $IPeriod'; |
our @EXPORT = qw'@mem $PC $A $P $X $Y $S $IPeriod $run_for'; |
10 |
|
|
11 |
=head1 NAME |
=head1 NAME |
12 |
|
|
23 |
# program counter |
# program counter |
24 |
our $PC = 0xbeef; |
our $PC = 0xbeef; |
25 |
# CPU registars |
# CPU registars |
26 |
our ( $A, $P, $X, $Y, $S ) = (0x42) x 5; |
our ( $A, $P, $X, $Y, $S ) = (0) x 5; |
27 |
# Set IPeriod to number of CPU cycles between calls to Loop6502 |
# Set IPeriod to number of CPU cycles between calls to Loop6502 |
28 |
our $IPeriod = 1; |
our $IPeriod = 1; |
29 |
|
# Exec6502 cycles |
30 |
|
our $run_for = 1; |
31 |
|
$run_for = 0x42; |
32 |
|
|
33 |
=head1 init |
=head1 init |
34 |
|
|
119 |
confess "no from address"; |
confess "no from address"; |
120 |
} |
} |
121 |
|
|
122 |
|
=head2 push_R |
123 |
|
|
124 |
|
called by C<perl.c> to push changes in registars back to perl variables |
125 |
|
|
126 |
|
=cut |
127 |
|
|
128 |
|
sub push_R { |
129 |
|
warn "push_R(",dump(@_),")\n"; |
130 |
|
my ( $a, $p, $x, $y, $s, $pc ) = @_; |
131 |
|
$PC = $pc; |
132 |
|
$S=$s; $X=$x; $Y=$y; $P=$p; $A=$a; |
133 |
|
dump_R(); |
134 |
|
} |
135 |
|
|
136 |
|
=head2 dump_R |
137 |
|
|
138 |
|
helper function which dumps registers |
139 |
|
|
140 |
|
=cut |
141 |
|
|
142 |
|
sub dump_R { |
143 |
|
warn sprintf("PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", $PC, $A, $P, $X, $Y, $S); |
144 |
|
} |
145 |
|
|
146 |
1; |
1; |