CPU extensions (Z80N & CSpect)

Beyond the standard and undocumented Z80 instruction sets, FantASM supports two opt-in extension sets.

Z80N — ZX Spectrum Next

The Next’s CPU adds extended opcodes such as NEXTREG, MUL, PUSH nnnn, LDIX and LDWS. Enable them in any of these ways:

  • -N, --z80n on the command line;
  • !target zxnext (the Next target enables Z80N);
  • !opt z80n on from source.
!target zxnext

    nextreg $07, 3        ; set the CPU speed register
    mul d, e              ; 8×8 → 16-bit multiply
    push $4000            ; push an immediate word

See the instruction set reference for the full list of Z80N opcodes.

CSpect

The CSpect emulator recognises two debugging instructions that FantASM can emit:

InstructionPurpose
BREAKTrigger the CSpect debugger at this point.
EXITExit the emulator.

Enable them with -c, --cspect or !opt cspect on:

!opt cspect on

    break              ; drop into the CSpect debugger here

These are also useful when producing test builds; strip them from release builds by gating on a define.