Acme-6502
view release on metacpan or search on metacpan
lib/Acme/6502.pm view on Meta::CPAN
=head1 VERSION
This document describes Acme::6502 version 0.76
=head1 SYNOPSIS
use Acme::6502;
my $cpu = Acme::6502->new();
# Set start address
$cpu->set_pc(0x8000);
# Load ROM image
$cpu->load_rom('myrom.rom', 0x8000);
# Run for 1,000,000 instructions then return
$cpu->run(1_000_000);
=head1 DESCRIPTION
lib/Acme/6502.pm view on Meta::CPAN
Read a byte at the specified address.
=item C<read_16( $addr )>
Read a sixteen bit (low, high) word at the specified address.
=item C<read_32( $addr )>
Read a 32 bit word at the specified address.
=item C<read_chunk( $start, $end )>
Read a chunk of data from C<$start> to C<$end> - 1 into a string.
=item C<read_str( $addr )>
Read a carriage return terminated (0x0D) string from the
specified address.
=item C<run( $count [, $callback ] )>
Execute the specified number of instructions and return. Optionally a
callback may be provided in which case it will be called before each
lib/Acme/6502/Tube.pm view on Meta::CPAN
die $@ if $@;
}
sub _osfile {
my $self = shift;
my $a = $self->get_a();
my $blk = $self->get_xy();
my $name = $self->read_str( $self->read_16( $blk ) );
my $load = $self->read_32( $blk + 2 );
my $exec = $self->read_32( $blk + 6 );
my $start = $self->read_32( $blk + 10 );
my $end = $self->read_32( $blk + 14 );
# printf("%-20s %08x %08x %08x %08x\n", $name, $load, $exec, $start, $end);
if ( $a == 0x00 ) {
# Save
open my $fh, '>', $name or die "Can't write $name\n";
binmode $fh;
my $buf = $self->read_chunk( $start, $end );
syswrite $fh, $buf or die "Error writing $name\n";
$self->set_a( 1 );
}
elsif ( $a == 0xFF ) {
# Load
if ( -f $name ) {
open my $fh, '<', $name or die "Can't read $name\n";
binmode $fh;
my $len = -s $fh;
sysread $fh, my $buf, $len or die "Error reading $name\n";
( run in 0.283 second using v1.01-cache-2.11-cpan-0d8aa00de5b )