I/O Ports
Spectranext exposes several fixed Z80 I/O ports (addresses ending in $3B). Use the usual instructions — for example ld bc, $nn3B with out (c), a and in a, (c) — with the port numbers below.
I/O ports
$003B — Page A
Write only. Chooses which 4K page is visible in memory region A. Prefer the ROM paging helpers (for example SETPAGEA) instead of raw OUT, so paging stays consistent with the rest of the system. Details: memory.
$013B — Page B
Write only. Same role as $003B, but for region B (for example SETPAGEB).
$053B — Page 0 (Spectranext only)
Write only. Chooses which 4 KiB Spectranext page is visible in section 0, at $0000–$0FFF. The page number is written in A:
ld a, page_number
ld bc, $053B
out (c), a
This is a Spectranext-only extension; original Spectranet hardware has no programmable section-0 mapping. It is intended for tightly controlled environments that need to temporarily replace the Spectrum ROM view, such as the eSXDOS/DOT compatibility kernel. It is not a substitute for the normal PAGEIN/PAGEOUT and page-A/page-B APIs: mapping a page at $0000 also replaces the Spectrum ROM, interrupt vectors, and ROM entry points visible to the Z80.
The assembler symbol is PAGE0REG.
$063B — Page 3 (Spectranext only)
Write only. Chooses which 4 KiB Spectranext page is visible in section 3, at $3000–$3FFF. Write the page number in A using the same pattern:
ld a, page_number
ld bc, $063B
out (c), a
This is also a Spectranext-only extension. It permits a second independent 4 KiB mapping in addition to pages A and B, and is used by the eSXDOS/DOT environment to expose the second half of a command image or a shared workspace. Be careful not to use it while code, data, or the stack still depends on the mapping it replaces. The assembler symbol is PAGE3REG.
$023B — Trap / CPLD
Read and write. Spectranet-style programmable trap address and related behaviour; reads can report hardware identity (what the CPLD reports).
On Spectranext, a programmable trap in $0000–$3FFF is matched only while the cartridge is paged out, when that range refers to host ROM. While the cartridge is paged in, the same addresses refer to cartridge memory and are deliberately ignored by the programmable trap to avoid address-alias collisions. Traps at $4000–$FFFF remain valid in either paging state.
On original Spectranet this behavior was a design bug – programmable trap left by %tapein could trap while spectranet module executes.
$033B — Cartridge control
Read and write. Controls paging the Spectranet ROM/RAM, traps, and the register bit pattern used when detecting Spectranext.
The current RP2350 write bits are:
| Bit | Mask | Effect |
|---|---|---|
| 0 | $01 | Page in; clearing releases only an I/O-owned mapping. |
| 1–2 | $06 | Ignored on writes; these bits are border colour on reads. |
| 3 | $08 | Programmable trap enable; zero disables it. |
| 4–6 | $70 | Ignored on writes. Bit 5 retains a different legacy CPLD meaning. |
| 7 | $80 | Detection signature; reads return the inverse of the written bit. |
Read bits 0–2 are border colour, not paging/mode status. Compatibility
requests use the separate $073B port below. Writing border readback to
$033B cannot change compatibility mode. Page-in/out, trap enable and the
detection signature retain their existing meanings.
$073B — Compatibility mode (Spectranext only)
Read/write, exact address. Reads report current compatibility modes;
writes accept explicit requests. The port does not change paging, programmable
traps or the detection signature. $0F3B and other address aliases are not
implemented.
| Bit | Mask | Read | Write |
|---|---|---|---|
| 0 | $01 | DivMMC bus mode is active, regardless of how it was enabled. | Enable DivMMC mode. If already active, do nothing; otherwise save the mode and reboot cartridge and Spectrum. |
| 1 | $02 | Next compatibility latch is active. | Set the latch. Host or cartridge reset clears it. |
| 2–7 | $FC | Zero. | Reserved; ignored. Write zero. |
Both defined bits are write-one requests: writing zero preserves the existing state. Bit 0 reads the active bus policy, not the last write or a pending request: DivMMC selected by settings is reported before SPX writes anything. Native, locked and settings-error policies return bit 0 clear. Reads have no side effects. Write requests are ignored while the cartridge is disabled.
Before offering a native esxDOS mount, the VFS browser reads bit 0. When clear,
it hides Mount esxdos and rejects manually entered esxdos:// URIs before
calling the mount provider. The bit reports compatibility mode, not a separate
probe for an attached device or inserted SD card.
The DivMMC request stops the host after the requesting OUT, withdraws the cartridge bus drivers, commits the settings, then reboots. It does not switch the running listener in place. Flash errors or an unsupported bootloader leave the host stopped; an existing power-cycle lock is not cleared. Normal settings-based mode changes retain their power-cycle requirement.
Bit 1 selects the cartridge's Next-specific bus handling. It does not enable the Next's expansion bus, modify NextRegs, or persist a setting in flash. Detect the Next and enable its expansion bus before requesting this latch. Bit 1 alone does not force DivMMC mode. If bit 0 causes a reboot, initialization must run again afterward to set bit 1 for the new boot.
; Run from host RAM, with DivMMC unmapped and interrupts disabled.
ld bc, $033B
in a, (c)
and $08 ; preserve programmable-trap enable
or $01 ; page in only
out (c), a
; After positively detecting Next hardware and configuring its expansion bus:
ld bc, $073B
ld a, $03 ; bit 0: DivMMC; bit 1: Next
out (c), a
For a non-Next DivMMC host, use $01 at $073B. In active DivMMC mode execution
continues after the write. Changing from native mode stops and reboots the
host. Code and stack must remain outside the low 16 KiB during paging changes.
The assembler symbol for the compatibility-mode port is COMPATREG.
Install the updated SPX together with this firmware. Older SPX binaries which
request compatibility through $033B bits 1/2 or the historical bit 6 no longer
set those modes. There is deliberately no compatibility alias at $033B, so
legacy Spectranet control-register writes remain safe.
$043B — Console I/O
Write only. Each byte you send is printed on the host console. Typical pattern: bc = $043B, then out (c), a per character.
More detail: libterm and logging.
See also
- Syscalls —
SPECTRANEXToperations, jump table,IXCALL - Detection — using port
$033B - libterm / stdout — port
$043B - Memory map — paging on
$003B/$013B - DOT commands — one use of the Spectranext-only section-0 and section-3 mappings