GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Acme::6502(3) User Contributed Perl Documentation Acme::6502(3)

Acme::6502 - Pure Perl 65C02 simulator.

This document describes Acme::6502 version 0.76

    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);

Imagine the nightmare scenario: your boss tells you about a legacy system you have to support. How bad could it be? COBOL? Fortran? Worse: it's an embedded 6502 system run by a family of squirrels (see Dilberts passim). Fortunately there's a pure Perl 6502 emulator that works so well the squirrels will never know the difference.

"new"
Create a new 6502 CPU.
"call_os( $vec_number )"
Subclass to provide OS entry points. OS vectors are installed by calling "make_vector". When the vector is called "call_os()" will be called with the vector number.
"get_a()"
Read the current value of the processor A register (accumulator).
"get_p()"
Read the current value of the processor status register.
"get_pc()"
Read the current value of the program counter.
"get_s()"
Read the current value of the stack pointer.
"get_x()"
Read the current value of the processor X index register.
"get_y()"
Read the current value of the processor X index register.
"get_xy()"
Read the value of X and Y as a sixteen bit number. X forms the lower 8 bits of the value and Y forms the upper 8 bits.
"get_state()"
Returns an array containing the values of the A, X, Y, S, P and SP.
"set_a( $value )"
Set the value of the processor A register (accumulator).
"set_p( $value )"
Set the value of the processor status register.
"set_pc( $value )"
Set the value of the program counter.
"set_s( $value )"
Set the value of the stack pointer.
"set_x( $value )"
Set the value of the X index register.
"set_y( $value )"
Set the value of the Y index register.
"set_xy( $value )"
Set the value of the X and Y registers to the specified sixteen bit number. X gets the lower 8 bits, Y gets the upper 8 bits.
"set_jumptab( $addr )"
Set the address of the block of memory that will be used to hold the thunk blocks that correspond with vectored OS entry points. Each thunk takes four bytes.
"load_rom( $filename, $addr )"
Load a ROM image at the specified address.
"make_vector( $jmp_addr, $vec_addr, $vec_number )"
Make a vectored entry point for an emulated OS. $jmp_addr is the address where an indirect JMP instruction (6C) will be placed, $vec_addr is the address of the vector and $vec_number will be passed to "call_os" when the OS call is made.
"poke_code( $addr, @bytes )"
Poke code directly at the specified address.
"read_8( $addr )"
Read a byte at the specified address.
"read_16( $addr )"
Read a sixteen bit (low, high) word at the specified address.
"read_32( $addr )"
Read a 32 bit word at the specified address.
"read_chunk( $start, $end )"
Read a chunk of data from $start to $end - 1 into a string.
"read_str( $addr )"
Read a carriage return terminated (0x0D) string from the specified address.
"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 instruction is executed:

    my $cb = sub {
        my ($pc, $inst, $a, $x, $y, $s, $p) = @_;
        # Maybe output trace info
    }
    
    $cpu->run(100, $cb);
    
"write_8( $addr, $value )"
Write the byte at the specified address.
"write_16( $addr, $value )"
Write a sixteen bit (low, high) value at the specified address.
"write_32( $addr, $value )"
Write a 32 bit value at the specified address.
"write_chunk( $addr, $string )"
Write a chunk of data to memory.

"Bad instruction at %s (%s)"
The emulator hit an illegal 6502 instruction.

Acme::6502 requires no configuration files or environment variables.

None.

None reported.

Doesn't have support for hardware emulation hooks - so memory mapped I/O is out of the question until someone fixes it.

Please report any bugs or feature requests to "bug-acme-6502@rt.cpan.org", or through the web interface at <http://rt.cpan.org>.

Andy Armstrong "<andy@hexten.net>"

Brian Cassidy "<bricas@cpan.org>"

Copyright (c) 2006-2012, Andy Armstrong "<andy@hexten.net>". All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

2022-04-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.