Memory and application loading
Build-specific layout of the 16 KiB RAM and the 32 KiB cartridge.
Memory model
All addresses on this page are hexadecimal byte addresses; range ends are inclusive unless stated otherwise. The CPU executes native code from RAM. The SMP ROM is storage accessed through the controller, rather than an extra 32 KiB of CPU memory.
The kernel occupies 8,752 of the 8,768 bytes assigned to its resident area, leaving 16 bytes there. This is not 16 bytes of total system free RAM; the rest is assigned to fixed data, buffers, stacks and loadable module windows.
RAM layout
| Range | Use |
|---|---|
| 0000–00FF | Vectors; RTC at 0040, keyboard at 00C8. |
| 0100–01FF | Bootstrap initially; then 256-byte pipe FIFO. |
| 0200–05BF | 120×64 monochrome framebuffer, 960 bytes. |
| 0600–069B | Kernel and controller globals. |
| 06A0–06EF | Two 40-byte file descriptors. |
| 06F0–06FF | Process/module-cache state. |
| 0700–071F | Keyboard queue storage. |
| 0720–075F | Four 16-byte block-device records. |
| 0760–07AF | Four 20-byte task-control blocks. |
| 07B0–07EF | BASIC compiler/runtime state. |
| 07F0–07FF | Pipe control, eight words. |
| 0800–2A3F | Resident kernel area. |
| 2A40–2C3F | 512-byte active MKS2 metadata buffer. |
| 2C40–2D3F | TMP/COPYBUF, 256-byte data scratch buffer. |
| 2D40–2E3F | VERIFY; also runtime bytecode cache. |
| 2E40–2F6B | Text console, 300 bytes. |
| 2F6C–3097 | Text shadow, 300 bytes. |
| 30A0–30FF | Normalized path, 96 bytes. |
| 3100–315F | Current directory, 96 bytes. |
| 3160–316F | Filename scratch. |
| 3180–319F / 31A0–323F | PID 1 private data / 160-byte stack. |
| 3240–325F / 3260–32FF | PID 2 private data / 160-byte stack. |
| 3300–37FF | Ordinary lower application window, 1,280 bytes. |
| 3800–3CFF | Pager module or 1,280-byte editor buffer. |
| 3D00–3DFF | Shell input/arguments and application paths; reused by BASIC. |
| 3E00–3FFF | 512-byte stack shared by PID 0 and PID 3. |
BASIC overlays and workspace
In BASIC mode the application region is repartitioned: 3300–367F is an 896-byte lower phase, and 3680–3CFF is a 1,664-byte common module. These are alternate uses, not extra simultaneous windows.
During compilation, TEXT/SHADOW provide a 256-byte source cache and a 256-byte table of up to 64 line-number/offset pairs. The compiler restores the text console after releasing that workspace.
During execution, 3D00–3D33 holds A–Z, 3D40–3D9F holds a data pathname and 3DA0–3DDF holds eight FOR/GOSUB frames. The operand stack uses the foreground stack with an explicit limit of 16 values.
ROM layout
| ROM byte range / offset | Purpose |
|---|---|
| 0000–01FF | Bootstrap area. |
| 0200 onward | Resident image, 8,752 bytes. |
| 2480 onward, below 3D00 | First region of verified native application modules. |
| 3D00–3D7F | Additional EXEC help record. |
| 3FDE | Whole-ROM checksum word. |
| 3FE0 / 5FE0 / 7FE0 | Distinct 32-byte addressing markers. |
| 4000–4FFF | First 32 compact help records. |
| 5000 onward, below marker | Compact messages and diagnostics. |
| 6000–7FFF | 8 KiB read-only MKS2 system volume; its data also contains module storage. |
| 6500 onward | Remaining native modules in the system volume’s data area. |
| 7D00–7EFF | FK keyword dictionary. |
Module loading rules
The loader validates the module ID, native module ABI 3, destination window, size, ROM bounds and checksum. PID 0 can request normal loads. PID 3 can request only its registered BASIC family. Background contexts cannot load arbitrary modules.
Compiler phase changes pass through the upper common module, which restores the lower caller before returning. The runtime keeps fetch, arithmetic and control flow in the upper module; lower device/graphics/file phases always return to the stable dispatcher before another phase can replace them.
A native pipeline uses the ordinary lower window for its producer and the pager window for its consumer. The active pipe prevents every replacement load until both contexts have finished.