A modern, browser-based 6502 assembler built with React and TypeScript. Write and assemble 6502 code in real-time with syntax highlighting, error reporting, and instant machine code generation.
- Real-time Assembly: Write 6502 assembly code and see machine code generated instantly
- Complete Instruction Set: Full support for all 6502 instructions and addressing modes
- Syntax Highlighting: Enhanced code editor with assembly syntax highlighting
- Error Reporting: Detailed error messages with line numbers and context
- Symbol Table: View labels and their resolved addresses
- Sample Programs: Built-in examples to get you started
- Modern Web Interface: Clean, responsive design that works on desktop and mobile
Try it live at: https://sokoide.github.io/6502-assembler/
This project implements a traditional two-pass assembler:
- Pass 1: Parse syntax, build symbol table, calculate addresses
- Pass 2: Resolve operands and generate final machine code
- Labels: Case-sensitive label support
- Directives:
.org,.res,.byte,.word,.dword,.ascii,.asciiz - Addressing Modes: All standard 6502 addressing modes
- Number Formats: Hexadecimal (
$FF), decimal (123), character ('A') - Operators: Low/high byte operators (
#<LABEL,#>LABEL) - Comments: Line comments using
;
| Mode | Syntax | Example |
|---|---|---|
| Immediate | #value |
LDA #$FF |
| Zero Page | address |
LDA $10 |
| Zero Page,X | address,X |
LDA $10,X |
| Absolute | address |
LDA $1000 |
| Absolute,X | address,X |
LDA $1000,X |
| Absolute,Y | address,Y |
LDA $1000,Y |
| Indirect | (address) |
JMP ($1000) |
| Indexed Indirect | (address,X) |
LDA ($10,X) |
| Indirect Indexed | (address),Y |
LDA ($20),Y |
| Relative | label |
BNE LOOP |
- Node.js 16+
- npm
# Clone the repository
git clone https://github.com/sokoide/6502-assembler.git
cd 6502-assembler
# Install dependencies
npm install
# Start development server
npm run dev# Development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Run tests
npm test
# Lint code
npm run lint# Start development server
make dev
# Build project
make build
# Build and deploy to docs/ (GitHub Pages)
make install
# Clean build artifacts
make clean; Simple 6502 program
.org $8000
START: LDX #$00 ; Initialize X register
LDY #$10 ; Initialize Y register
LOOP: LDA DATA,X ; Load data
STA $0200,Y ; Store to memory
INX ; Increment X
INY ; Increment Y
CPX #$04 ; Compare with 4
BNE LOOP ; Branch if not equal
BRK ; Break
DATA: .byte $01, $02, $03, $04├── src/
│ ├── components/ # React components
│ │ ├── AssemblyEditor.tsx
│ │ ├── OutputDisplay.tsx
│ │ └── ErrorDisplay.tsx
│ ├── services/ # Core logic
│ │ ├── assembler.ts # Two-pass assembler
│ │ ├── opcodes.ts # 6502 instruction set
│ │ └── sampleCodes.ts # Example programs
│ ├── types.ts # TypeScript definitions
│ └── App.tsx # Main application
├── docs/ # GitHub Pages deployment
├── Makefile # Build automation
└── README.md
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
The MOS Technology 6502 is an 8-bit microprocessor that was widely used in home computers and game consoles of the 1970s and 1980s, including:
- Apple II
- Commodore 64
- Nintendo Entertainment System (NES)
- Atari 2600
This assembler helps you learn and experiment with 6502 assembly language programming in a modern, accessible way.
-
Start the development server:
npm run dev
-
For VS Code debugging:
- Press
F5to run under the Edge & VS Code debugger - Set breakpoints in TypeScript files
- Use browser developer tools for additional debugging
- Press