Both sides previous revisionPrevious revisionNext revision | Previous revision |
spo600:6502_emulator [2025/01/27 16:16] – [6502 Emulator] chris | spo600:6502_emulator [2025/04/09 21:14] (current) – chris |
---|
====== 6502 Emulator ====== | ====== 6502 Emulator ====== |
| |
A simple web-based [[6502]] emulator is available at [[http://6502.cdot.systems]] (note that this is an http link, not an https link). This emulator is used in the [[start|SPO600]] course to teach 8-bit [[Assembly Language|assembly language]] before transitioning to more complex 64-bit x86_64 and [[ARMv8#AArch64]] assembly language. | A simple web-based [[6502]] emulator is available at [[http://6502.proximity.on.ca]] (note that this is an http link, not an https link). This emulator is used in the [[start|SPO600]] course to teach 8-bit [[Assembly Language|assembly language]] before transitioning to more complex 64-bit x86_64 and [[ARMv8#AArch64]] assembly language. |
| |
In most 6502 documentation, including this page, the ''$'' prefix indicates hexadecimal notation. (Note that in some other contexts, hexadecimal is indicated by a ''0x'' prefix or an ''h'' suffix). | In most 6502 documentation, including this page, the ''$'' prefix indicates hexadecimal notation. (Note that in some other contexts, hexadecimal is indicated by a ''0x'' prefix or an ''h'' suffix). |
* Origin assignment: You can tell the assembler where to assemble the following code with this syntax: ''*=$XXXX'' where XXXX is an address in hexadecimal. Multiple origin assignments may be used. Example: ''*=$1800'' | * Origin assignment: You can tell the assembler where to assemble the following code with this syntax: ''*=$XXXX'' where XXXX is an address in hexadecimal. Multiple origin assignments may be used. Example: ''*=$1800'' |
* "define" directive: Macro assignments may be created with the "define" directive: ''define macro value'' -- for example: ''define WHITE $01'' -- the macro value will be substituted into lines wherever the macro name appears (e.g., ''LDA #WHITE''). | * "define" directive: Macro assignments may be created with the "define" directive: ''define macro value'' -- for example: ''define WHITE $01'' -- the macro value will be substituted into lines wherever the macro name appears (e.g., ''LDA #WHITE''). |
* "dcb" directive: the Define Constant Byte (dcb) directive will cause the assembler to place individual byte values into memory. These byte values may be in hexadecimal prefixed with $, decimal with no prefix, or single printable non-space characters quoted with double quotes. | * "dcb" directive: the Define Constant Byte (dcb) directive will cause the assembler to place individual byte values into memory. These byte values may be in hexadecimal prefixed with $, decimal with no prefix, or single printable non-space characters quoted with double quotes. A label may be placed in front of a dcb directive. |
| |
==== High and Low Label Bytes ==== | ==== High and Low Label Bytes ==== |
* The low byte of the label X can be accessed as <X and the high byte can be accessed as >X. For example, this code will load the low byte of the label "start" into the A register: ''LDA #<START'' - note that this only works with labels, and not with macros. | * The low byte of the label X can be accessed as <X and the high byte can be accessed as >X. For example, this code will load the low byte of the label "start" into the A register: ''LDA #<START'' - note that this only works with labels, and not with macros. |
* You can use labels and origin assignment together to get a label for any address in the system. For example, to get a label pointing to the first byte of the character display, you could place this at the end of your program: | * You can use labels and origin assignment together to get a label for any address in the system. For example, to get a label pointing to the first byte of the character display, you could place this at the end of your program: |
| |
| |
===== Using the Monitor ===== | ===== Using the Monitor ===== |
Selecting the Monitor checkbox will display the specified region of memory as code is executed. For example, specifying a start of $00 and a length of $100 will display the entire zero page. Once enabled, the monitor may not display until the code is executed (via Run button). | Selecting the Monitor checkbox will display the specified region of memory as code is executed. For example, specifying a start of $00 and a length of $100 will display the entire zero page. The monitor display is updated with after each execution of one (or more) instructions. |
===== Turning the Text Screen On/Off ===== | ===== Turning the Text Screen On/Off ===== |
The checkbox labeled "Text Screen" can be used to hide the character display to free up more screen space for editing code. Note also that the character display can be used for additional program memory (whether the display is enabled or not) when it's not required for output. | The checkbox labeled "Text Screen" can be used to hide the character display to free up more screen space for editing code. Note also that the character display can be used for additional program memory (whether the display is enabled or not) when it's not required for output. |
* a one-byte pseudo-random number generator (//PRNG//) at **$fe**. | * a one-byte pseudo-random number generator (//PRNG//) at **$fe**. |
* a single-key buffer at **$ff** - if you write to this address, it will remain unchanged until a new keypress is received. Printable characters plus Return/Enter and Backspace are reported as ASCII codes; cursor keys are reported as $80=up, $81=right, $82=down, $83=left. | * a single-key buffer at **$ff** - if you write to this address, it will remain unchanged until a new keypress is received. Printable characters plus Return/Enter and Backspace are reported as ASCII codes; cursor keys are reported as $80=up, $81=right, $82=down, $83=left. |
* a 32x32 pixel bitmapped display at **$0200-$05ff**, with one byte per pixel. The upper-left pixel is at address $0200, the pixel to the right is $0201, and the first pixel on the second row is $0220. A [[https://docs.google.com/spreadsheets/d/1a1-ZZ1opY8xcuUHNxj3YW75dxOPynSuP2-QGSvZGzYY/edit?usp=sharing|reference spreadsheet]] shows the row/column to address mapping. The lowest four bits of each byte select one of 16 colours. | * a 32x32 pixel bitmapped display at **$0200-$05ff**, with one byte per pixel. The upper-left pixel is at address $0200, the pixel to the right is $0201, and the first pixel on the second row is $0220. A [[https://docs.google.com/spreadsheets/d/1a1-ZZ1opY8xcuUHNxj3YW75dxOPynSuP2-QGSvZGzYY/edit?usp=sharing|reference spreadsheet]] shows the row/column to address mapping. The lowest four bits of each byte select one of 16 colours from a preset palette: |
* $0: Black | * $0: Black |
* $1: White | * $1: White |