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 $run_for $debug'; |
our @EXPORT = qw'@mem $PC $A $P $X $Y $S $IPeriod $ICount $IRequest $IAutoReset $TrapBadOps $Trap $Trace $run_for $debug'; |
10 |
|
|
11 |
=head1 NAME |
=head1 NAME |
12 |
|
|
24 |
our $PC = 0xbeef; |
our $PC = 0xbeef; |
25 |
# CPU registars |
# CPU registars |
26 |
our ( $A, $P, $X, $Y, $S ) = (0) x 5; |
our ( $A, $P, $X, $Y, $S ) = (0) x 5; |
27 |
# Set IPeriod to number of CPU cycles between calls to Loop6502 |
|
28 |
our $IPeriod = 1; |
our $IPeriod=1; # Set IPeriod to number of CPU cycles between calls to Loop6502 |
29 |
|
our $ICount; |
30 |
|
our $IRequest; # Set to the INT_IRQ when pending IRQ |
31 |
|
our $IAutoReset; # Set to 1 to autom. reset IRequest |
32 |
|
our $TrapBadOps=1; # Set to 1 to warn of illegal opcodes |
33 |
|
our $Trap; # Set Trap to address to trace from |
34 |
|
our $Trace; # Set Trace=1 to start tracing |
35 |
|
|
36 |
# Exec6502 cycles |
# Exec6502 cycles |
37 |
our $run_for = 0; |
our $run_for = 0; |
38 |
|
|
144 |
|
|
145 |
sub push_R { |
sub push_R { |
146 |
warn "## M6502::push_R(",dump(@_),")\n" if $debug; |
warn "## M6502::push_R(",dump(@_),")\n" if $debug; |
147 |
my ( $a, $p, $x, $y, $s, $pc ) = @_; |
( $A, $P, $X, $Y, $S, $PC, $IPeriod, $ICount, $IRequest, $IAutoReset, $TrapBadOps, $Trap, $Trace ) = @_; |
|
$PC = $pc; |
|
|
$S=$s; $X=$x; $Y=$y; $P=$p; $A=$a; |
|
148 |
dump_R(); |
dump_R(); |
149 |
} |
} |
150 |
|
|
157 |
=cut |
=cut |
158 |
|
|
159 |
sub dump_R { |
sub dump_R { |
160 |
my $dump = sprintf(" PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x\n", $PC, $A, $P, $X, $Y, $S); |
my $dump = sprintf(" PC: %04x A:%02x P:%02x X:%02x Y:%02x S:%02x " |
161 |
|
. "IPeriod:%d ICount:%d IRequest:%02x IAutoReset:%02x TrapBadOps:%d Trap:%d Trace:%d" |
162 |
|
. "\n", |
163 |
|
$PC, $A, $P, $X, $Y, $S, $IPeriod, $ICount, $IRequest, $IAutoReset, $TrapBadOps, $Trap, $Trace, |
164 |
|
); |
165 |
warn "## M6502::dump_R $dump" if $debug; |
warn "## M6502::dump_R $dump" if $debug; |
166 |
return $dump; |
return $dump; |
167 |
} |
} |