6502-assembly

6502-assembly is a skill for Claude Code, Codex from nschneir/PET-Project. It costs 54 tokens per session (1,874 once invoked), scanned A, original, MIT.

A guide to writing and debugging 6502 assembly, the machine-code language used by the Commodore PET, with the ca65 and ld65 tools. It explains the PET program layout, its BASIC SYS start command, and calls to built-in ROM routines.

In plain words
What is it for?
Building or running PET assembly programs with pet build or pet run, starting code from BASIC, printing through the PET's ROM, and avoiding common 6502 mistakes.
Why use it?
It provides the required structure for a PET program and highlights hardware-specific details that can otherwise cause build or runtime errors.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Building or running PET assembly programs with pet build or pet run, starting code from BASIC, printing through the PET's ROM, and avoiding common 6502 mistakes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nschneir/pet-project/6502-assembly
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add nschneir/PET-Project --skill 6502-assembly
Clone the repo
git clone --depth 1 https://github.com/nschneir/PET-Project

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 6502-assembly

README.md
[![agentmods](https://agentmods.dev/badge/skills/nschneir/pet-project/6502-assembly.svg)](https://agentmods.dev/skills/nschneir/pet-project/6502-assembly)
Your own site
<a href="https://agentmods.dev/skills/nschneir/pet-project/6502-assembly"><img src="https://agentmods.dev/badge/skills/nschneir/pet-project/6502-assembly.svg" alt="Measured on agentmods" height="20"></a>
Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,874 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00054 $0.01874
Opus 5 $0.00027 $0.00937
Sonnet 5 $0.00011 $0.00375
Haiku 4.5 $0.00005 $0.00187

Measured 8d ago against content hash 4df74f08a0b8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

6502-assembly scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/6502-assembly/SKILL.md · 137 lines

How it starts

The opening of the file, as written. The whole thing — 137 lines — stays where its author put it; the contents beside it link to each section on GitHub.

6502 assembly for the PET

Assemble with ca65/ld65 through pet build FILE.s (produces a .prg plus a VICE label file) or run in one step with pet run FILE.s (assembles, loads, and RUNs, registering the labels on the session for symbolic debugging). The machine-level reference for addresses and ROM routines is the pet-development skill's reference files (memory map, ROM routines, zero page, PETSCII).

The program skeleton

A PET program loads at $0401 and needs a tiny BASIC stub so that RUN transfers control to your machine code. This skeleton assembles as-is (it is the project’s tests/programs/hello-asm example):

; print a message via the ROM CHROUT routine, then return to BASIC.
; Layout: 2-byte load address ($0401), then a BASIC stub "10 SYS 1037",
; then code at $040D (= 1037).

CHROUT = $FFD2

        .segment "LOADADDR"
        .word   $0401

        .segment "EXEHDR"
        .word   nextln          ; pointer to next BASIC line
        .word   10              ; line number 10
        .byte   $9E, "1037", $00 ; SYS 1037
nextln: .word   $0000           ; end of BASIC program

        .segment "CODE"
start:  ldx     #0
loop:   lda     msg,x
        beq     done
        jsr     CHROUT
        inx
        bne     loop
done:   rts

msg:    .byte   "HELLO FROM ASM", $0D, $00

Why SYS 1037

The load address $0401 is emitted by the LOADADDR segment (not loaded into RAM as data — it is the PRG header). Starting at $0401 the EXEHDR segment lays down a single BASIC line — next-line pointer, line number 10, the SYS token $9E, the digits "1037", and a $00 terminator — followed by the $0000 end-of-program marker. That stub occupies 12 bytes ($0401$040C), so your CODE segment begins at $040D, which is decimal 1037. Hence SYS 1037 jumps to start. Change the message and the code, not the stub.

Segments available in the linker config: CODE, RODATA, DATA, BSS (and ZEROPAGE). Put executable code and mutable data in CODE/DATA, constants in RODATA, and uninitialized storage in BSS.

Read the full file on GitHub · 137 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 137 lines · 54 tokens per session scan A 4df74f08a0b8

Subscribe to this mod's changes

6502-assembly is a skill published in the GitHub repository nschneir/PET-Project (1 stars, last pushed 16d ago), licensed MIT. It adds 54 tokens to every session and 1,874 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

6502-assembly

Use when writing or debugging 6502 assembly for the Commodore 64 with ca65/ld65 via c64 build or c64 run. Covers the C64 program skeleton, the BASIC SYS stub, calling ROM routines, and 6502 gotchas.

nschneir/Project64 · 58 tokens

c64-development

Use when developing, running, or debugging Commodore 64 software (Commodore BASIC or 6510/6502 assembly) on the VICE emulator with the c64 CLI or the c64-tools MCP server. Covers the build/run/observe/debug loop, the stopped-state discipline, C64 text encodings, graphics and sprites, and the memory map.

nschneir/Project64 · 78 tokens

cartridge-programming

Use when writing, building, or debugging a Commodore 64 cartridge — plain 8K/16K/Ultimax or bank-switched EasyFlash — with the c64 CLI or the c64-tools MCP server. Covers the two boot mechanisms (CBM80 vs the $FFFC reset vector), the memory modes, cart-native code in ROM, the EasyFlash banking discipline from…

nschneir/Project64 · 96 tokens

6502-debugging

Use when a C64 program misbehaves at runtime — crashes, corruption, wrong values, dead input, visual glitches — and you need a procedure, not a guess. Symptom-indexed playbook of runtime debugging procedures using c64-tools.

nschneir/Project64 · 55 tokens

disk-io-programming

Use when a Commodore 64 program has to touch a disk while it runs — loading levels, music or graphics on demand, saving a high-score file, or streaming a data file byte by byte. Covers the KERNAL LOAD/SAVE and channel calls, device and secondary-address conventions, reading the DOS error channel, and the…

nschneir/Project64 · 89 tokens

annotate-source-files

Add PUT workflow annotations to source files using the correct language-specific comment prefix. Covers annotation syntax, skeleton generation via putgenerate(), multiline annotations, .internal variables, and validation. Supports 30+ languages with automatic comment prefix detection. Use after analyzing a codebase…

pjt222/agent-almanac · 89 tokens