Skip to main content

Syscalls

When the Spectranet ROM is paged into the Z80 address space, it exposes a fixed jump table: one three-byte entry every $03 bytes from $3E00 through $3EF0. Each address is the start of a small routine in ROM (socket helpers, paging, filesystem calls, and on Spectranext the SPECTRANEXT multiplexer).

Conceptually these are syscalls: your program does not know the physical address of the implementation inside the banked ROM; you call a well-known vector and the ROM does the work, then returns (often via PAGEOUT at $007C) so execution continues in your own code or in the Spectrum ROM.


Jump table region ($3E00$3EF0)

  • Granularity: entries are spaced by $03 bytes (typical jp or jp (hl) / jp (ix) target layout in the table).
  • Naming: assembly sources define symbolic names in spectranet.inc (and copies such as the index module include). Use those names instead of hard-coded addresses when possible.
  • Paging: on original Spectranet you usually PAGEIN before calling a jump-table address (memory). On Spectranext, a fetch to the trampoline region around $3FF8$3FFF (for example call IXCALL / call HLCALL) is trapped: the cartridge pages itself in for that access, so you do not need an explicit PAGEIN first. The HLCALL / IXCALL trampolines still arrange a safe return through PAGEOUT.

This article focuses on how you invoke one of these vectors and documents SPECTRANEXT in detail. For the command/status RAM at $3400$3401, see I/O Ports.


Reaching a vector: HLCALL, IXCALL, and PAGEIN

From spectranet.inc (hardware and trampolines):

AddressSymbolRole
$3FF9PAGEINPage Spectranet ROM into the decode range so jump-table calls are valid.
$3FFAHLCALLCall target whose address is in HL (dispatcher pushes PAGEOUT, then jp (hl)).
$3FFDIXCALLCall target whose address is in IX (dispatcher pushes PAGEOUT, then jp (ix)).
$007CPAGEOUTReturn path: M1 at this address unpages Spectranet; the byte fetched is ret, so the stack unwinds back to your caller.

Typical assembly pattern for any IX-based entry (including SPECTRANEXT):

ld   ix, SPECTRANEXT    ; 0x3EF0 — or another equ from spectranet.inc
call IXCALL ; 0x3FFD — enters ROM, returns via PAGEOUT

On Spectranext, you can use this pattern without having called PAGEIN first: the hardware/firmware recognises the instruction fetch to call IXCALL ($3FFD) in the $3FF8$3FFF window and pages in the Spectranet ROM so the J_ixdispatch stub and your (IX) target run correctly. That is only for this trampoline address range — calling a raw jump-table address such as $3EF0 with Spectranet still unpaged still requires the ROM to be mapped or another supported entry path.

After the ROM routine returns, you still do not need a manual PAGEOUT: the dispatcher has pushed PAGEOUT ($007C) as the return address, so SPECTRANEXT unwinds through PAGEOUT and Spectranet is unpaged automatically before your code resumes.

For routines that expect the target address in HL, use call HLCALL instead.

From C, the linked Spectranet libraries wrap these details; you include headers and call documented functions rather than raw addresses.


SPECTRANEXT ($3EF0)

SPECTRANEXT is the Spectranext operation multiplexer in ROM. It is not a separate syscall per Wi‑Fi/DNS feature; it is one jump-table slot whose behaviour is selected by register A on entry.

  • Entry address: SPECTRANEXT equ $3EF0 (see spectranet.inc).
  • Invocation: load A with the operation ID, set up inputs in the registers documented below, then ld ix, SPECTRANEXT / call IXCALL. On Spectranet, call IXCALL does not require a prior PAGEIN (see above).

Operations (IDs, inputs, outputs)

IDOperationInputs (before call)Outputs (on success, carry = 0)
0Get controller statusDE = pointer to 4-byte IPv4 buffer (host order), filled by ROMB = controller status · C = Wi‑Fi connection state · IPv4 at (DE..DE+3)
1Scan Wi‑Fi access pointsA = number of networks found
2Get name of scanned APC = AP index (0-based) · DE = buffer for NUL-terminated name (staging copy, up to 64 bytes)Name written at DE
3Connect to Wi‑FiHL = SSID string · DE = password string
4Disconnect Wi‑Fi
5DNS: hostname → IPv4HL = hostname string · DE = 4-byte IPv4 result bufferIPv4 at (DE..DE+3)

Constants and C prototypes are in spectranext.h (same IDs and semantics). For a concise port-level summary, I/O Ports lists the same operations in table form.


Full jump table reference ($3E00$3EF0)

The following table lists symbol → address as in spectranet-firmware/include/spectranet.inc. It is a reference, not a full manual for each routine.

AddressSymbol
$3E00SOCKET
$3E03CLOSE
$3E06LISTEN
$3E09ACCEPT
$3E0CBIND
$3E0FCONNECT
$3E12SEND
$3E15RECV
$3E18SENDTO
$3E1BRECVFROM
$3E1EPOLL
$3E21POLLALL
$3E24POLLFD
$3E27GETHOSTBYNAME
$3E2APUTCHAR42
$3E2DPRINT42
$3E30CLEAR42
$3E33SETPAGEA
$3E36SETPAGEB
$3E39LONG2IPSTRING
$3E3CIPSTRING2LONG
$3E3FITOA8
$3E42RAND16
$3E45REMOTEADDRESS
$3E48IFCONFIG_INET
$3E4BIFCONFIG_NETMASK
$3E4EIFCONFIG_GW
$3E51INITHW
$3E54GETHWADDR
$3E57DECONFIG
$3E5AMAC2STRING
$3E5DSTRING2MAC
$3E60ITOH8
$3E63HTOI8
$3E66GETKEY
$3E69KEYUP
$3E6CINPUTSTRING
$3E6FGET_IFCONFIG_INET
$3E72GET_IFCONFIG_NETMASK
$3E75GET_IFCONFIG_GW
$3E78SETTRAP
$3E7BDISABLETRAP
$3E7EENABLETRAP
$3E81PUSHPAGEA
$3E84POPPAGEA
$3E87PUSHPAGEB
$3E8APOPPAGEB
$3E8DPAGETRAPRETURN
$3E90TRAPRETURN
$3E93ADDBASICEXT
$3E96STATEMENT_END
$3E99EXIT_SUCCESS
$3E9CPARSE_ERROR
$3E9FRESERVEPAGE
$3EA2FREEPAGE
$3EA5REPORTERR
$3EA8MOUNT
$3EABUMOUNT
$3EAEOPENDIR
$3EB1OPEN
$3EB4UNLINK
$3EB7MKDIR
$3EBARMDIR
$3EBDSIZE
$3EC0FREE
$3EC3STAT
$3EC6CHMOD
$3EC9READ
$3ECCWRITE
$3ECFLSEEK
$3ED2VCLOSE
$3ED5VPOLL
$3ED8READDIR
$3EDBCLOSEDIR
$3EDECHDIR
$3EE1GETCWD
$3EE4RENAME
$3EE7SETMOUNTPOINT
$3EEAFREEMOUNTPOINT
$3EEDRESALLOC
$3EF0SPECTRANEXT

See also

  • I/O Ports$3400/$3401 handshake and operation IDs in one place
  • Memory map — paging and PAGEIN / PAGEOUT
  • spectranext.h (SDK) — C API for SPECTRANEXT operations