← ClaudeAtlas

z80-assemblylisted

Write, assemble, load and debug Z80 machine code for the ZX Spectrum (48K/128K) and compatibles. Use this WHENEVER the user wants to write a Z80 assembly routine, a BASIC `USR` machine-code "wstawka", a fast plotter/sprite/scroller, an interrupt (IM2) handler, a keyboard/joystick reader, or anything that drives the Spectrum hardware directly (display file at 0x4000, attribute file at 0x5800, ULA/border/beeper via port 0xFE, contended memory timing). It explains the Z80 register set and flags, the instruction groups, the non-linear screen layout and its address maths, ROM entry points and system variables, and how to assemble with sjasmplus (preferred), pasmo or z88dk-z80asm into a `.tap`/`.sna` and run it via the `zesarux-control` skill. Prefer this skill whenever the task is "Z80", "asm", "machine code", "assembler", "USR", "interrupt", "IM2", "T-states", "opcode", or driving Spectrum hardware from low level — even if the user only says "assembly on the Spectrum". Also trigger on Polish phrasings like "napis
dtz-labs/zx-skills · ★ 0 · Web & Frontend · score 72
Install: claude install-skill dtz-labs/zx-skills
# Z80 assembly for the ZX Spectrum This skill helps you write **correct, fast Z80 machine code** for the ZX Spectrum (and close compatibles) and get it running: write the source → assemble it to a loadable file → load and debug it in the emulator. It covers the CPU itself, the Spectrum's hardware quirks (especially the non-linear screen), the common assemblers, and how to bridge to BASIC via `USR`. The reference files hold the depth. **Read the relevant reference before writing non-trivial code** — Z80/Spectrum work has many traps: the display file is *not* linearly laid out, half the "instructions" you want are flag-dependent, IM2 needs a carefully aligned vector table, and timing depends on *contended* memory. Guessing produces code that crashes the machine or corrupts BASIC. ## Workflow 1. **Decide where the code lives and how it is reached.** A standalone program (`.sna`/autostart `.tap`) gets control at a fixed address. A BASIC helper is `RANDOMIZE USR addr` — then you MUST protect that memory first with `CLEAR addr-1` (lower RAMTOP) or place code in a safe area. Returning a value to BASIC: leave it in **BC** (`USR` reads BC). See `references/examples.md` and the BASIC-interfacing notes below. 2. **Write the source.** Pick an assembler (default **sjasmplus**) and follow its syntax/directives — `ORG`, `DB/DEFB`, `DW/DEFW`, `DS`, `EQU`, `MACRO`, modules. Keep labels meaningful; comment T-state-critical loops. See `references/assemblers.md`. For