Notes:
Controls:
* Assemble - Assembles (compiles) the source code in the text box into
6502 object code at address $0600. Also performs a Reset. Any error
messages appear in the info box at the bottom of the page.
* Run/Stop - Runs (executes) or stops execution of the 6502 code. This
button will be disabled when unassembled code exists in the text box
(for example, if you add code, or if the code doesn't assemble correctly).
Code stops executing when a BRK instruction is hit (which is the default
instruction following your assembled code).
* Reset - Rests registers, sets the PC to $0600, and clears the zero page,
stack, and displays.
* Hexdump - Displays memory contents from $0600 to the end of the assembled
code, in hexadecimal format.
* Disasseble - Display a hexdump plus a disassembly of the memory contents
from $0600 to the end of the assembled code. Note: if the disassembled
code does not match your source code after a Run, then your code has
probably overwritten memory page $06 (and later) -- which is easy to do
since this page immediately follows the bitmapped display.
* Notes - Displays this information text in the info box at the bottom
of the page.
* Speed - Sets the speed of execution in instructions per display frame.
Set to the left, the speed will be approximately 1% of a 1MHz 6502; on the
right, it will be about 100% (or just over).
* Save - Downloads the source code in the text box to your local machine.
This is an easy way to make backup copies of evolving code, or to place
the code in a file under version control.
* Load - Loads the specified file from the local machine into the text box.
This is an alternative to cutting and pasting code into the emulator.
* Monitor - Displays the memory region starting at "Start" and running
for "Length" bytes.
* Text screen - Enables and disables the text display (on the right hand
side).
* Debugger - Turns on single-stepping controls.
* Step - Executes a single instruction.
* Jump to... - Jumps to the specified address or label.
Memory map:
All 64K ($0000-$ffff) is populated with RAM and available. This is the
system memory map:
Page $00: 6502 zero page, used for variables and pointers
Two locations in the zero page are connected to devices:
* Memory location $fe contains a new random byte on every read.
* Memory location $ff contains the ascii code of the last key pressed.
Values written to $ff will remain unchanged until next key press.
Printable keys have their ASCII value; BackSpace is $08; Enter is $0d;
Cursor controls are $80=up, $81=right, $82=down, $83=left
Page $01: 6502 stack (downward)
Pages $02-05: bitmapped display
Pages $06-$ef: your code and data
Pages $f0-$f7: character display
Pages $f8-$fd: reserved for future ROM expansion
Pages $fe-$ff: ROM code (see below)
Available Assembler Directives:
dcb
value[,
value [...]] - (define constant byte) used to create
constants in memory. Multiple bytes are separated by commas. Values
may be in decimal, hexadecimal, or single characters in double quotes
(except spaces - use 32 or $20 to represent a space).
define
macro value - defines a macro expression.
value must be an
opaque string.
*=
address - changes assembler pointer to given address
label: - defines an address label. Reference the label in your
code without the colon. Labels can be used with the "Jump To" button in the
debugger.
Bitmap Display:
The bitmapped display is 32x32 pixels, and memory locations $200 to
$5ff map to the screen pixels. The lowest four bits of each byte set the
colour of the corresponding pixel. The colours are:
$0: Black
$1: White
$2: Red
$3: Cyan
$4: Purple
$5: Green
$6: Blue
$7: Yellow
$8: Orange
$9: Brown
$a: Light red
$b: Dark grey
$c: Grey
$d: Light green
$e: Light blue
$f: Light grey
Character Display:
The character display is 80x25 characters in size, and memory locations
$f000-$f7cf contains the ASCII characters on the display (row-major).
Bit 7, if set, make a character appear in reverse video. Codes $21-$7e
(and corresponding codes with bit 7 set, $a1-$fe) display; all other codes
show up as blanks.
ROM Routines:
These routines are defined in ROM:
* SCINIT $ff81 - Initialize and clear the character display
* CHRIN $ffcf - Input one character from keyboard (returns A)
* 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.
* PLOT $fff0 - gets (CARRY=1) or sets (CARRY=0) the cursor position
If C=0: X,Y registers set the cursor position
Y:X is returned as a pointer to the current screen position
If C=1: X,Y registers return the current cursor position
A contains the character at the current cursor location
To use these routines, these define directives may be pasted into your code:
; ROM routines
define SCINIT $ff81 ; initialize/clear screen
define CHRIN $ffcf ; input character from keyboard
define CHROUT $ffd2 ; output character to screen
define SCREEN $ffed ; get screen size
define PLOT $fff0 ; get/set cursor coordinates
Speed Slider:
The Speed slider controls the number of opcodes executed per display frame.
When set fully left, the emulator operates at about 1% of the speed of an
actual 6502 chip; when set rully right, the emulator operates close to
the actual speed of a 1MHz 6502 chip (depending on the code). It is
recommended that the higher speeds be used with the ROM routines.
References:
A reference for the 6502 opcodes is available at
http://www.6502.org/tutorials/6502opcodes.html
Another reference with flag information:
https://www.masswerk.at/6502/6502_instruction_set.html
Example code which will run in this emulator:
https://wiki.cdot.senecacollege.ca/wiki/6502_Emulator_Example_Code
More examples, plus the ROM source code:
https://github.com/ctyler/6502js-code
Source code for this emulator:
https://github.com/ctyler/6502js
The emulator is licensed under the terms of the GPL v2.
The code-bedder library is licensed freely (see https://codebedder.com)
The prism.js library (https://prismjs.com) is licensed under the MIT license as follows:
MIT LICENSE
Copyright (c) 2012 Lea Verou
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.