The cl-6502 Reference Manual

This is the cl-6502 Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 14:55:08 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 cl-6502

An emulator for the MOS 6502 CPU

Author

Brit Butler <>

License

BSD

Dependencies
  • alexandria (system).
  • cl-ppcre (system).
Source

cl-6502.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 cl-6502/cl-6502.asd

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

ASDF Systems

cl-6502.

Packages

6502-conf.

Public Interface

app-path (function).

Internals

*basedir* (special variable).


3.1.2 cl-6502/packages.lisp

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

Packages

3.1.3 cl-6502/conditions.lisp

Dependency

packages.lisp (file).

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

Internals

3.1.4 cl-6502/addressing.lisp

Dependency

conditions.lisp (file).

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

Public Interface
Internals

3.1.5 cl-6502/cpu.lisp

Dependency

addressing.lisp (file).

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

Public Interface
Internals

3.1.6 cl-6502/disassemble.lisp

Dependency

cpu.lisp (file).

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

Public Interface
Internals

3.1.7 cl-6502/parser.lisp

Dependency

disassemble.lisp (file).

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

Internals

3.1.8 cl-6502/assemble.lisp

Dependency

parser.lisp (file).

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

Public Interface

asm (generic function).

Internals

3.1.9 cl-6502/opcodes.lisp

Dependency

assemble.lisp (file).

Source

cl-6502.asd.

Parent Component

cl-6502 (system).


3.1.10 cl-6502/jit.lisp

Dependency

opcodes.lisp (file).

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

Public Interface

jit-step (function).

Internals

3.1.11 cl-6502/utils.lisp

Dependency

jit.lisp (file).

Source

cl-6502.asd.

Parent Component

cl-6502 (system).

Public Interface

4 Packages

Packages are listed by definition order.


4.1 6502

Source

packages.lisp.

Use List

common-lisp.

Public Interface
Internals

4.2 cl-6502

Homepage: <a href="http://github.com/redline6561/cl-6502">Github</a>

Source

packages.lisp.

Use List

common-lisp.


4.3 6502-conf

Source

cl-6502.asd.

Public Interface

app-path (function).

Internals

*basedir* (special variable).


5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *cpu*

The 6502 instance used by default during execution.

Package

6502.

Source

cpu.lisp.

Special Variable: *opcode-meta*

A mapping of opcodes to metadata lists.

Package

6502.

Source

cpu.lisp.


5.1.2 Macros

Macro: defenum (name (&rest keys))

Define a function named %NAME, that takes KEY as an arg and returns the index of KEY. KEYS should be scalar values.

Package

6502.

Source

cpu.lisp.

Macro: status-bit (key)

Test if KEY is set in the status register. KEY should be a keyword.

Package

6502.

Source

cpu.lisp.


5.1.3 Ordinary functions

Function: absolute (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf absolute) (cpu)
Package

6502.

Source

addressing.lisp.

Function: absolute-x (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf absolute-x) (cpu)
Package

6502.

Source

addressing.lisp.

Function: absolute-y (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf absolute-y) (cpu)
Package

6502.

Source

addressing.lisp.

Function: accumulator (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf accumulator) (cpu)
Package

6502.

Source

addressing.lisp.

Function: app-path (path &rest args)
Package

6502-conf.

Source

cl-6502.asd.

Function: bytevector (size)

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

Package

6502.

Source

cpu.lisp.

Reader: cpu-ar (instance)
Writer: (setf cpu-ar) (instance)
Package

6502.

Source

cpu.lisp.

Target Slot

ar.

Reader: cpu-cc (instance)
Writer: (setf cpu-cc) (instance)
Package

6502.

Source

cpu.lisp.

Target Slot

cc.

Reader: cpu-pc (instance)
Writer: (setf cpu-pc) (instance)
Package

6502.

Source

cpu.lisp.

Target Slot

pc.

Reader: cpu-sp (instance)
Writer: (setf cpu-sp) (instance)
Package

6502.

Source

cpu.lisp.

Target Slot

sp.

Reader: cpu-sr (instance)
Writer: (setf cpu-sr) (instance)
Package

6502.

Source

cpu.lisp.

Target Slot

sr.

Reader: cpu-xr (instance)
Writer: (setf cpu-xr) (instance)
Package

6502.

Source

cpu.lisp.

Target Slot

xr.

Reader: cpu-yr (instance)
Writer: (setf cpu-yr) (instance)
Package

6502.

Source

cpu.lisp.

Target Slot

yr.

Function: 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.

Package

6502.

Source

disassemble.lisp.

Function: disasm (start end)

Disassemble memory from START to END.

Package

6502.

Source

disassemble.lisp.

Function: disasm-to-list (start end)

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

Package

6502.

Source

disassemble.lisp.

Function: disasm-to-str (start end)

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

Package

6502.

Source

disassemble.lisp.

Function: execute (cpu)

Step the CPU until a BRK instruction.

Package

6502.

Source

utils.lisp.

Function: get-byte (address)

Get a byte from RAM at the given ADDRESS.

Package

6502.

Source

cpu.lisp.

Function: (setf get-byte) (address)

Set ADDRESS in *ram* to NEW-VAL.

Package

6502.

Source

cpu.lisp.

Function: get-range (start &optional end)

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

Package

6502.

Source

cpu.lisp.

Function: (setf get-range) (start)

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

Package

6502.

Source

cpu.lisp.

Function: get-word (address &optional wrap-p)

Get a word from RAM starting at the given ADDRESS.

Package

6502.

Source

cpu.lisp.

Function: (setf get-word) (address)

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

Package

6502.

Source

cpu.lisp.

Function: immediate (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf immediate) (cpu)
Package

6502.

Source

addressing.lisp.

Function: implied (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf implied) (cpu)
Package

6502.

Source

addressing.lisp.

Function: indirect (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf indirect) (cpu)
Package

6502.

Source

addressing.lisp.

Function: indirect-x (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf indirect-x) (cpu)
Package

6502.

Source

addressing.lisp.

Function: indirect-y (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf indirect-y) (cpu)
Package

6502.

Source

addressing.lisp.

Function: jit-step (cpu pc)

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

Package

6502.

Source

jit.lisp.

Function: make-cpu (&key pc sp sr xr yr ar cc)
Package

6502.

Source

cpu.lisp.

Function: relative (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf relative) (cpu)
Package

6502.

Source

addressing.lisp.

Function: step-cpu (cpu opcode)

Step the CPU through the next OPCODE.

Package

6502.

Source

utils.lisp.

Function: wrap-byte (value)

Wrap VALUE so it conforms to (typep value ’u8), i.e. a single byte.

Package

6502.

Source

cpu.lisp.

Function: wrap-word (value)

Wrap VALUE so it conforms to (typep value ’u16), i.e. a machine word.

Package

6502.

Source

cpu.lisp.

Function: zero-page (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf zero-page) (cpu)
Package

6502.

Source

addressing.lisp.

Function: zero-page-x (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf zero-page-x) (cpu)
Package

6502.

Source

addressing.lisp.

Function: zero-page-y (cpu)
Package

6502.

Source

addressing.lisp.

Function: (setf zero-page-y) (cpu)
Package

6502.

Source

addressing.lisp.


5.1.4 Generic functions

Generic Function: asm (source &optional init-env org-start)

Assemble SOURCE into a bytevector and return it.

Package

6502.

Source

assemble.lisp.

Methods
Method: asm ((source string) &optional init-env org-start)
Method: asm ((source list) &optional init-env org-start)
Generic Function: nmi (obj)

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

Package

6502.

Source

cpu.lisp.

Methods
Method: nmi (obj)
Generic Function: reader (mode)

Return a Perl-compatible regex suitable for parsing MODE.

Package

6502.

Source

addressing.lisp.

Methods
Method: reader ((mode (eql |6502|:relative)))
Method: reader ((mode (eql |6502|:indirect-y)))
Method: reader ((mode (eql |6502|:indirect-x)))
Method: reader ((mode (eql |6502|:indirect)))
Method: reader ((mode (eql |6502|:absolute-y)))
Method: reader ((mode (eql |6502|:absolute-x)))
Method: reader ((mode (eql |6502|:absolute)))
Method: reader ((mode (eql |6502|:zero-page-y)))
Method: reader ((mode (eql |6502|:zero-page-x)))
Method: reader ((mode (eql |6502|:zero-page)))
Method: reader ((mode (eql |6502|:immediate)))
Method: reader ((mode (eql |6502|:accumulator)))
Method: reader ((mode (eql |6502|:implied)))
Method: reader (mode)
Generic Function: reset (obj)

Reset the OBJ to an initial state.

Package

6502.

Source

cpu.lisp.

Methods
Method: reset (obj)
Generic Function: writer (mode)

Return a format string suitable for printing MODE.

Package

6502.

Source

addressing.lisp.

Methods
Method: writer ((mode (eql |6502|:relative)))
Method: writer ((mode (eql |6502|:indirect-y)))
Method: writer ((mode (eql |6502|:indirect-x)))
Method: writer ((mode (eql |6502|:indirect)))
Method: writer ((mode (eql |6502|:absolute-y)))
Method: writer ((mode (eql |6502|:absolute-x)))
Method: writer ((mode (eql |6502|:absolute)))
Method: writer ((mode (eql |6502|:zero-page-y)))
Method: writer ((mode (eql |6502|:zero-page-x)))
Method: writer ((mode (eql |6502|:zero-page)))
Method: writer ((mode (eql |6502|:immediate)))
Method: writer ((mode (eql |6502|:accumulator)))
Method: writer ((mode (eql |6502|:implied)))
Method: writer (mode)

5.1.5 Standalone methods

Method: initialize-instance :after ((cpu cpu) &key)
Source

cpu.lisp.


5.1.6 Structures

Structure: cpu

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

Package

6502.

Source

cpu.lisp.

Direct superclasses

structure-object.

Direct methods

initialize-instance.

Direct slots
Slot: pc
Type

|6502|:u16

Initform

65532

Readers

cpu-pc.

Writers

(setf cpu-pc).

Slot: sp
Type

|6502|:u8

Initform

253

Readers

cpu-sp.

Writers

(setf cpu-sp).

Slot: sr
Type

|6502|:u8

Initform

36

Readers

cpu-sr.

Writers

(setf cpu-sr).

Slot: xr
Type

|6502|:u8

Initform

0

Readers

cpu-xr.

Writers

(setf cpu-xr).

Slot: yr
Type

|6502|:u8

Initform

0

Readers

cpu-yr.

Writers

(setf cpu-yr).

Slot: ar
Type

|6502|:u8

Initform

0

Readers

cpu-ar.

Writers

(setf cpu-ar).

Slot: cc
Type

fixnum

Initform

0

Readers

cpu-cc.

Writers

(setf cpu-cc).


5.1.7 Types

Type: u16 ()
Package

6502.

Source

cpu.lisp.

Type: u8 ()
Package

6502.

Source

cpu.lisp.


5.2 Internals


5.2.1 Constants

Constant: +max-byte+
Package

6502.

Source

assemble.lisp.

Constant: +relative-branch-size-byte+
Package

6502.

Source

assemble.lisp.


5.2.2 Special variables

Special Variable: *address-modes*

A list of all the 6502 Address Modes.

Package

6502.

Source

addressing.lisp.

Special Variable: *basedir*
Package

6502-conf.

Source

cl-6502.asd.

Special Variable: *jit-cache*

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

Package

6502.

Source

jit.lisp.

Special Variable: *opcode-funs*

The opcode lambdas used during emulation.

Package

6502.

Source

cpu.lisp.

Special Variable: *ram*

A lovely hunk of bytes.

Package

6502.

Source

cpu.lisp.

Special Variable: +absolute-modes+
Package

6502.

Source

assemble.lisp.

Special Variable: +zero-page-modes+
Package

6502.

Source

assemble.lisp.


5.2.3 Macros

Macro: branch-if (predicate)

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

Package

6502.

Source

cpu.lisp.

Macro: defaddress (name (&key reader writer cpu-reg) &body body)

Define an Addressing Mode, NAME, with READER and WRITER methods that take NAME as a symbol and return a regex or format expression, respectively, and a function and setf function to get and set the data pointed to by the given mode.

Package

6502.

Source

addressing.lisp.

Macro: defasm (name (&key docs raw-p track-pc) modes &body body)

Define a 6502 instruction NAME, storing its DOCS and metadata in *opcode-meta*, and a lambda that executes BODY in *opcode-funs*. Within BODY, the functions GETTER and SETTER can be used to get and set values for the current addressing mode, respectively. TRACK-PC can be passed nil to disable program counter updates for branching/jump operations. If RAW-P is true, GETTER will return the mode’s address directly, otherwise it will return the byte at that address. MODES is a list of opcode metadata lists: (opcode cycles bytes mode).

Package

6502.

Source

cpu.lisp.

Macro: resolve-byte (place env)

Given a place and an environment, if that place is a function, call that function with the environment and assign the result to the place.

Package

6502.

Source

assemble.lisp.

Macro: set-flags-if (&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.

Package

6502.

Source

cpu.lisp.

Macro: set-status-bit (key new-val)

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

Package

6502.

Source

cpu.lisp.

Macro: 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.

Package

6502.

Source

disassemble.lisp.


5.2.4 Ordinary functions

Function: %status-bit (key)
Package

6502.

Source

cpu.lisp.

Function: arg-formatter (arg mode)

Given an instruction’s ARG, format it for display using the MODE’s WRITER.

Package

6502.

Source

disassemble.lisp.

Function: assemble-code-block (code-block &optional init-env org-start)

Given a list of instructions, assemble each to a byte vector.

Package

6502.

Source

assemble.lisp.

Function: assemble-instruction (instruction pc env)

Given an instruction, and the current program counter, fill the environment with any labels and assemble instruction to a list of bytes.

Package

6502.

Source

assemble.lisp.

Function: bytes-to-keyword-syntax (bytes mode)

Take BYTES and a MODE and return our assembly representation of the arguments.

Package

6502.

Source

disassemble.lisp.

Function: copy-cpu (instance)
Package

6502.

Source

cpu.lisp.

Function: copy-instruction (instance)
Package

6502.

Source

assemble.lisp.

Function: cpu-p (object)
Package

6502.

Source

cpu.lisp.

Function: decide-address-mode (instruction env)

Finds the desired address mode, matching what the opcode allows to what was parsed from the operand’s syntax.

Package

6502.

Source

assemble.lisp.

Function: disasm-ins (index &optional disasm-op)

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

Package

6502.

Source

disassemble.lisp.

Function: fetch-expression (stream)

Fetches an expression from the stream, either a term or a term plus another.

Package

6502.

Source

parser.lisp.

Function: fetch-label (stream)

Fetches a label from the stream, or returns nil.

Package

6502.

Source

parser.lisp.

Function: fetch-literal (stream)

Fetches a literal value from the stream and returns it as an alist containing the integer value and address mode, or returns nil.

Package

6502.

Source

parser.lisp.

Function: fetch-name (stream)

Fetches a name from the stream, or returns nil.

Package

6502.

Source

parser.lisp.

Function: fetch-opcode (stream)

Fetches an opcode from the stream as a keyword, or returns nil.

Package

6502.

Source

parser.lisp.

Function: fetch-operand (stream)

Fetches the operand, returning its numerical value and possible address-modes.

Package

6502.

Source

parser.lisp.

Function: fetch-term (stream)

Fetches a literal or name from the stream, or returns nil.

Package

6502.

Source

parser.lisp.

Function: find-opcode (opcode mode)

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

Package

6502.

Source

assemble.lisp.

Function: get-basic-block (cpu)

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

Package

6502.

Source

jit.lisp.

Function: get-opcode-address-modes (opcode)

Given an opcode, return the possible address modes for that operation.

Package

6502.

Source

assemble.lisp.

Reader: instruction-address-mode (instance)
Writer: (setf instruction-address-mode) (instance)
Package

6502.

Source

assemble.lisp.

Target Slot

address-mode.

Reader: instruction-label (instance)
Writer: (setf instruction-label) (instance)
Package

6502.

Source

assemble.lisp.

Target Slot

label.

Reader: instruction-opcode (instance)
Writer: (setf instruction-opcode) (instance)
Package

6502.

Source

assemble.lisp.

Target Slot

opcode.

Function: instruction-p (object)
Package

6502.

Source

assemble.lisp.

Reader: instruction-value (instance)
Writer: (setf instruction-value) (instance)
Package

6502.

Source

assemble.lisp.

Target Slot

value.

Function: jit-block (opcodes)

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

Package

6502.

Source

jit.lisp.

Function: list-to-instructions (instructions)

Given a list of assembly tuples, convert them to instructions.

Package

6502.

Source

assemble.lisp.

Function: make-and-resolve-byte (operand pc type env)

Given an operand, convert it to a byte, resolving any delayed functions.

Package

6502.

Source

assemble.lisp.

Function: make-byte (value pc type)

Given an integer, return a single byte for the required type. Given a label, return a delayed function to calculate the same, once labels are defined.

Package

6502.

Source

assemble.lisp.

Function: make-getter (name mode raw-p)

Generate an appropriate GETTER for NAME based on RAW-P and whether or not it is a register shift operation.

Package

6502.

Source

addressing.lisp.

Function: make-instruction (&key label opcode address-mode value)
Package

6502.

Source

assemble.lisp.

Function: make-stream (text)

Make a string displaced onto the given text.

Package

6502.

Source

parser.lisp.

Function: match-opcode-data (data opcode &optional address-mode)

Returns whether the asm metadata matches the given opcode, and address-mode if it is provided.

Package

6502.

Source

assemble.lisp.

Function: match-operand-address-modes (stream)

Matches the stream against all address-mode readers, returning those that match, as well as the positions where the match occurs.

Package

6502.

Source

parser.lisp.

Function: 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 the absolute address.

Package

6502.

Source

cpu.lisp.

Function: operand-possible-modes-and-value (stream)

Returns all matching address-modes for the operand, along with positions where the match occurs.

Package

6502.

Source

parser.lisp.

Function: overflow-p (result reg mem)

Checks whether the sign of RESULT is found in the signs of REG or MEM.

Package

6502.

Source

cpu.lisp.

Function: parse-code (text)

Parses the assembly source text and returns the assembled code as a list of alists.

Package

6502.

Source

parser.lisp.

Function: parse-line (text)

Converts a line of text into an instruction representing the assembly code.

Package

6502.

Source

parser.lisp.

Function: print-instruction (bytes index name docs mode)

Format the instruction at INDEX and its operands for display.

Package

6502.

Source

disassemble.lisp.

Function: process-args (value address-mode pc)

Given the operand value, address-mode, and program counter, return a list of assembled bytes, using delayed functions for labels or expressions.

Package

6502.

Source

assemble.lisp.

Function: rotate-byte (integer count cpu)

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

Package

6502.

Source

cpu.lisp.

Function: sexpify-instruction (bytes index name docs mode)

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

Package

6502.

Source

disassemble.lisp.

Function: skip-white-space (stream)

Fetches white space from the stream, ignores it and returns the stream.

Package

6502.

Source

parser.lisp.

Function: stack-pop (cpu)

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

Package

6502.

Source

cpu.lisp.

Function: stack-pop-word (cpu)

Pop a 16-bit word off the stack.

Package

6502.

Source

cpu.lisp.

Function: stack-push (value cpu)

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

Package

6502.

Source

cpu.lisp.

Function: stack-push-word (value cpu)

Push the 16-bit word VALUE onto the stack.

Package

6502.

Source

cpu.lisp.

Function: strip-comment (text)

Removes comment and white space from end of string.

Package

6502.

Source

parser.lisp.

Function: substream-advance (stream start end)

Set the stream to a substream at START positions ahead and finishing at END position.

Package

6502.

Source

parser.lisp.

Function: transform-sexp-syntax (sexp-token)

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

Package

6502.

Source

assemble.lisp.

Function: try-fetch (stream regex)

If the stream begins with a regex match, returns the matched text and move the stream past it. Otherwise, returns nil.

Package

6502.

Source

parser.lisp.

Function: tuple-to-instruction (opcode &optional operand)

Given an opcode and value, as symbols, convert them to an instruction.

Package

6502.

Source

assemble.lisp.

Function: wrap-page (address)

Wrap the given ADDRESS, ensuring that we don’t cross a page boundary. e.g. If we (get-word address).

Package

6502.

Source

cpu.lisp.

Function: zero-page-address (addr env)

Returns whether the address is a zero page access.

Package

6502.

Source

assemble.lisp.


5.2.5 Generic functions

Generic Reader: line (condition)
Package

6502.

Methods
Reader Method: line ((condition invalid-syntax))
Source

conditions.lisp.

Target Slot

line.

Generic Reader: mode (condition)
Package

6502.

Methods
Reader Method: mode ((condition invalid-mode))
Source

conditions.lisp.

Target Slot

mode.

Generic Reader: opcode (condition)
Package

6502.

Methods
Reader Method: opcode ((condition illegal-opcode))
Source

conditions.lisp.

Target Slot

opcode.


5.2.6 Conditions

Condition: illegal-opcode

Illegal opcodes are not currently implemented.

Package

6502.

Source

conditions.lisp.

Direct superclasses

condition.

Direct methods

opcode.

Direct slots
Slot: opcode
Initargs

:opcode

Readers

opcode.

Writers

This slot is read-only.

Condition: invalid-mode

Only the 6502 addressing modes have readers and printers.

Package

6502.

Source

conditions.lisp.

Direct superclasses

condition.

Direct methods

mode.

Direct slots
Slot: mode
Initargs

:mode

Readers

mode.

Writers

This slot is read-only.

Condition: invalid-syntax

Assembly must conform to the syntax in the README.

Package

6502.

Source

conditions.lisp.

Direct superclasses

condition.

Direct methods

line.

Direct slots
Slot: line
Initargs

:line

Readers

line.

Writers

This slot is read-only.


5.2.7 Structures

Structure: instruction

Represents a single line of code.

Package

6502.

Source

assemble.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: label
Type

(or null string)

Readers

instruction-label.

Writers

(setf instruction-label).

Slot: opcode
Type

(or null symbol)

Readers

instruction-opcode.

Writers

(setf instruction-opcode).

Slot: address-mode
Type

(or null symbol list)

Readers

instruction-address-mode.

Writers

(setf instruction-address-mode).

Slot: value
Type

(or null |6502|:u16 list string)

Readers

instruction-value.

Writers

(setf instruction-value).


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   %   (  
A   B   C   D   E   F   G   I   J   L   M   N   O   P   R   S   T   W   Z  
Index Entry  Section

%
%status-bit: Private ordinary functions

(
(setf absolute): Public ordinary functions
(setf absolute-x): Public ordinary functions
(setf absolute-y): Public ordinary functions
(setf accumulator): Public ordinary functions
(setf cpu-ar): Public ordinary functions
(setf cpu-cc): Public ordinary functions
(setf cpu-pc): Public ordinary functions
(setf cpu-sp): Public ordinary functions
(setf cpu-sr): Public ordinary functions
(setf cpu-xr): Public ordinary functions
(setf cpu-yr): Public ordinary functions
(setf get-byte): Public ordinary functions
(setf get-range): Public ordinary functions
(setf get-word): Public ordinary functions
(setf immediate): Public ordinary functions
(setf implied): Public ordinary functions
(setf indirect): Public ordinary functions
(setf indirect-x): Public ordinary functions
(setf indirect-y): Public ordinary functions
(setf instruction-address-mode): Private ordinary functions
(setf instruction-label): Private ordinary functions
(setf instruction-opcode): Private ordinary functions
(setf instruction-value): Private ordinary functions
(setf relative): Public ordinary functions
(setf zero-page): Public ordinary functions
(setf zero-page-x): Public ordinary functions
(setf zero-page-y): Public ordinary functions

A
absolute: Public ordinary functions
absolute-x: Public ordinary functions
absolute-y: Public ordinary functions
accumulator: Public ordinary functions
app-path: Public ordinary functions
arg-formatter: Private ordinary functions
asm: Public generic functions
asm: Public generic functions
asm: Public generic functions
assemble-code-block: Private ordinary functions
assemble-instruction: Private ordinary functions

B
branch-if: Private macros
bytes-to-keyword-syntax: Private ordinary functions
bytevector: Public ordinary functions

C
copy-cpu: Private ordinary functions
copy-instruction: Private ordinary functions
cpu-ar: Public ordinary functions
cpu-cc: Public ordinary functions
cpu-p: Private ordinary functions
cpu-pc: Public ordinary functions
cpu-sp: Public ordinary functions
cpu-sr: Public ordinary functions
cpu-xr: Public ordinary functions
cpu-yr: Public ordinary functions
current-instruction: Public ordinary functions

D
decide-address-mode: Private ordinary functions
defaddress: Private macros
defasm: Private macros
defenum: Public macros
disasm: Public ordinary functions
disasm-ins: Private ordinary functions
disasm-to-list: Public ordinary functions
disasm-to-str: Public ordinary functions

E
execute: Public ordinary functions

F
fetch-expression: Private ordinary functions
fetch-label: Private ordinary functions
fetch-literal: Private ordinary functions
fetch-name: Private ordinary functions
fetch-opcode: Private ordinary functions
fetch-operand: Private ordinary functions
fetch-term: Private ordinary functions
find-opcode: Private ordinary functions
Function, %status-bit: Private ordinary functions
Function, (setf absolute): Public ordinary functions
Function, (setf absolute-x): Public ordinary functions
Function, (setf absolute-y): Public ordinary functions
Function, (setf accumulator): Public ordinary functions
Function, (setf cpu-ar): Public ordinary functions
Function, (setf cpu-cc): Public ordinary functions
Function, (setf cpu-pc): Public ordinary functions
Function, (setf cpu-sp): Public ordinary functions
Function, (setf cpu-sr): Public ordinary functions
Function, (setf cpu-xr): Public ordinary functions
Function, (setf cpu-yr): Public ordinary functions
Function, (setf get-byte): Public ordinary functions
Function, (setf get-range): Public ordinary functions
Function, (setf get-word): Public ordinary functions
Function, (setf immediate): Public ordinary functions
Function, (setf implied): Public ordinary functions
Function, (setf indirect): Public ordinary functions
Function, (setf indirect-x): Public ordinary functions
Function, (setf indirect-y): Public ordinary functions
Function, (setf instruction-address-mode): Private ordinary functions
Function, (setf instruction-label): Private ordinary functions
Function, (setf instruction-opcode): Private ordinary functions
Function, (setf instruction-value): Private ordinary functions
Function, (setf relative): Public ordinary functions
Function, (setf zero-page): Public ordinary functions
Function, (setf zero-page-x): Public ordinary functions
Function, (setf zero-page-y): Public ordinary functions
Function, absolute: Public ordinary functions
Function, absolute-x: Public ordinary functions
Function, absolute-y: Public ordinary functions
Function, accumulator: Public ordinary functions
Function, app-path: Public ordinary functions
Function, arg-formatter: Private ordinary functions
Function, assemble-code-block: Private ordinary functions
Function, assemble-instruction: Private ordinary functions
Function, bytes-to-keyword-syntax: Private ordinary functions
Function, bytevector: Public ordinary functions
Function, copy-cpu: Private ordinary functions
Function, copy-instruction: Private ordinary functions
Function, cpu-ar: Public ordinary functions
Function, cpu-cc: Public ordinary functions
Function, cpu-p: Private ordinary functions
Function, cpu-pc: Public ordinary functions
Function, cpu-sp: Public ordinary functions
Function, cpu-sr: Public ordinary functions
Function, cpu-xr: Public ordinary functions
Function, cpu-yr: Public ordinary functions
Function, current-instruction: Public ordinary functions
Function, decide-address-mode: Private ordinary functions
Function, disasm: Public ordinary functions
Function, disasm-ins: Private ordinary functions
Function, disasm-to-list: Public ordinary functions
Function, disasm-to-str: Public ordinary functions
Function, execute: Public ordinary functions
Function, fetch-expression: Private ordinary functions
Function, fetch-label: Private ordinary functions
Function, fetch-literal: Private ordinary functions
Function, fetch-name: Private ordinary functions
Function, fetch-opcode: Private ordinary functions
Function, fetch-operand: Private ordinary functions
Function, fetch-term: Private ordinary functions
Function, find-opcode: Private ordinary functions
Function, get-basic-block: Private ordinary functions
Function, get-byte: Public ordinary functions
Function, get-opcode-address-modes: Private ordinary functions
Function, get-range: Public ordinary functions
Function, get-word: Public ordinary functions
Function, immediate: Public ordinary functions
Function, implied: Public ordinary functions
Function, indirect: Public ordinary functions
Function, indirect-x: Public ordinary functions
Function, indirect-y: Public ordinary functions
Function, instruction-address-mode: Private ordinary functions
Function, instruction-label: Private ordinary functions
Function, instruction-opcode: Private ordinary functions
Function, instruction-p: Private ordinary functions
Function, instruction-value: Private ordinary functions
Function, jit-block: Private ordinary functions
Function, jit-step: Public ordinary functions
Function, list-to-instructions: Private ordinary functions
Function, make-and-resolve-byte: Private ordinary functions
Function, make-byte: Private ordinary functions
Function, make-cpu: Public ordinary functions
Function, make-getter: Private ordinary functions
Function, make-instruction: Private ordinary functions
Function, make-stream: Private ordinary functions
Function, match-opcode-data: Private ordinary functions
Function, match-operand-address-modes: Private ordinary functions
Function, maybe-update-cycle-count: Private ordinary functions
Function, operand-possible-modes-and-value: Private ordinary functions
Function, overflow-p: Private ordinary functions
Function, parse-code: Private ordinary functions
Function, parse-line: Private ordinary functions
Function, print-instruction: Private ordinary functions
Function, process-args: Private ordinary functions
Function, relative: Public ordinary functions
Function, rotate-byte: Private ordinary functions
Function, sexpify-instruction: Private ordinary functions
Function, skip-white-space: Private ordinary functions
Function, stack-pop: Private ordinary functions
Function, stack-pop-word: Private ordinary functions
Function, stack-push: Private ordinary functions
Function, stack-push-word: Private ordinary functions
Function, step-cpu: Public ordinary functions
Function, strip-comment: Private ordinary functions
Function, substream-advance: Private ordinary functions
Function, transform-sexp-syntax: Private ordinary functions
Function, try-fetch: Private ordinary functions
Function, tuple-to-instruction: Private ordinary functions
Function, wrap-byte: Public ordinary functions
Function, wrap-page: Private ordinary functions
Function, wrap-word: Public ordinary functions
Function, zero-page: Public ordinary functions
Function, zero-page-address: Private ordinary functions
Function, zero-page-x: Public ordinary functions
Function, zero-page-y: Public ordinary functions

G
Generic Function, asm: Public generic functions
Generic Function, line: Private generic functions
Generic Function, mode: Private generic functions
Generic Function, nmi: Public generic functions
Generic Function, opcode: Private generic functions
Generic Function, reader: Public generic functions
Generic Function, reset: Public generic functions
Generic Function, writer: Public generic functions
get-basic-block: Private ordinary functions
get-byte: Public ordinary functions
get-opcode-address-modes: Private ordinary functions
get-range: Public ordinary functions
get-word: Public ordinary functions

I
immediate: Public ordinary functions
implied: Public ordinary functions
indirect: Public ordinary functions
indirect-x: Public ordinary functions
indirect-y: Public ordinary functions
initialize-instance: Public standalone methods
instruction-address-mode: Private ordinary functions
instruction-label: Private ordinary functions
instruction-opcode: Private ordinary functions
instruction-p: Private ordinary functions
instruction-value: Private ordinary functions

J
jit-block: Private ordinary functions
jit-step: Public ordinary functions

L
line: Private generic functions
line: Private generic functions
list-to-instructions: Private ordinary functions

M
Macro, branch-if: Private macros
Macro, defaddress: Private macros
Macro, defasm: Private macros
Macro, defenum: Public macros
Macro, resolve-byte: Private macros
Macro, set-flags-if: Private macros
Macro, set-status-bit: Private macros
Macro, status-bit: Public macros
Macro, with-disasm: Private macros
make-and-resolve-byte: Private ordinary functions
make-byte: Private ordinary functions
make-cpu: Public ordinary functions
make-getter: Private ordinary functions
make-instruction: Private ordinary functions
make-stream: Private ordinary functions
match-opcode-data: Private ordinary functions
match-operand-address-modes: Private ordinary functions
maybe-update-cycle-count: Private ordinary functions
Method, asm: Public generic functions
Method, asm: Public generic functions
Method, initialize-instance: Public standalone methods
Method, line: Private generic functions
Method, mode: Private generic functions
Method, nmi: Public generic functions
Method, opcode: Private generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reader: Public generic functions
Method, reset: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
Method, writer: Public generic functions
mode: Private generic functions
mode: Private generic functions

N
nmi: Public generic functions
nmi: Public generic functions

O
opcode: Private generic functions
opcode: Private generic functions
operand-possible-modes-and-value: Private ordinary functions
overflow-p: Private ordinary functions

P
parse-code: Private ordinary functions
parse-line: Private ordinary functions
print-instruction: Private ordinary functions
process-args: Private ordinary functions

R
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
reader: Public generic functions
relative: Public ordinary functions
reset: Public generic functions
reset: Public generic functions
resolve-byte: Private macros
rotate-byte: Private ordinary functions

S
set-flags-if: Private macros
set-status-bit: Private macros
sexpify-instruction: Private ordinary functions
skip-white-space: Private ordinary functions
stack-pop: Private ordinary functions
stack-pop-word: Private ordinary functions
stack-push: Private ordinary functions
stack-push-word: Private ordinary functions
status-bit: Public macros
step-cpu: Public ordinary functions
strip-comment: Private ordinary functions
substream-advance: Private ordinary functions

T
transform-sexp-syntax: Private ordinary functions
try-fetch: Private ordinary functions
tuple-to-instruction: Private ordinary functions

W
with-disasm: Private macros
wrap-byte: Public ordinary functions
wrap-page: Private ordinary functions
wrap-word: Public ordinary functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions
writer: Public generic functions

Z
zero-page: Public ordinary functions
zero-page-address: Private ordinary functions
zero-page-x: Public ordinary functions
zero-page-y: Public ordinary functions


A.3 Variables

Jump to:   *   +  
A   C   L   M   O   P   S   V   X   Y  
Index Entry  Section

*
*address-modes*: Private special variables
*basedir*: Private special variables
*cpu*: Public special variables
*jit-cache*: Private special variables
*opcode-funs*: Private special variables
*opcode-meta*: Public special variables
*ram*: Private special variables

+
+absolute-modes+: Private special variables
+max-byte+: Private constants
+relative-branch-size-byte+: Private constants
+zero-page-modes+: Private special variables

A
address-mode: Private structures
ar: Public structures

C
cc: Public structures
Constant, +max-byte+: Private constants
Constant, +relative-branch-size-byte+: Private constants

L
label: Private structures
line: Private conditions

M
mode: Private conditions

O
opcode: Private conditions
opcode: Private structures

P
pc: Public structures

S
Slot, address-mode: Private structures
Slot, ar: Public structures
Slot, cc: Public structures
Slot, label: Private structures
Slot, line: Private conditions
Slot, mode: Private conditions
Slot, opcode: Private conditions
Slot, opcode: Private structures
Slot, pc: Public structures
Slot, sp: Public structures
Slot, sr: Public structures
Slot, value: Private structures
Slot, xr: Public structures
Slot, yr: Public structures
sp: Public structures
Special Variable, *address-modes*: Private special variables
Special Variable, *basedir*: Private special variables
Special Variable, *cpu*: Public special variables
Special Variable, *jit-cache*: Private special variables
Special Variable, *opcode-funs*: Private special variables
Special Variable, *opcode-meta*: Public special variables
Special Variable, *ram*: Private special variables
Special Variable, +absolute-modes+: Private special variables
Special Variable, +zero-page-modes+: Private special variables
sr: Public structures

V
value: Private structures

X
xr: Public structures

Y
yr: Public structures


A.4 Data types

Jump to:   6  
A   C   D   F   I   J   O   P   S   T   U  
Index Entry  Section

6
6502: The 6502 package
6502-conf: The 6502-conf package

A
addressing.lisp: The cl-6502/addressing․lisp file
assemble.lisp: The cl-6502/assemble․lisp file

C
cl-6502: The cl-6502 system
cl-6502: The cl-6502 package
cl-6502.asd: The cl-6502/cl-6502․asd file
Condition, illegal-opcode: Private conditions
Condition, invalid-mode: Private conditions
Condition, invalid-syntax: Private conditions
conditions.lisp: The cl-6502/conditions․lisp file
cpu: Public structures
cpu.lisp: The cl-6502/cpu․lisp file

D
disassemble.lisp: The cl-6502/disassemble․lisp file

F
File, addressing.lisp: The cl-6502/addressing․lisp file
File, assemble.lisp: The cl-6502/assemble․lisp file
File, cl-6502.asd: The cl-6502/cl-6502․asd file
File, conditions.lisp: The cl-6502/conditions․lisp file
File, cpu.lisp: The cl-6502/cpu․lisp file
File, disassemble.lisp: The cl-6502/disassemble․lisp file
File, jit.lisp: The cl-6502/jit․lisp file
File, opcodes.lisp: The cl-6502/opcodes․lisp file
File, packages.lisp: The cl-6502/packages․lisp file
File, parser.lisp: The cl-6502/parser․lisp file
File, utils.lisp: The cl-6502/utils․lisp file

I
illegal-opcode: Private conditions
instruction: Private structures
invalid-mode: Private conditions
invalid-syntax: Private conditions

J
jit.lisp: The cl-6502/jit․lisp file

O
opcodes.lisp: The cl-6502/opcodes․lisp file

P
Package, 6502: The 6502 package
Package, 6502-conf: The 6502-conf package
Package, cl-6502: The cl-6502 package
packages.lisp: The cl-6502/packages․lisp file
parser.lisp: The cl-6502/parser․lisp file

S
Structure, cpu: Public structures
Structure, instruction: Private structures
System, cl-6502: The cl-6502 system

T
Type, u16: Public types
Type, u8: Public types

U
u16: Public types
u8: Public types
utils.lisp: The cl-6502/utils․lisp file