Skip to content
Emulator for the 6502 microprocessor (using Ian Piumarta's C library)
C Lua Prolog
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
examples
lib/piumarta
src
tests
.gitignore
README.md
lua-m6502-1.0-1.rockspec

README.md

6502 microprocessor emulator

This is an emulator for the 6502 microprocessor, which was dominant in the late '70s and early '80s.

This is but a Lua binding for Ian Piumarta's emulator, which is written in C (and is bundled here; you don't need to install it separately).

The use of Lua, a high-level "scripting" language, lets you easily build the "computer" around the processor using easy Lua code instead of C.

Installation

Using luarocks:

$ luarocks install lua-m6502

(Add --local (or prepend with sudo) if desired.)

Alternatively, clone the repository and do luarocks make.

Example

-- Instantiate a microprocessor.
local mpu = require('M6502').new()

-- Write into memory, at address $600, a sample program.
mpu:pokes(0x600, "\169\007")  -- "LDA #7" (loads 7 into the A register)

-- Set the program counter to $600.
mpu:pc(0x600)

-- Run!
mpu:run()

Documentation

The API is fully documented in doc/html. The documentation is generated by ldoc.

Getting the source code

Do:

$ git clone https://github.com/mooffie/lua-M6502
You can’t perform that action at this time.