cpu-z80

Provides Z80 assembly coding rules, opcode encodings, flags, and T-state timings for z88dk development.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing or reviewing Z80 assembly for z88dk library and application code requires exact knowledge of flag behavior, opcode encodings, and cycle timings, and mistakes like assuming 16-bit dec sets the Z flag cause subtle bugs. ## Core Features & Use Cases - Opcode Reference: Full unprefixed, CB, ED, and DD/FD opcode grids in Zilog mnemonics with byte counts, T-states, and flag effects in references/opcodes.md. - Flag Rules and Pitfalls: Documents which instructions do not set flags (16-bit inc/dec, djnz, rla family) and contrasts Z80 behavior with 8085 to prevent porting errors. - Assembler Guidance: Explains z80asm synthetic opcodes, strict-mode restrictions, undocumented instructions like sll and ixh, and how to verify encodings against cpu_test fixtures. - Use Case: When optimizing a hot math routine in libsrc, check whether exx, sbc hl,de, or a synthetic ld de,hl is valid and how many T-states each choice costs. ## Quick Start Ask the AI to review a Z80 assembly routine for correct flag usage and cycle timing using the Z80 opcode reference.

Frequently Asked Questions about cpu-z80

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

FAQPage Schema
How do I check Z80 opcode flags and T-states for z88dk assembly?

Consult the opcode grids in references/opcodes.md, which list byte counts, cycle timings, and SZHPNC flag effects for unprefixed, CB, ED, and DD/FD instructions. Timings follow the clrhome Z80 table and encodings follow z80asm strict test fixtures.

Why does dec bc not set the zero flag on Z80?

On Z80, 16-bit inc and dec instructions modify no flags at all, so dec bc never sets Z. Test the pair through A instead, for example ld a,b followed by or c, then branch on jp nz.

What is the difference between Z80 and 8085 assembly in z88dk?

Z80 supports exx, IX/IY index registers, djnz, sbc hl,de, and CB/ED/DD/FD prefixes, none of which exist on 8085. Flag behavior also differs: 8085 has separate P and V flags plus K, while Z80 packs parity and overflow into one P/V bit.

Can I use undocumented Z80 instructions like sll or ixh in z88dk?

z80asm accepts sll and ixh/ixl in normal mode but strict mode rejects them. Use them only when a measured size or T-state win justifies it, and never in code assembled with strict flags.

Does djnz affect flags on the Z80?

No, djnz decrements B internally and sets no flags, so a following jp z tests an older Z flag. It takes 13 T-states when the branch is taken and 8 when it falls through.