Coder Social home page Coder Social logo

1parmsingh / 6502_assembly_simulator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wynand1004/6502_assembly_simulator

0.0 0.0 0.0 52 KB

A Simple 6502 CPU Simulator for students to use to learn Assembly Language

License: GNU General Public License v3.0

Python 100.00%

6502_assembly_simulator's Introduction

6502_Assembly_Simulator

A Simple Simulator for students to use to learn 6502 Assembly Language.

It is a work in progress and nowhere near complete but the basic structure is there. See below to see which commands have been implemented thus far.

Implementation Details

The program is a simulation of an 8-bit computer running a 6502 CPU. There is a 32x24 graphics display capable of displaying 16 colors, and a 40x5 text display. Graphics memory starts from 1024 ($0400), and text memory starts at 2048 ($0800). Execution begins at 4096 ($1000). The text display displays standard ASCII characters - no unicode or double-byte characters.

Color List:

0 black

1 white

2 red

3 cyan

4 purple

5 green

6 blue

7 yellow

8 orange

9 brown

10 pink

11 darkgrey

12 grey

13 lightgreen

14 lightblue

15 lightgrey

Currently, there is no assembler to convert the assembly code to machine code (although this feature is planned). Code must be added manually to the simulator.py file.

Here is the current sample code:

memory[4096] = 0xa9 # LDA #0x01

memory[4097] = 0x02

memory[4098] = 0x8d # STA 0x400

memory[4099] = 0x00

memory[4100] = 0x04

memory[4101] = 0xee # INC 0x1003 (4099)

memory[4102] = 0x03

memory[4103] = 0x10

memory[4104] = 0xaa # TAX

memory[4105] = 0xe8 # INX

memory[4106] = 0x8a # TXA

memory[4107] = 0xc9 # CMP #0x0f

memory[4108] = 0x0f

memory[4109] = 0xd0 # BNE (Jump ahead back 13 memory locations from start of next instruction)

memory[4110] = 0xf3

memory[4111] = 0xea # NOP NOP NOP

memory[4112] = 0xea

memory[4113] = 0xea

memory[4114] = 0xa9 # LDA #0x01

memory[4115] = 0x01

memory[4116] = 0xea # NOP

memory[4117] = 0x4c # JMP 0x1002 (4097)

memory[4118] = 0x02

memory[4119] = 0x10

Implemented Instructions

LDA (Immediate)

STA (Absolute)

LDX (Immediate)

STX (Absolute)

INC (Absolute)

INX

INY

JMP (Absolute)

TAX

TXA

DEX

TAY

TYA

DEY

CLC

SEC

CLI

SEI

CLV

CLD

SED

NOP

CMP (Immediate)

BEQ

BNE

To Try It Out

  • Download the repository and run simulator.py using Python 2 or Python 3
  • You should see a number of different colored pixels (squares) appear row by row in the top half of the display.

Known Issues

  • For some reason, the display can freeze on Mac. This is a known bug in tkinter on the Mac. Interestingly, it occurs when the background of the tkinter canvas is black along with the rectangles used as "pixels". Changing the pixel color to all white, or all green, for example seems to alleviate the issue.

6502_assembly_simulator's People

Contributors

wynand1004 avatar 18melissa40 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.