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:
| Range | Use |
|---|---|
&800-&83F | Sound workspace |
&840-&84F | Sound channel 0 |
&850-&85F | Sound channel 1 |
&860-&86F | Sound channel 2 |
&870-&87F | Sound channel 3 |
&880-&8BF | Printer buffer (distinct region — NOT shared with sound) |
&8C0-&8FF | Envelope storage 1-4 (13 bytes each + 3 spare) |
&900-&9BF | RS423 output buffer — OR Envelopes 5-16 — OR (overlap) CFS/RFS BPUT sequential output buffer |
&9C0-&9FF | Speech buffer — overlapped by CFS/RFS BPUT output buffer when CFS active |
Page B (&0B00-&0BFF) — Function keys
| Range | Use |
|---|---|
&B00-&B10 | Soft key pointers (one per function key) |
&B11-&BFF | Soft 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
| Range | Use |
|---|---|
&D00-&D5F | NMI handling code (filing systems install here) |
&D60-&D7F | Econet workspace |
&D80-&D91 | Unused on most machines |
&D92-&D9E | Reserved for trackerball |
&D9F-&DEF | Extended vector table (paged-ROM-claimed extra vectors) |
&DF0-&DFF | ROM 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:
| Range | Use |
|---|---|
&200-&235 | OS vector table (see calls) |
&236-&28F | OS variables — accessible via OSBYTE &A6-&FF. Direct read is faster than OSBYTE. |
&290-&291 | *TV vertical adjust + interlace |
&292-&296 | TIME — first copy (dual-clock to allow atomic 5-byte read) |
&297-&29B | TIME — second copy |
&29C-&2A0 | Interval timer (OSWORDs &03/&04) |
&2A1-&2B0 | Paged ROM table (OSBYTE &AA/&AB) |
&2B1-onwards | INKEY 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:
| Addr | What | OSBYTE-var # |
|---|---|---|
&020E-&020F | OSWRCH vector | — |
&024A | ROM active at last BRK | &BA (fx186) |
&0261 | Speech suppression status | &D1 (fx209) |
&0262 | Sound suppression status | &D2 (fx210) |
&0277 | User VIA IRQ mask | &E7 (fx231) |
&0279 | System VIA IRQ mask | &E9 (fx233) |
&027C | Output stream destination (FX3) | &EC (fx236) |
&027D | Cursor key status (FX4) | &ED (fx237) |
&028C | Current language ROM (but see the Master caveat below) | &FC (fx252) |
&028D | Last 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):
| Range | Use |
|---|---|
&300-&30B | Current graphics window (&300-&307, pixels) + text window (&308-&30B, chars) |
&30C-&30F | Graphics origin (external coords) |
&310-&317 | Current + old graphics cursor (external coords) |
&318-&319 | Text cursor X / Y |
&31A | Line within graphics cell of cursor |
&31B | Graphics workspace / VDU queue control |
&31F-&323 | VDU queue (5 bytes) |
&324-&327 | Current graphics cursor (internal coords) |
&328-&32F | Bitmap read from screen by OSBYTE 135 |
&330-&349 | Graphics workspace |
&34A-&34B | Text cursor address for 6845 |
&34C-&34D | Text window width in bytes |
&34E | MSB of HIMEM (ignoring shadow) |
&34F | Bytes per character (current mode) |
&350-&351 | Top-left screen address as given to 6845 — this is the screen-start mirror for hardware scroll |
&352-&353 | Bytes per char row (current mode) |
&354 | Screen mode size in pages |
&355 | Current screen mode (ignoring shadow bit) |
&356 | Screen size code: 0=20K, 1=16K, 2=10K, 3=8K, 4=1K |
&35F | Last 6845 cursor start register value |
&360 | Logical colours - 1 |
&361 | Pixels per byte - 1 (0 for text) |
&362-&363 | Bit masks for left-most and right-most pixel |
&366-&36E | VDU 23 settings (Master ECF, dot patterns, etc.) |
&36F-&37E | Font location bytes (MSB per font group) |
&37F | Unused |
&380-onwards | Colour 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-&8Fand whatever else you touch (see zero-page). - OS palette (
&FE21+ page 3 colour palette copy at&380+): if you wrote&FE21directly, also write the same value (XOR 7) into the OS copy, or restore the original. &350/&351if you moved R12/R13.- IRQ vectors
&204-&207if 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:
| Range | Use | Note |
|---|---|---|
&3000-&7FFF | LYNNE shadow screen | Any portion not needed by the current mode is free; *MOVE will use it |
&8000-&83FF | Soft-key expansion buffer | 1 KB — replaces the cramped &0B00-&0BFF allocation on Model B. Not available for any other use |
&8400-&88FF | VDU workspace (flood-fill scratch) | Routines tag &8601 to share; commercial software should avoid |
&8900-&8FFF | Soft character definitions | Moved from &0E00+ on B/B+ — exploded font no longer steals from user RAM. Big PAGE win |
&C000-&DBFF | HAZEL (paged-ROM workspace) | ROMs claim via service calls; static workspace requires filing-system pattern |
&DC00-&DCFF | MOS CLI buffer | Corrupted by every * command |
&DD00-&DEFF | Transient utility workspace | Used by user * commands and *MOVE |
&DF00-&DFFF | MOS private workspace | Off-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:
OSBYTE &A8(168) returns the start of the extended-vector space (&0D9F).- Write the per-vector triple at
extended_start + 3 × vector_index:<entry_low> <entry_high> <rom_slot_number>. - Replace the normal vector at
&02xxwith&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
&FCusage. - 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.
| Range | What it is | Yours when | Trap |
|---|---|---|---|
&0100-&017F | bottom half of the stack page | measured untouched through play, deck load, console and game over including *LOADs (Paradroid) | not loadable from disc; paths not exercised invalidate the measurement |
&0400-&07FF | language workspace | after *RUN (Edge, verified by sentinel) | Paradroid’s briefing lives here; the ceiling is &0800 |
&0800-&08FF | MOS sound: &800-&83F workspace, &840-&87F channel queues, &8C0-&8FF envelopes | only while you own IRQ1V | see “the MOS plays your data as notes” below |
&0800-&0BFF | sound, serial, soft keys | once the MOS interrupt is gone (Edge, sentinel) | |
&0A00 | printer buffer | survives 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-&0CFF | user-defined characters | once the MOS is not printing | on the Master the real font is at &8900 (master-overview), so Edge keeps player state here |
&0D00-&0D5F | NMI 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 not | never safely, if you make OS calls afterwards | OSBYTE 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-&0DFF | ROM private workspace | excluded | on a Master front end the MOS still runs, paged ROMs 9 and 13 read it (Stryker’s Run) |
&0E00-&10FF | DFS shared workspace | after OSBYTE 140, or while you own the machine outright | nothing 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-&18FF | DFS random-access buffers, untouched by *LOAD/OSFILE | immediately — 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,RTIat&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*TAPEends 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-&CFincluded) 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 140after 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/19called, 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). *EXEChangs a game at&1100once OSBYTE 140 is in the boot: Paradroid’s*EXEC-booted dev disc went black inside the DNFS ROM at&ACB1, ROMSEL 14, while the*RUNdisc was fine;OSBYTE 119(close the exec file) hung identically, because the close is itself a write there (jsbeebB-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-&08FFand 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-&087Fstopped it instantly. Sound suppression (OSBYTE &D2) does NOT stop it — it gates newSOUNDcommands, 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-&08FFwhile 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).&1100is the safe staging address on a Model B (Paradroid, 2026-08-30, jsbeeb). See zx0-loading. VDU 22clears&3000-&7FFF, what the OS thinks is its screen, so data loaded above&3000is 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*RUNimage loaded before the boot’s mode change loses everything at or above&3000before it runs, so the code ceiling is&3000even 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-&7FFFfirst (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&FE20from it; a program that writes&FE20itself while the MOS IRQ still runs (a loader, a title screen) must write&0248too, or the next flash tick puts the old mode’s byte back (1942src/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.