OS Workspace — Pages 1, 2, 3

Beyond zero page (zero-page), MOS occupies three more pages of low RAM. Knowing the layout matters when:

  • You want to read MOS state without using OSBYTEs (faster lookups).
  • You want to bypass MOS for a particular function and need to know what state to restore.
  • You’re writing code that lives in low RAM and want to avoid clobbering MOS variables.

Page 1 (&0100-&01FF) — Stack

The 6502 hardware stack. BBC firmware initialises SP to &FF; the stack grows downward from &01FF. SP wraps within page 1 on overflow with no trap, so deep recursion or unbalanced pushes silently corrupt earlier stack frames.

When MOS calls into your code via OSWRCH/OSRDCH/IRQ/etc, the upper portion of page 1 contains the return-address chain. Don’t touch it.

Pages 8-9 (&0800-&09FF) — Buffers

From NAUG §6.6 p114:

RangeUse
&800-&83FSound workspace
&840-&84FSound channel 0
&850-&85FSound channel 1
&860-&86FSound channel 2
&870-&87FSound channel 3
&880-&8BFPrinter buffer (distinct region — NOT shared with sound)
&8C0-&8FFEnvelope storage 1-4 (13 bytes each + 3 spare)
&900-&9BFRS423 output buffer — OR Envelopes 5-16 — OR (overlap) CFS/RFS BPUT sequential output buffer
&9C0-&9FFSpeech buffer — overlapped by CFS/RFS BPUT output buffer when CFS active

Page B (&0B00-&0BFF) — Function keys

RangeUse
&B00-&B10Soft key pointers (one per function key)
&B11-&BFFSoft key definition strings

Page C (&0C00-&0CFF) — User character definitions

8 bytes per character × 32 characters = 256 bytes for ASCII 128-159 (or 224-255 on imploded font).

Page D (&0D00-&0DFF) — NMI + Econet

RangeUse
&D00-&D5FNMI handling code (filing systems install here)
&D60-&D7FEconet workspace
&D80-&D91Unused on most machines
&D92-&D9EReserved for trackerball
&D9F-&DEFExtended vector table (paged-ROM-claimed extra vectors)
&DF0-&DFFROM workspace bytes (per-ROM private workspace pointer)

NMI handlers are page-aligned at &D00. Disc filing systems and Econet share the NMI; claim/release protocol is via paged-ROM service calls (Ch17, pending).

Page 2 (&0200-&02FF) — OS vectors + OS variables

From NAUG §6.6.2:

RangeUse
&200-&235OS vector table (see calls)
&236-&28FOS variables — accessible via OSBYTE &A6-&FF. Direct read is faster than OSBYTE.
&290-&291*TV vertical adjust + interlace
&292-&296TIME — first copy (dual-clock to allow atomic 5-byte read)
&297-&29BTIME — second copy
&29C-&2A0Interval timer (OSWORDs &03/&04)
&2A1-&2B0Paged ROM table (OSBYTE &AA/&AB)
&2B1-onwardsINKEY countdown, OSWORD &00 workspace, ADC LSB/MSB tables, event enable flags, two-key rollover, buffer pointers, CFS state, OSFILE control blocks

Master and Electron differ in the exact addresses of some of these — NAUG p115 has a side-by-side table.

Useful direct reads

The OSBYTE-variable address is &0236 + (osbyte_number - &A6). So &D2 (sound suppression) lives at &0236 + (&D2 - &A6) = &0262. Worked examples:

AddrWhatOSBYTE-var #
&020E-&020FOSWRCH vector—
&024AROM active at last BRK&BA (fx186)
&0261Speech suppression status&D1 (fx209)
&0262Sound suppression status&D2 (fx210)
&0277User VIA IRQ mask&E7 (fx231)
&0279System VIA IRQ mask&E9 (fx233)
&027COutput stream destination (FX3)&EC (fx236)
&027DCursor key status (FX4)&ED (fx237)
&028CCurrent language ROM (but see the Master caveat below)&FC (fx252)
&028DLast BREAK type&FD (fx253)

The addresses are stable across BBC/B+/Master — the formula above always holds — but a byte’s contents need not mean the same thing at every moment on every machine. On the Master, &028C is not a safe “current language ROM” under a *RUN boot: it read &FF, and restoring ROMSEL from it paged ANDY (bit 7) over the DFS. Save ROMSHAD (&F4) to restore paging instead (phX, 2026-11-14, jsbeeb Master MOS 3.20; phX/docs/hwtest.md “Traps found on the way” — beeb-port-kit-hardware-facts-2026-11 §4). Whether &028C holds &FF at other moments is not measured. (Until 2026-11-18 this paragraph said only “exact addresses are stable across BBC/B+/Master”.) Reading directly is faster than calling OSBYTE (saves the dispatch overhead). For full table see allmem-ripley-harston lines 179-287, or query OSBYTE &A6/&A7 to get the base address dynamically (in case a future MOS shifts it).

Page 3 (&0300-&03FF) — VDU workspace + filing buffers

From NAUG §13.2.2 (already in naug-ch13-video):

RangeUse
&300-&30BCurrent graphics window (&300-&307, pixels) + text window (&308-&30B, chars)
&30C-&30FGraphics origin (external coords)
&310-&317Current + old graphics cursor (external coords)
&318-&319Text cursor X / Y
&31ALine within graphics cell of cursor
&31BGraphics workspace / VDU queue control
&31F-&323VDU queue (5 bytes)
&324-&327Current graphics cursor (internal coords)
&328-&32FBitmap read from screen by OSBYTE 135
&330-&349Graphics workspace
&34A-&34BText cursor address for 6845
&34C-&34DText window width in bytes
&34EMSB of HIMEM (ignoring shadow)
&34FBytes per character (current mode)
&350-&351Top-left screen address as given to 6845 — this is the screen-start mirror for hardware scroll
&352-&353Bytes per char row (current mode)
&354Screen mode size in pages
&355Current screen mode (ignoring shadow bit)
&356Screen size code: 0=20K, 1=16K, 2=10K, 3=8K, 4=1K
&35FLast 6845 cursor start register value
&360Logical colours - 1
&361Pixels per byte - 1 (0 for text)
&362-&363Bit masks for left-most and right-most pixel
&366-&36EVDU 23 settings (Master ECF, dot patterns, etc.)
&36F-&37EFont location bytes (MSB per font group)
&37FUnused
&380-onwardsColour palette copy (1 byte per logical colour), BPUT/BGET buffers, filing-system block headers, keyboard input buffer

&350/&351 is the screen-start the OS thinks the 6845 has — keep this in sync if you hardware-scroll directly, so subsequent OSWRCH lands at the right pixel row. Equivalent to OSBYTE &A0, X=&50.

Bypassing MOS — what to save/restore

If you’re going fully native (game / demo style, no return to BASIC):

  • You don’t need to preserve anything. Set SP, set zero page, set IRQ vectors, set MOS-tracked hardware state to whatever you want, run forever (or until BRK/reset).

If you’re returning to BASIC after a routine:

  • Page 0: save &70-&8F and whatever else you touch (see zero-page).
  • OS palette (&FE21 + page 3 colour palette copy at &380+): if you wrote &FE21 directly, also write the same value (XOR 7) into the OS copy, or restore the original.
  • &350/&351 if you moved R12/R13.
  • IRQ vectors &204-&207 if you hooked them.
  • Sideways ROM register &FE30: never set — see paged-rom.

If you’re inside an IRQ handler:

  • A is in &FC (MOS save). Don’t touch.
  • Keep your handler under 2 ms (NAUG §8.5 — interrupts).
  • Don’t call any OS routine.

Master “second 32 KB” workspace map (&3000-&DFFF in LYNNE+ANDY+HAZEL)

The Master’s 128 KB of DRAM splits into two 64 KB regions. The “second 32 KB” (the upper half of the second region, partially overlaid by paged ROMs in the CPU map) contains a mix of shadow display and MOS workspace. Per master-arm Ch 11:

RangeUseNote
&3000-&7FFFLYNNE shadow screenAny portion not needed by the current mode is free; *MOVE will use it
&8000-&83FFSoft-key expansion buffer1 KB — replaces the cramped &0B00-&0BFF allocation on Model B. Not available for any other use
&8400-&88FFVDU workspace (flood-fill scratch)Routines tag &8601 to share; commercial software should avoid
&8900-&8FFFSoft character definitionsMoved from &0E00+ on B/B+ — exploded font no longer steals from user RAM. Big PAGE win
&C000-&DBFFHAZEL (paged-ROM workspace)ROMs claim via service calls; static workspace requires filing-system pattern
&DC00-&DCFFMOS CLI bufferCorrupted by every * command
&DD00-&DEFFTransient utility workspaceUsed by user * commands and *MOVE
&DF00-&DFFFMOS private workspaceOff-limits

The soft-character-definition relocation from &0E00+ to &8900 is one of the Master’s biggest practical wins: on a Model B, defining 32 custom characters cost 256 bytes of OSHWM. On Master those bytes live in the second 32 KB invisibly. Code that explicitly pokes &0E00-area font on a Model B needs a Master code path that targets &8900 instead — see memory-map for the broader map.

Master vector additions (&0D9F-&0DEF)

Per ARM Ch 11, the Master allocates 80 bytes for extended vectors at &0D9F-&0DEF. These let a sideways-ROM intercept any vector with the routine living in the ROM — without the ROM having to be in slot 15 or whatever. Mechanism:

  1. OSBYTE &A8 (168) returns the start of the extended-vector space (&0D9F).
  2. Write the per-vector triple at extended_start + 3 × vector_index: <entry_low> <entry_high> <rom_slot_number>.
  3. Replace the normal vector at &02xx with &FF00 + (vector_addr - &0200) × 3 / 2 — a special address the MOS recognises as “this dispatches via the extended vector triple”.

This is how things like the Master’s ADFS filing system, network filing system, and other complex ROM-resident handlers intercept vectors cleanly without trampling each other. The MOS handles ROM-bank switching on each dispatch via the extended vector.

Vector-number indexing (per ARM Ch 11 vector table): vector_number = (vector_addr - &0200) / 2. So OSWRCH (vector &20E) is vector number 7, OSWORD (&20C) is 6, OSBYTE (&20A) is 5, EVNTV (&220) is 16, etc.

See also

  • zero-page — Page 0 detail.
  • memory-map — Big picture.
  • calls — OS entry-point reference.
  • interrupts — IRQ handler conventions and &FC usage.
  • paged-roms — extended vectors install pattern (the high-level companion to the &0D9F-&0DEF detail above).

Measured in practice — reclaiming MOS workspace in two C64 → BBC ports (2026)

Source: beeb-port-kit-hardware-facts — facts measured during Kieran Connell’s two C64 → BBC ports, Paradroid (BBC Model B, August 2026) and Edge Grinder (BBC Master 128, September 2026). Instrument is jsbeeb driven through an MCP unless the entry says otherwise; b-em and b2 were the cross-checks. Each entry gives the date (or the port’s layer where the write-up carries no date), the emulator or hardware, and the port’s own write-up. Both ports own the machine outright once loaded (IRQ1V taken, no return to BASIC), which is the “going fully native” case above; the table says what each page cost to reclaim and when it became safe.

RangeWhat it isYours whenTrap
&0100-&017Fbottom half of the stack pagemeasured untouched through play, deck load, console and game over including *LOADs (Paradroid)not loadable from disc; paths not exercised invalidate the measurement
&0400-&07FFlanguage workspaceafter *RUN (Edge, verified by sentinel)Paradroid’s briefing lives here; the ceiling is &0800
&0800-&08FFMOS sound: &800-&83F workspace, &840-&87F channel queues, &8C0-&8FF envelopesonly while you own IRQ1Vsee “the MOS plays your data as notes” below
&0800-&0BFFsound, serial, soft keysonce the MOS interrupt is gone (Edge, sentinel)
&0A00printer buffersurvives BASIC exec, DFS loads, VDU 22 (Paradroid)inside a loader’s tables — a byte parked here did not survive a program unpacking over &0400-&1BFF
&0C00-&0CFFuser-defined charactersonce the MOS is not printingon the Master the real font is at &8900 (master-overview), so Edge keeps player state here
&0D00-&0D5FNMI routine (DFS)never while the disc is in use
&0D9F+extended vector table: the route ANY sideways ROM takes when it claims a vector, filing system or notnever safely, if you make OS calls afterwardsOSBYTE 140 does NOT make it yours — it is the MOS’s, not the filing system’s. Paradroid buries it and carries the question open (#18)
&0DF0-&0DFFROM private workspaceexcludedon a Master front end the MOS still runs, paged ROMs 9 and 13 read it (Stryker’s Run)
&0E00-&10FFDFS shared workspaceafter OSBYTE 140, or while you own the machine outrightnothing may be LOADED there; and it need not end where Acorn DFS’s does — OSHWM is the only thing that says where this machine’s filing system stops
&1100-&18FFDFS random-access buffers, untouched by *LOAD/OSFILEimmediately — Paradroid RUNS here; worth 2K below PAGE = &1900*EXEC writes here, and so does closing an exec file: a game living here must boot by *RUN. Acorn-DFS-specific either way

Measured: Paradroid Layers 3, 11e, 13 (August 2026), jsbeeb; Edge Layer 2 onward (September 2026), jsbeeb — Paradroid CLAUDE.md, layer-11e-sound.md, layer-13-compatibility.md, Edge CLAUDE.md. The table’s last four rows were revised 2026-11-18 from the kit’s later version (beeb-port-kit-hardware-facts-2026-11 §6, after hexwab on paradroid-beeb #18).

Two ways to take the filing system’s workspace (hexwab, paradroid-beeb #18, 2026-09-13)

Most of the table is workspace the filing system still owns. The kit’s rule (beeb-port-kit-hardware-facts-2026-11 §6):

  • A loader, which still has to load, cannot shut the filing system down. It borrows the workspace and must own the machine while it does: claim the NMI (OSBYTE 143,12,255, RTI at &0D00) and let no OS code run at all — no OS call, no MOS interrupt handler.
  • A game that has finished loading calls OSBYTE 140 (what *TAPE ends up calling) while the workspace is still intact. The filing system detaches every hook and stops its hardware raising NMIs; only then is the workspace yours (zero page &B0-&CF included) and an OS call safe afterwards. The price: nothing may load again — 140 selects the tape FS and there is no safe way back.
  • A third answer, on a Master: OSBYTE 140 after the boot’s last load, then drive the 1770 yourself (1942, phX) — see wd1770.
  • A filing system is entitled to hook OSBYTE, OSWORD and the vectors and find its workspace intact. Acorn’s DFS hooks none, which is the only reason a game that skips 140 appears to work: Paradroid (workspace buried, OSBYTE 229/&0F/19 called, no 140) hung on an Opus 1770 with DDOS 3.45 on real hardware (hexwab, 2026-09-13).
  • Nothing guarantees FS workspace stops at &1900. Another filing system’s OSHWM can be higher, and MMFS in sideways RAM puts it lower, at &0E00. Put code as high as you can and read OSHWM (hexwab; not measured).
  • *EXEC hangs a game at &1100 once OSBYTE 140 is in the boot: Paradroid’s *EXEC-booted dev disc went black inside the DNFS ROM at &ACB1, ROMSEL 14, while the *RUN disc was fine; OSBYTE 119 (close the exec file) hung identically, because the close is itself a write there (jsbeeb B-DFS1.2, 2026-09-13). Boot by *RUN.

MOS low RAM on a Master, measured through a whole game (MOS 3.20)

1942, 2026-10-07, jsbeeb Master (tools/measure_lowram.mjs, tools/measure_break.mjs, decision 141 L2) — a game that owns IRQ1V and the NMI (beeb-port-kit-hardware-facts-2026-11 §6):

Free (unwritten through a whole driven game, not read by soft BREAK)Read by BREAK — leave alone
&0100-&01BF (stack peaked 41 bytes deep, at &01D7)&0218-&021F
&0200-&0217 except IRQ1V&0280-&0287 (and &0287-&0289 if you arm the BREAK intercept)
&0220-&027F, &028A-&029F, &02B0-&03FF&02A0-&02AF
&0D9F-&0DFF; zero page &A0-&A7 once OSBYTE 140 has given you the NMI

“Read by BREAK” was found by filling each block with four patterns, pressing BREAK and requiring the MOS banner and *FX 0’s OS 3.20. Until IRQ1V is yours the MOS’s 100 Hz IRQ writes &02B1-&02BE (unpack into those after the takeover); while the MOS still owns IRQ1V it writes 27 bytes in &0240-&02CD under a program that only spins (kit, 2026-10-25, jsbeeb 2.10.2, lib/test/range_free.mjs). Stryker’s Run also measured &0982-&0CFF (a !BOOT and loader’s pages) free in play, by watches over every phase. Not measured on hardware or MOS 3.5.

phX’s use, played on KC’s real Master (after *FX 140, its own NMI and IRQ): the zero page all its own except &A0 (its 1770 NMI’s), &F4 (ROMSHAD, written with ROMSEL always) and &FC (the IRQ’s saved A) — the MOS’s &E0-&FF included; &0D40-&0D9E of the NMI page for overlay code (its NMI routine at &0D00, its BREAK intercept at &0D20) (phX/docs/memory-map.md, phX/CLAUDE.md). See zero-page.

The OS’s hooks are regions too. The BREAK intercept’s JMP at &0287-&0289 is three bytes a page-2 overlay can take: phX’s did, 196 fields in, and 1942 put two variables at &0288. See break-intercept.

  • The MOS plays your data as notes. Hand IRQ1V back with a charset over &0800-&08FF and the MOS’s 100 Hz sound driver finds its queue pointers and buffers full of bitmaps: a quiet, rising sequence that a game’s own mute cannot touch (chip read CH0 attenuation 14, CH1 13, periods falling 401 → 146 → 95). Zeroing &0800-&087F stopped it instantly. Sound suppression (OSBYTE &D2) does NOT stop it — it gates new SOUND commands, not a draining queue. OSBYTE &0F, X=0 (flush every buffer) BEFORE uninstalling the IRQ is the fix (Paradroid, 2026-08-26, jsbeeb). See sound.
  • The MOS’s 100 Hz IRQ writes &0800-&08FF while it owns the machine, so a compressed stream staged there at boot is corrupted mid-decode: one byte changed sends the depacker off a wrong offset (542 wrong bytes across a credits screen, found by diffing the depacked screen, not by looking at it). &1100 is the safe staging address on a Model B (Paradroid, 2026-08-30, jsbeeb). See zx0-loading.
  • VDU 22 clears &3000-&7FFF, what the OS thinks is its screen, so data loaded above &3000 is wiped before it can be read; it also re-enables R8 and the cursor (Paradroid Layer 3; Edge 2026-09-02). See vdu. The same goes for code: a *RUN image loaded before the boot’s mode change loses everything at or above &3000 before it runs, so the code ceiling is &3000 even where the screen ends up in shadow; 1942 found it by not booting, with no diagnostic (BUGS #17). On a Master the mode change also lights the display for ~5 fields with whatever main RAM held: zero &3000-&7FFF first (beeb-port-kit-hardware-facts-2026-11 §6).
  • The MOS keeps a copy of the ULA control register at &0248 (MOS_ULA_COPY), and its flash timer EORs the flash bit into it and writes &FE20 from it; a program that writes &FE20 itself while the MOS IRQ still runs (a loader, a title screen) must write &0248 too, or the next flash tick puts the old mode’s byte back (1942 src/lib/beeb.h.6502, 2026-09, a Master port). See video-ula.
  • Zeroing &0242 (the keyboard polling byte, OSBYTE &B2) stops the 100 Hz tick’s key scan; clearing bit 1 of &0279 (System VIA IRQ mask, OSBYTE &E9) stops the MOS taking VSync (Stryker’s Run, 2026-10-16). See interrupts.

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.