LAMAlib is a comprehensive macro library that brings modern programming conveniences to 6502 assembly development. Write cleaner, more maintainable code for the Commodore 64, C128, and VIC-20 with high-level constructs, 16-bit operations, and powerful abstractions—all while maintaining full control over your assembly code.
- 16-bit operations made easy: Work with 16-bit values using intuitive macros like
ldax,addax,cmpax - Structured programming: Use
if/then/else,do/loop, andwhileconstructs in assembly - Zero overhead by default: Macros only generate code when you use them—no bloat
- Modular design: Include only what you need with separate modules for sprites, graphics, and more
- Battle-tested: Used in numerous game jam entries and retro projects
.include "LAMAlib.inc"
ldax #$1234 ; load a 16 bit value into registers A/X
clc
adcax #$2345 ; add another 16 bit value
stax $C000 ; store result
set_cursor_pos 10,0
print "The result is ",($C000) ; print the result to the screen
getkey ; waiting for keypress
rtsldax #$1000 ; Load 16-bit value
addax #$0500 ; Add without carry
subax #$0200 ; Subtract without carry
mulax #$0313 ; Multiply AX by $313
divax #$0420 ; Divide AX by $420
cmpax #$1300 ; Compare 16-bit values, sets Z and C flag like CMPldx #10
do
lda table,x
if ge #$80 ; if A >= $80
print "High value!"
else
print "Low value!"
endif
dex
loop while ne ; while X != 0.include "LAMAlib-sprites.inc"
showSprite 0
setSpriteColor 0,#RED
setSpriteXY 0,#100,#150
setSpriteCostume 0,#13
enableMultiColorSprite 0print "Score: ",(score) ; Print string + variable
print "X=",X," Y=",Y ; Print multiple valuesclrscr ; Clear screen
set_cursor_pos 12,10 ; Position cursor (col, row)
poke $400,42 ; Poke to screen memory
textcolor 7 ; Set text color- Clone or download this repository
- Run the included installation script:
./install_lamalib
- Include LAMAlib in your programs:
.include "LAMAlib.inc"
- Assemble using the
asshelper script:ass yourprog.s
For detailed installation options and platform-specific instructions (C64/C128/VIC-20), see the full documentation.
A demonstration of high-level expressions, loops, and text output:
Many games at the One Hour Game Jam have been created with LAMAlib, demonstrating its effectiveness for rapid retro game development.
A lunar landing game with physics simulation
Olympic-themed sports game
Both games are available with full source code at github.com/demesos/retrobits
LAMAlib includes reusable modules for common tasks:
- copycharset: Copy and modify character sets with effects (italic, reverse)
- mousedriver: 1351 mouse and joystick input handling
- polychars: Display more than 256 characters on screen simultaneously
- PETSCII display: Decode and display PETSCII encoded text
- topdownscroller: Multi-column text scrolling with variable speeds
LAMAlib comes with helpful development tools:
ass: Quick assembly script for C64/C128/VIC-20asdent: Automatic indentation formatter for assembly sourceexprass: High-level expression translator (convertslet A=PEEK(1024+X+40*Y)to assembly)
ߓ Full API Reference: LAMAlibdoc.md
Complete documentation of all macros, modules, and features.
This project is released under The Unlicense - public domain. Use it freely in any project, commercial or otherwise.
Contributions, bug reports, and feature requests are welcome! Feel free to open an issue or submit a pull request.
LAMAlib was created to make 6502 assembly programming more accessible and enjoyable while maintaining the power and control that assembly provides. Whether you're a game jam participant or working on a larger retro project, LAMAlib helps you write better code faster.
Author: Wilfried Elmenreich
GitHub: https://github.com/demesos/LAMAlib



