User Tools

Site Tools


spo600:6502_emulator

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
spo600:6502_emulator [2024/05/07 16:55] chrisspo600:6502_emulator [2025/04/09 21:14] (current) chris
Line 1: Line 1:
 ====== 6502 Emulator ====== ====== 6502 Emulator ======
  
-A simple web-based [[6502]] emulator is available at [[https://6502.cdot.systems]]. 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. On other systemsthis may be designated by a ''0x'' prefix.+In most 6502 documentation, including this page, the ''$'' prefix indicates hexadecimal notation. (Note that in some other contextshexadecimal is indicated by a ''0x'' prefix or an ''h'' suffix).
  
 =====  Basic Controls  ===== =====  Basic Controls  =====
Line 33: Line 33:
   *  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 &lt;X and the high byte can be accessed as &gt;X. For example, this code will load the low byte of the label "start" into the A register: ''LDA #&lt;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:
  
Line 58: Line 58:
  
 =====  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 moreinstructions.
 =====  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.
Line 79: Line 78:
   *  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
Line 96: Line 95:
     *  $e: Light blue     *  $e: Light blue
     *  $f: Light grey     *  $f: Light grey
-  *  an 80x25 character display at **$f000-$fcff**, with one byte per character. Printable ASCII characters will be displayed. If the high-order bit is set, the character will be shown in <span style="background: black; color: white;">&nbsp;reverse video&nbsp;</font>.+  *  an 80x25 character display at **$f000-$fcff**, with one byte per character. Printable ASCII characters will be displayed. If the high-order bit is set, the character will be shown in reverse video.
   *  a read-only ROM chip is present at **$fe00-$ffff**; see below for details.   *  a read-only ROM chip is present at **$fe00-$ffff**; see below for details.
  
Line 111: Line 110:
   *  SCINIT $ff81 - Initialize and clear the character display   *  SCINIT $ff81 - Initialize and clear the character display
   *  CHRIN $ffcf - Input one character from keyboard (returns A (that is, the return value will be placed in the Accumulator register))   *  CHRIN $ffcf - Input one character from keyboard (returns A (that is, the return value will be placed in the Accumulator register))
-  *  CHROUT $ffdw - Outputs one character (A) to the screen at the current cursor position. Screen will wrap/scroll appropriately. Printable characters and cursor codes ($80/$81/$82/$83 for up/right/left/down) as well as RETURN ($0d) are accepted. Printable ASCII codes with the high bit set will be printed in reverse video.+  *  CHROUT $ffdw - Outputs one character (A) to the screen at the current cursor position. Screen will wrap/scroll appropriately. Printable characters and cursor codes ($80/$81/$82/$83 for up/right/down/left) as well as RETURN ($0d) are accepted. Printable ASCII codes with the high bit set will be printed in reverse video.
   *  SCREEN $ffed - Returns the character screen size in the X and Y registers.   *  SCREEN $ffed - Returns the character screen size in the X and Y registers.
   *  PLOT $fff0 - gets (CARRY=1) or sets (CARRY=0) the cursor position   *  PLOT $fff0 - gets (CARRY=1) or sets (CARRY=0) the cursor position
Line 146: Line 145:
  
 =====  Source Code  ===== =====  Source Code  =====
-The emulator's source code can be found at https:<nowiki>//</nowiki>github.com/ctyler/6502js ... Pull Requests are welcome.+The emulator's source code can be found at https://github.com/ctyler/6502js ... Pull Requests are welcome.
  
spo600/6502_emulator.1715100925.txt.gz · Last modified: 2024/05/07 20:55 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki