Common Lisp Package: 6502

README:

FUNCTION

Public

SETFABSOLUTE (NEW-VALUE CPU)

SETFABSOLUTE-X (NEW-VALUE CPU)

SETFABSOLUTE-Y (NEW-VALUE CPU)

SETFACCUMULATOR (NEW-VALUE CPU)

BYTEVECTOR (SIZE)

Return an array of the given SIZE with element-type U8.

CPU-AR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CPU-CC (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CPU-PC (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CPU-SP (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CPU-SR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CPU-XR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CPU-YR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CURRENT-INSTRUCTION (CPU &OPTIONAL PRINT-P)

Return a list representing the current instruction. If PRINT-P is non-nil, print the current address and instruction and return NIL.

DISASM (START END)

Disassemble memory from START to END.

DISASM-TO-LIST (START END)

Disassemble a given region of memory into a sexp-based format.

DISASM-TO-STR (START END)

Call DISASM with the provided args and return its output as a string.

GET-BYTE (ADDRESS)

Get a byte from RAM at the given address.

SETFGET-BYTE (NEW-VAL ADDRESS)

Set ADDRESS in *ram* to NEW-VAL.

GET-INSTRUCTION (OPCODE)

Get the mnemonic for OPCODE. Returns a symbol to be funcalled or nil.

GET-RANGE (START &OPTIONAL END)

Get a range of bytes from RAM, starting from START and stopping at END if provided.

SETFGET-RANGE (BYTEVECTOR START)

Replace the contents of RAM, starting from START with BYTEVECTOR.

GET-WORD (ADDRESS &OPTIONAL WRAP-P)

Get a word from RAM starting at the given address.

SETFGET-WORD (NEW-VAL ADDRESS)

Set ADDRESS and (1+ ADDRESS) in *ram* to NEW-VAL, little endian ordering.

SETFIMMEDIATE (NEW-VALUE CPU)

SETFIMPLIED (NEW-VALUE CPU)

SETFINDIRECT (NEW-VALUE CPU)

SETFINDIRECT-X (NEW-VALUE CPU)

SETFINDIRECT-Y (NEW-VALUE CPU)

JIT-EXECUTE (CPU)

Execute the CPU with the dynamic recompiler.

JIT-STEP (CPU PC)

If the current block has been JIT compiled, run it, otherwise JIT compile it.

SETFRELATIVE (NEW-VALUE CPU)

STATUS-BIT (KEY CPU)

Retrieve bit KEY from the status register of CPU. KEY should be a keyword.

SETFSTATUS-BIT (NEW-VAL KEY CPU)

Set bit KEY in the status reg of CPU to NEW-VAL. KEY should be a keyword.

WRAP-BYTE (VAL)

Wrap the given value to ensure it conforms to (typep val 'u16), e.g. a Stack Pointer or general purpose register.

WRAP-WORD (VAL)

Wrap the given value to ensure it conforms to (typep val 'u16), e.g. a Program Counter address.

SETFZERO-PAGE (NEW-VALUE CPU)

SETFZERO-PAGE-X (NEW-VALUE CPU)

SETFZERO-PAGE-Y (NEW-VALUE CPU)

Undocumented

SETFCPU-AR (NEW-VALUE INSTANCE)

SETFCPU-CC (NEW-VALUE INSTANCE)

SETFCPU-PC (NEW-VALUE INSTANCE)

SETFCPU-SP (NEW-VALUE INSTANCE)

SETFCPU-SR (NEW-VALUE INSTANCE)

SETFCPU-XR (NEW-VALUE INSTANCE)

SETFCPU-YR (NEW-VALUE INSTANCE)

MAKE-CPU (&KEY ((PC DUM2) 65532) ((SP DUM3) 253) ((SR DUM4) 36) ((XR DUM5) 0) ((YR DUM6) 0) ((AR DUM7) 0) ((CC DUM8) 0))

Private

ARG-FORMATTER (ARG MODE)

Given an instruction's ARG, format it for display using the MODE's PRINTER.

COMPOSE (FUNCTION &REST MORE-FUNCTIONS)

Returns a function composed of FUNCTION and MORE-FUNCTIONS that applies its arguments to to each in turn, starting from the rightmost of MORE-FUNCTIONS, and then calling the next one with the primary value of the last.

DISASM-INS (INDEX &OPTIONAL (DISASM-OP #'PRINT-INSTRUCTION))

Lookup the metadata for the instruction at INDEX and pass it to DISASM-OP for formatting and display, returning the instruction length.

EMPTYP (SEQUENCE)

Returns true if SEQUENCE is an empty sequence. Signals an error if SEQUENCE is not a sequence.

EXTRACT-NUM (STR &OPTIONAL (MODE 'IMPLIED))

Extract a hex number from its containing string, STR.

FIND-OPCODE (NAME MODE)

Find an opcode matching NAME and MODE, raising ILLEGAL-OPCODE otherwise.

FLATTEN (TREE)

Traverses the tree in order, collecting non-null leaves into a list.

GET-BASIC-BLOCK (CPU)

Get the opcodes from the current PC to the next branch.

JIT-BLOCK (OPCODES)

Given a list of opcodes, JIT compile an equivalent function.

MAKE-KEYWORD (NAME)

Interns the string designated by NAME in the KEYWORD package.

MATCH-MODE (TOKENS)

Given a list of args, TOKENS, match them to an addressing mode or return NIL.

MAYBE-UPDATE-CYCLE-COUNT (CPU ADDRESS &OPTIONAL START)

If ADDRESS crosses a page boundary, add an extra cycle to CPU's count. If START is provided, test that against ADDRESS. Otherwise, use (absolute cpu).

OVERFLOW-P (RESULT &REST ARGS)

Checks whether the sign of RESULT is found in the signs of the ARGS.

PROCESS-ARGS (TOKENS MODE)

Take a list of args TOKENS and produce an appropriate 6502 bytevector.

PROCESS-STATEMENT (STATEMENT)

Given a symbolic assembly STATEMENT, convert it to a list of bytes.

ROTATE-BYTE (INTEGER COUNT CPU)

Rotate the bits of INTEGER by COUNT. If COUNT is negative, rotate right.

SET-FLAGS-NZ (CPU VALUE)

Set the zero and negative bits of CPU's staus-register based on VALUE.

SEXPIFY-INSTRUCTION (BYTES INDEX NAME MODE)

Given BYTES and metadata, return a sexp-format representation of it.

STACK-POP (CPU)

Pop the value pointed to by the SP and increment the SP.

STACK-POP-WORD (CPU)

Pop a 16-bit word off the stack.

STACK-PUSH (VALUE CPU)

Push the given VALUE on the stack and decrement the SP.

STACK-PUSH-WORD (VALUE CPU)

Push the 16-bit word VALUE onto the stack.

TRANSFORM-SEXP-SYNTAX (TOKENS)

Given a SEXP-token using an indirect, *.x or *.y addressing mode, transform it to use the classic string assembly syntax.

WRAP-PAGE (ADDRESS)

Wrap the given ADDRESS, ensuring that we don't cross a page boundary. e.g. When the last two bytes of ADDRESS are #xff.

Undocumented

%STATUS-BIT (KEY &OPTIONAL NEXT)

COPY-CPU (INSTANCE)

CPU-P (OBJECT)

TOKENIZE-STATEMENT (STR)

TRANSFORM-STR-SYNTAX (BYTES MODE)

TRIM-WHITESPACE (STR)

MACRO

Public

DEFENUM (NAME (&REST KEYS))

Define a function named %NAME, that takes args (KEY &OPTIONAL NEXT). If NEXT is non-nil, return the successor to KEY. Othewrise, return the index of KEY. KEYS may consist of scalar values or lists that start with a scalar value.

Private

BRANCH-IF (PREDICATE CPU)

Take a Relative branch if PREDICATE is true, otherwise increment the PC.

DEFADDRESS (NAME (&KEY CPU-REG READER PRINTER (DOCS )) &BODY BODY)

Define an Addressing Mode in the form of a method called NAME specialized on CPU returning an address according to BODY and a setf function to store to that address. If CPU-REG is non-nil, BODY will be wrapped in a get-byte for setf. READER should be a Perl-compatible regex that can read assembly in the mode. PRINTER should be the format string desired for disassembly of the mode. DOCS is used as the documentation for the method and setf function when provided.

DEFINS ((NAME OPCODE CYCLE-COUNT BYTE-COUNT MODE) (&KEY SETF-FORM (TRACK-PC T)) &BODY BODY)

Define an EQL-Specialized method on OPCODE named NAME. MODE must return an address or byte at an address if funcalled with a cpu. SETF-FORM is a lambda that may be funcalled with a value to set the address computed by MODE. If TRACK-PC is t, the default, the program counter will be incremented to just past the instruction's operands. Otherwise, BODY is responsible for the PC.

DEFOPCODE (NAME (&KEY (DOCS ) ADDR-STYLE (TRACK-PC T)) MODES &BODY BODY)

Define a Generic Function NAME with DOCS if provided and instructions, i.e. methods, via DEFINS for each addressing mode listed in MODES. If ADDR-STYLE is :raw, MODE can be funcalled with a cpu in BODY to retrieve MODE's address. If ADDR-STYLE is :mixed, accumulator addressing returns the accumulator value while others return the byte at MODE's address. If ADDR-STYLE is nil, funcalling MODE will return the byte at the given address.

SET-FLAGS-IF (CPU &REST FLAG-PREDS)

Takes any even number of arguments where the first is a keyword denoting a status bit and the second is a funcallable predicate that takes no arguments. It will set each flag to 1 if its predicate is true, otherwise 0.

WITH-DISASM ((START END &KEY OP) &BODY BODY)

Loop from START to END, passing each instruction to OP and execute BODY. OP is PRINT-INSTRUCTION by default. Within BODY, the return value of OP is bound to RESULT and the length of the instruction in bytes is bound to STEP.

GENERIC-FUNCTION

Public

6502-STEP (CPU OPCODE)

Step the CPU through the next instruction, returning the CPU or :done.

ABSOLUTE (CPU)

ABSOLUTE-X (CPU)

ABSOLUTE-Y (CPU)

ACCUMULATOR (CPU)

ASM (SOURCE)

Assemble SOURCE into a bytevector and return it.

EXECUTE (CPU &OPTIONAL PROGRAM)

Step the CPU until a BRK. If a PROGRAM bytevector is supplied, it will be placed at the beginning of *ram* and the PC will be set to 0.

IMMEDIATE (CPU)

IMPLIED (CPU)

INDIRECT (CPU)

INDIRECT-X (CPU)

INDIRECT-Y (CPU)

NMI (OBJ)

Generate a non-maskable interrupt. Used for vblanking in NES.

RELATIVE (CPU)

RESET (OBJ)

Reset the OBJ to an initial state.

ZERO-PAGE (CPU)

ZERO-PAGE-X (CPU)

ZERO-PAGE-Y (CPU)

Private

ADC (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (INDIRECT-X CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (INDIRECT-X CPU)))))

Add to Accumulator with Carry

AND (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (INDIRECT-X CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (INDIRECT-X CPU)))))

And with Accumulator

ASL (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ZERO-PAGE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (ZERO-PAGE CPU)))))

Arithmetic Shift Left

BCC (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (RELATIVE CPU)))) (SETF-FORM (LAMBDA (X) (SETF (RELATIVE CPU) X))))

Branch on Carry Clear

BCS (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (RELATIVE CPU)))) (SETF-FORM (LAMBDA (X) (SETF (RELATIVE CPU) X))))

Branch on Carry Set

BEQ (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (RELATIVE CPU)))) (SETF-FORM (LAMBDA (X) (SETF (RELATIVE CPU) X))))

Branch if Equal

BIT (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ZERO-PAGE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (ZERO-PAGE CPU)))))

Test Bits in Memory with Accumulator

BMI (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (RELATIVE CPU)))) (SETF-FORM (LAMBDA (X) (SETF (RELATIVE CPU) X))))

Branch on Negative Result

BNE (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (RELATIVE CPU)))) (SETF-FORM (LAMBDA (X) (SETF (RELATIVE CPU) X))))

Branch if Not Equal

BPL (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (RELATIVE CPU)))) (SETF-FORM (LAMBDA (X) (SETF (RELATIVE CPU) X))))

Branch on Positive Result

BRK (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Force Break

BVC (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (RELATIVE CPU)))) (SETF-FORM (LAMBDA (X) (SETF (RELATIVE CPU) X))))

Branch on Overflow Clear

BVS (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (RELATIVE CPU)))) (SETF-FORM (LAMBDA (X) (SETF (RELATIVE CPU) X))))

Branch on Overflow Set

CLC (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Clear Carry Flag

CLD (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Clear Decimal Flag

CLI (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Clear Interrupt Flag

CLV (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Clear Overflow Flag

CMP (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (INDIRECT-X CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (INDIRECT-X CPU)))))

Compare Memory with Accumulator

CPX (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (IMMEDIATE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (IMMEDIATE CPU)))))

Compare Memory with X register

CPY (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (IMMEDIATE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (IMMEDIATE CPU)))))

Compare Memory with Y register

DEC (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ZERO-PAGE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (ZERO-PAGE CPU)))))

Decrement Memory

DEX (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Decrement X register

DEY (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Decrement Y register

EOR (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (INDIRECT-X CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (INDIRECT-X CPU)))))

Exclusive OR with Accumulator

INC (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ZERO-PAGE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (ZERO-PAGE CPU)))))

Increment Memory

INX (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Increment X register

INY (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Increment Y register

JMP (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ABSOLUTE CPU) X))) (MODE 'ABSOLUTE))

Jump Unconditionally

JSR (OPCODE CPU &KEY MODE SETF-FORM (MODE 'ABSOLUTE) (SETF-FORM (LAMBDA (X) (SETF (ABSOLUTE CPU) X))))

Jump to Subroutine

LDA (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (INDIRECT-X CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (INDIRECT-X CPU)))))

Load Accumulator from Memory

LDX (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (IMMEDIATE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (IMMEDIATE CPU)))))

Load X register from Memory

LDY (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (IMMEDIATE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (IMMEDIATE CPU)))))

Load Y register from Memory

LSR (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ZERO-PAGE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (ZERO-PAGE CPU)))))

Logical Shift Right

NOP (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

No Operation

ORA (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (INDIRECT-X CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (INDIRECT-X CPU)))))

Bitwise OR with Accumulator

PHA (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Push Accumulator

PHP (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Push Processor Status

PLA (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Pull Accumulator from Stack

PLP (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Pull Processor Status from Stack

PRINTER (MODE)

Return a format string suitable for printing MODE.

READER (MODE)

Return a Perl-compatible regex suitable for parsing MODE.

ROL (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ACCUMULATOR CPU) X))) (MODE 'ACCUMULATOR))

Rotate Left

ROR (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ZERO-PAGE CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (ZERO-PAGE CPU)))))

Rotate Right

RTI (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Return from Interrupt

RTS (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Return from Subroutine

SBC (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (INDIRECT-X CPU) X))) (MODE (LAMBDA (CPU) (GET-BYTE (INDIRECT-X CPU)))))

Subtract from Accumulator with Carry

SEC (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Set Carry Flag

SED (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Set Decimal Flag

SEI (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Set Interrupt Flag

STA (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (INDIRECT-X CPU) X))) (MODE 'INDIRECT-X))

Store Accumulator

STX (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ZERO-PAGE CPU) X))) (MODE 'ZERO-PAGE))

Store X register

STY (OPCODE CPU &KEY MODE SETF-FORM (SETF-FORM (LAMBDA (X) (SETF (ZERO-PAGE CPU) X))) (MODE 'ZERO-PAGE))

Store Y register

TAX (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Transfer Accumulator to X register

TAY (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Transfer Accumulator to Y register

TSX (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Transfer Stack Pointer to X register

TXA (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Transfer X register to Accumulator

TXS (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Transfer X register to Stack Pointer

TYA (OPCODE CPU &KEY MODE SETF-FORM (MODE (LAMBDA (CPU) (GET-BYTE (IMPLIED CPU)))) (SETF-FORM (LAMBDA (X) (SETF (IMPLIED CPU) X))))

Transfer Y register to Accumulator

Undocumented

LINE (CONDITION)

MODE (CONDITION)

OPCODE (CONDITION)

VARIABLE

Public

*CPU*

The 6502 instance used by opcodes in the package.

Private

*JIT-CACHE*

The JIT's hot code cache. Currently never invalidated.

*OPCODES*

A mapping of opcodes to instruction mnemonic/metadata conses.

*RAM*

A lovely hunk of bytes.

CLASS

Public

CPU

A 6502 CPU with an extra slot for tracking the cycle count/clock ticks.

CONDITION

Private

6502-ERROR

The base condition for all errors in 6502.

ILLEGAL-OPCODE

Illegal opcodes are not currently implemented.

INVALID-MODE

Only the 6502 addressing modes have readers and printers.

INVALID-SYNTAX

Assembly must conform to the syntax in the README.