Difference between revisions of "6502 Emulator"
Chris Tyler (talk | contribs) (→Peripherals) |
Chris Tyler (talk | contribs) (→Peripherals) |
||
Line 23: | Line 23: | ||
The checkbox labeled "Text Screen" can be used to hide the character display to free up more space for editing code. | The checkbox labeled "Text Screen" can be used to hide the character display to free up more space for editing code. | ||
− | == Peripherals == | + | == Peripherals and Memory Map == |
+ | The entire 64K address space is available and is populated with RAM except for peripherals. | ||
+ | |||
There are four peripherals available: | There are four peripherals available: | ||
− | * a one-byte pseudo-random number generator (''PRNG'') at $fe | + | * a one-byte pseudo-random number generator (''PRNG'') at '''$fe'''. |
− | * a single-key buffer $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 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 lowest four bits of each byte select one of 16 colours. |
− | * an 80x25 character display at $f000-$7cff, with one byte per pixel. 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;"> reverse video </span>. | + | * an 80x25 character display at '''$f000-$7cff''', with one byte per pixel. 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;"> reverse video </span>. |
+ | |||
+ | The <code>Reset</code> button clears the zero page, bitmap display, and character display, and resets the stack pointer (SP=$ff), program counter (PC=$0600), status register (P=$30), and the general purpose registers (A=X=Y=$00). | ||
+ | |||
+ | Code is assembled starting at $0600 (unless the code changes the location with a <code>*=''address''</code> directive). Memory following the program is reset to $00. A <code>BRK</code> instruction ($00) will cause the program to stop and return control to the debugger. | ||
For more details, press the <code>Notes</code> button in the emulator. | For more details, press the <code>Notes</code> button in the emulator. |
Revision as of 10:33, 11 January 2020
A simple web-based 6502 emulator is available at http://6502.cdot.systems
Contents
Basic Controls
The emulator has a text area for data entry, a small bit-mapped screen (32x32 pixels), a character screen (80x25 characters), a debug area, a memory monitor, and a message area.
These controls are available at the top of the screen:
- Assemble - assembles the code in the text area, placing the resulting binary machine language at $0600 and outputting any error messasges to the message area.
- Run - runs the assembled code, if it assembled correctly. While the code is running, this button becomes a Stop button.
- Reset - changes the PC to $0600, clears the bitmap and character displays, and clears the stack and zero page.
- Hexdump - shows the hexadecimal values in memory starting at $0600
- Disassemble - shows a combined hexdump and disassembly of code at $0600
- Notes - displays notes about the emulator in the message area.
Using the Debugger
The debugger will constantly show the value of the emulated 6502's registers. If you select the Debugger checkbox, you will be able to single-step through memory or jump to an address or label using the associated pushbuttons.
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 $ff will display the entire zero page.
Turning the Text Screen On/Off
The checkbox labeled "Text Screen" can be used to hide the character display to free up more space for editing code.
Peripherals and Memory Map
The entire 64K address space is available and is populated with RAM except for peripherals.
There are four peripherals available:
- 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 32x32 pixel bitmapped display at $0200-$05ff, with one byte per pixel. The lowest four bits of each byte select one of 16 colours.
- an 80x25 character display at $f000-$7cff, with one byte per pixel. Printable ASCII characters will be displayed. If the high-order bit is set, the character will be shown in reverse video .
The Reset
button clears the zero page, bitmap display, and character display, and resets the stack pointer (SP=$ff), program counter (PC=$0600), status register (P=$30), and the general purpose registers (A=X=Y=$00).
Code is assembled starting at $0600 (unless the code changes the location with a *=address
directive). Memory following the program is reset to $00. A BRK
instruction ($00) will cause the program to stop and return control to the debugger.
For more details, press the Notes
button in the emulator.
Example Code
See the 6502 Emulator Example Code page.