mk90.system

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

RangeUse
0000–00FFVectors; RTC at 0040, keyboard at 00C8.
0100–01FFBootstrap initially; then 256-byte pipe FIFO.
0200–05BF120×64 monochrome framebuffer, 960 bytes.
0600–069BKernel and controller globals.
06A0–06EFTwo 40-byte file descriptors.
06F0–06FFProcess/module-cache state.
0700–071FKeyboard queue storage.
0720–075FFour 16-byte block-device records.
0760–07AFFour 20-byte task-control blocks.
07B0–07EFBASIC compiler/runtime state.
07F0–07FFPipe control, eight words.
0800–2A3FResident kernel area.
2A40–2C3F512-byte active MKS2 metadata buffer.
2C40–2D3FTMP/COPYBUF, 256-byte data scratch buffer.
2D40–2E3FVERIFY; also runtime bytecode cache.
2E40–2F6BText console, 300 bytes.
2F6C–3097Text shadow, 300 bytes.
30A0–30FFNormalized path, 96 bytes.
3100–315FCurrent directory, 96 bytes.
3160–316FFilename scratch.
3180–319F / 31A0–323FPID 1 private data / 160-byte stack.
3240–325F / 3260–32FFPID 2 private data / 160-byte stack.
3300–37FFOrdinary lower application window, 1,280 bytes.
3800–3CFFPager module or 1,280-byte editor buffer.
3D00–3DFFShell input/arguments and application paths; reused by BASIC.
3E00–3FFF512-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 / offsetPurpose
0000–01FFBootstrap area.
0200 onwardResident image, 8,752 bytes.
2480 onward, below 3D00First region of verified native application modules.
3D00–3D7FAdditional EXEC help record.
3FDEWhole-ROM checksum word.
3FE0 / 5FE0 / 7FE0Distinct 32-byte addressing markers.
4000–4FFFFirst 32 compact help records.
5000 onward, below markerCompact messages and diagnostics.
6000–7FFF8 KiB read-only MKS2 system volume; its data also contains module storage.
6500 onwardRemaining native modules in the system volume’s data area.
7D00–7EFFFK 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.