Error Messages and Error Numbers

Every error reported on a BBC machine has an error number (1-byte value in &FD) and an error message (null-terminated string immediately after the BRK opcode that raised it). The error structure is documented in brk.

ERR in BASIC returns the error number. REPORT in BASIC prints the error message. The MOS error-string lookup is by convention only — a paged-ROM can raise any error number with any message, and many do.

BASIC error numbers (0-44)

These are the canonical Acorn BBC BASIC IV errors as shipped on every BBC machine. Per bbc-user-guide Ch 46:

NumHexMessageCause
0&00No roomUntrappable — all memory used
1&01Out of rangeBranch out of range in assembler
2&02ByteAssembler immediate operand > 255 (e.g. LDA #345)
3&03IndexBad assembler index mode
4&04MistakeGeneric “couldn’t make sense of input”
5&05Missing ,Expected comma
6&06Type mismatchNumber expected, string offered (or vice-versa)
7&07No FN=FNname outside function body
8&08$ rangeAttempt to use $ indirection at zero page
9&09Missing "Unterminated string
10&0ABad DIMDIM A(-3) etc.
11&0BDIM spaceInsufficient memory for array
12&0CNot LOCALLOCAL outside procedure/function
13&0DNo PROCENDPROC without DEF PROC
14&0EArrayReference to undeclared array
15&0FSubscriptArray index out of bounds
16&10Syntax errorMis-terminated command
17&11EscapeESCAPE key pressed
18&12Division by zero34/0 etc.
19&13String too long>255 chars
20&14Too bigNumeric overflow
21&15-ve rootSQR(-x), ASN(>1), ACS(>1)
22&16Log rangeLOG(<=0)
23&17Accuracy lostTrig of very large angle (e.g. SIN(1E7))
24&18Exp rangeEXP(>88)
25&19Bad MODEMode change inside PROC/FN or insufficient memory
26&1ANo such variableVariable used before assignment
27&1BMissing )Unbalanced bracket
28&1CBad hex&y etc. (invalid hex digit)
29&1DNo such FN/PROCUndefined FN/PROC call
30&1EBad callPROC/FN called incorrectly
31&1FArgumentsWrong number of args
32&20No FORNEXT without FOR
33&21Can't match FORNEXT doesn’t match FOR variable
34&22FOR variableNon-numeric FOR variable
35&23Too many FORsNesting >10
36&24No TOFOR X=1 (missing TO)
37&25Too many GOSUBsNesting >26
38&26No GOSUBRETURN without GOSUB
39&27ON syntaxMalformed ON … GOTO/GOSUB
40&28ON rangeControl var <1 or >list length
41&29No such lineGOTO/GOSUB to non-existent line
42&2AOut of DATAMore READs than DATA
43&2BNo REPEATUNTIL without REPEAT
44&2CToo many REPEATsNesting >20

Untrappable errors (No room, Bad program, LINE space, Silly, Failed at N, etc.) have no number — they exit to the BASIC prompt directly and can’t be caught by ON ERROR.

Cassette/CFS filing-system errors (216-223)

Raised by the cassette filing system when reading from tape:

NumMessageCause
216Data?CRC error in file body — rewind, replay
217Header?CRC error in file header — rewind, replay
218Block?Unexpected block number — rewind, replay
219File?Unexpected filename in header
220SyntaxBad *OPT or similar
222ChannelUse of unopened channel
223EofEnd of file reached

MOS / sideways-ROM errors (250+)

Defined by the MOS / paged-ROM dispatch layer:

NumMessageWhere raised
251Bad key*KEY syntax error
253Bad string* command string parse error
254Bad commandNo paged ROM recognised the * command

DFS / ADFS / NFS errors (varies)

Filing-system specific. Each filing-system ROM defines its own. Some common ones:

NumMessageTypical FS
198Disc faultDFS / ADFS
199Disc fullDFS / ADFS
200Disc changedDFS / ADFS
201File lockedDFS / ADFS
202Not openDFS / ADFS / NFS
203Not enabledDFS / NFS
204Bad nameDFS / ADFS / NFS
205Bad driveDFS / ADFS
206Bad directoryDFS / ADFS
207Bad attributeDFS / ADFS
208File existsDFS / ADFS
209Drive faultDFS / ADFS
210Disc read onlyDFS / ADFS
211Not foundDFS / ADFS / NFS
212ChannelDFS / ADFS
213End of fileDFS / ADFS
214File not foundDFS / ADFS / NFS

These are not authoritative; cross-check against *HELP output from the active filing system on real hardware for the exact range. Each filing system has its own error-number convention; conflicts exist between e.g. DFS 200 and NFS 200.

Raising errors from user code

Use the BRK + structure pattern (per brk):

BRK              ; trigger MOS error handler
EQUB error_num   ; error number
EQUS "Message"   ; null-terminated error string
EQUB 0

The MOS sets up &FD (pointer to message), &FE (return PC after BRK), &F0 (saved SP), then calls BRKV (&202). Default BRKV in BASIC prints the message and exits to prompt.

To intercept an error from your own code, hook BRKV before the operation that might fail:

LDA #<my_handler  : STA &202
LDA #>my_handler  : STA &203
; ... do potentially-failing work ...

Restore &202/&203 to the old values before returning. The standard pattern is to save them on entry and restore on RTS.

Compatibility notes

  • Error numbers 1-44 are stable across BBC BASIC I, II, III, IV (Model B → Master Compact).
  • Error number 0 (No room) is documented as untrappable on Model B per bbc-user-guide Ch 46 (“untrappable error”); behaviour on newer BASIC versions is undocumented in primary sources I’ve ingested — assume untrappable unless you can verify otherwise on the target machine.
  • Cassette errors 216-223 only fire on machines that have CFS available (Master 128 has CFS as a ROM image; Master Compact has no CFS at all).
  • DFS / ADFS / NFS errors are per-ROM — what error 200 means depends on which filing system is active.
  • The Silly and Failed at N errors (from RENUMBER, AUTO) have no numbers and are never ERR-readable.

See also

  • brk — BRK structure, BRKV protocol, ROM-raising-errors pattern.
  • calls — OSCLI / OSFILE / OSBYTE error-return conventions.
  • bbc-user-guide — Ch 46 (canonical BASIC error list).
  • zero-page&FD/&FE (error pointer), &F0 (saved SP).

This wiki is curated by Claude following the LLM-Wiki methodology — a human curates source documents, the LLM compiles structured cross-linked markdown. Content may contain errors, omissions, or stale claims. For authoritative information refer to the original source documents in the bbc-documents GitHub archive.