tool-z80asm

Assemble, link, and build libraries for Z80-family CPUs with z88dk-z80asm.

1.1k|206|Updated Mar 16, 2016
One-click install
npx skills add https://github.com/z88dk/z88dk --skill tool-z80asm-z88dk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tool-z80asm
Source: https://github.com/z88dk/z88dk/tree/main/.agents/skills/tool-z80asm
Command: npx skills add https://github.com/z88dk/z88dk --skill tool-z80asm-z88dk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing assembly for the many Z80-family CPUs (8080, 8085, z80, z80n, z180, gbz80, and more) requires knowing exactly which instructions each assembler mode accepts, how synthetic opcodes expand, and how PHASE/DEPHASE affects label addresses. This Skill provides the operational knowledge to drive the z88dk-z80asm assembler, linker, and librarian correctly when building libsrc code or producing .lib products. ## Core Features & Use Cases - Assembler and linker guidance: Covers CPU selection flags (-m8085, -mz80, -mz80n), library creation with -x, listings with -l, and incremental rebuilds with -d. - PHASE/DEPHASE semantics: Explains how bytes are stored at the section PC while labels resolve to a run address, and why phased code must be copied before execution. - CPU capability fixtures: Documents how to query src/z80asm/dev/cpu fixture files with rg to verify whether an instruction assembles for a given CPU and what encoding it emits, including strict-mode rules. - Use Case: When porting a library routine to the 8085, use this Skill to confirm that sub hl,bc is a real extended opcode while ld de,hl is only a synthetic expansion forbidden in strict mode. ## Quick Start Ask the assistant to check whether a specific assembly instruction is accepted by z88dk-z80asm for a given -m CPU target and what bytes it emits.

Frequently Asked Questions about tool-z80asm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check if an instruction assembles for a specific Z80 CPU in z88dk?

Query the CPU capability fixtures under src/z80asm/dev/cpu using rg against the cpu_test_<cpu>_ok.asm and cpu_test_<cpu>_err.asm files. The ok files show accepted forms with their emitted encodings, while err files list forms the assembler must reject for that -m target.

How do I create a library with z88dk-z80asm?

Use the -x flag followed by the library name and an @list of object files, for example z88dk-z80asm -xlibname.lib file1.o file2.o. The -d flag enables date-based incremental rebuilds during library builds.

What is the difference between normal and strict mode in z80asm?

Strict mode forbids synthetic opcodes, which are assembler sugar expanded into multiple real instructions in normal mode. Forms like ld de,hl assemble in normal mode but fail in strict mode, while real extended ops like sub hl,bc remain legal in both.

How does PHASE/DEPHASE work in z80asm?

PHASE stores bytes at the current section PC while resolving labels and $ to a run address as if ORG were set. The linker has no knowledge of PHASE, so runtime code must copy the phased bytes to the run address with ldir before calling those labels.

Should I use Intel or Zilog mnemonics in z88dk assembly code?

z88dk requires Zilog mnemonics for all tree code, including library, CRT, and examples. The assembler accepts Intel mnemonics on 8080/8085 only for compatibility with external sources, so translate Intel syntax to Zilog when importing foreign code.

Why does my PHASE'd code crash when called directly?

Labels inside PHASE resolve to the run address, not the storage address where the bytes actually sit. You must copy the phased block to its run address (typically with ldir) before any call or jp to those labels, or the CPU jumps to unpopulated memory.