6502 Emulator

Emulator

Notes:Controls:* Assemble - Assembles (compiles) the source code in the text box into6502 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. Thisbutton 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 defaultinstruction 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 assembledcode, in hexadecimal format.* Disasseble - Display a hexdump plus a disassembly of the memory contentsfrom $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 hasprobably 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 bottomof 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 theright, 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 placethe 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 handside).* 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 thesystem 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=leftPage $01: 6502 stack (downward)Pages $02-05: bitmapped displayPages $06-$ef: your code and dataPages $f0-$f7: character displayPages $f8-$fd: reserved for future ROM expansionPages $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 anopaque string.*=address - changes assembler pointer to given addresslabel: - defines an address label. Reference the label in yourcode without the colon. Labels can be used with the 'Jump To' button in thedebugger.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 thecolour 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 greyCharacter 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 codesshow 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/left/down) 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 locationTo use these routines, these define directives may be pasted into your code:; ROM routinesdefine SCINIT $ff81 ; initialize/clear screendefine CHRIN $ffcf ; input character from keyboarddefine CHROUT $ffd2 ; output character to screendefine SCREEN $ffed ; get screen sizedefine PLOT $fff0 ; get/set cursor coordinatesSpeed 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 anactual 6502 chip; when set rully right, the emulator operates close tothe 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 athttp://www.6502.org/tutorials/6502opcodes.htmlAnother reference with flag information:https://www.masswerk.at/6502/6502_instruction_set.htmlExample code which will run in this emulator:https://wiki.cdot.senecacollege.ca/wiki/6502_Emulator_Example_CodeMore examples, plus the ROM source code:https://github.com/ctyler/6502js-codeSource code for this emulator:https://github.com/ctyler/6502js
6502 Emulator

6502 Emulator For Windows 10

I'm making a 6502 emulator and I'm stuck (or I think I am at least) already at the beginning (implementing the ADC operation). The problem is that I have to determine if there's a carry or an overflow. The thing is, I can't really grasp the difference between them in my implementation. MOS6502 Emulator in C. This is my C implementation of the MOS Technology 6502 CPU. The code is written to be more readable than fast, however some minor tricks have been introduced to greatly reduce the overall execution time. Main features: 100% coverage of legal opcodes. Decimal mode implemented.

Comments are closed.