Architecture
A RamWorks card gives the enhanced IIe extra 64K banks of
auxiliary memory, and one register, $C073, chooses which bank the
auxiliary-memory switches see. maux gives each process one of those banks.
Because ALTZP moves the zero page and the hardware stack along with it, a
bank switch swaps the registers' working set, the stack and the whole address
space in one motion.
Every process sees the same logical address space from $0000,
so nothing is relocated and an ordinary assembler's output runs as it is.
It is a poor man's MMU with 64K pages.
1. Who owns what
AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYTpmNTI5YjYxYi05ODJhLTQ3MmYtYTZjYy1hOGY2MzMzOGE2NDcAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAAAKoAOJtxE2MycGEuaW5ncmVkaWVudC52MwAAAAAYYzJzaJVQdnhmvrk/KvAzBcnjnHgAAABwY2JvcqNpZGM6Zm9ybWF0bWltYWdlL3N2Zyt4bWxqaW5zdGFuY2VJRHgseG1wOmlpZDpiNWU0YjY0Yi04ZjJiLTQ4ZDEtOWE1NS01MDNiYzY1ODdlNDZscmVsYXRpb25zaGlwaHBhcmVudE9mAAAB4mp1bWIAAABBanVtZGNib3IAEQAQgAAAqgA4m3ETYzJwYS5hY3Rpb25zLnYyAAAAABhjMnNo9Tl2uaplfXnHQ7akemnvEwAAAZljYm9yomdhY3Rpb25zgqJmYWN0aW9ua2MycGEub3BlbmVkanBhcmFtZXRlcnOha2luZ3JlZGllbnRzgaJjdXJseC1zZWxmI2p1bWJmPWMycGEuYXNzZXJ0aW9ucy9jMnBhLmluZ3JlZGllbnQudjNkaGFzaFggid9u4KCIEdAF2hQhTh9hmr/5QsojjKcpDP+nvE6+3mSkZmFjdGlvbngdY29tLmFudGhyb3BpYy5jbGF1ZGUucHJvdmlkZWRqcGFyYW1ldGVyc6F4H2NvbS5hbnRocm9waWMub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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQA6dAW4TZwYl2rMHAnhdVegufnN4/1Jhx+2iwBPrdPldKBRfu62tCz7A/F9Meho9LXGEpTMkIcTyWzXGubSQCzs=
Who owns what: main memory, aux bank 0, and one aux bank per process
Three kinds of 64K block. Main memory holds the kernel and ProDOS 8. Aux bank 0 is the kernel annex and the only bank the video scanner reads. Every other aux bank is one process, with its own zero page, stack, program and a stub page at $FF00.
MAIN 64K
AUX BANK 0
AUX BANK 1, 2, 3 ...
the kernel and ProDOS 8
the kernel annex
one process each
kernel zero page and stack
kernel code: org $2000, up to about $97E8; it borrows the hires pages for itself
text page 1 stays the display; ProDOS's $BF00 global page is here
$C000-$CFFF is not RAM: I/O and slot ROM
language card: ProDOS 8's (MLI, drivers). maux's own use is bank 2: the bye resident at $D100 and the kernel cold segment at $D400. $FF00: ProDOS's page
PCB array (one slot per process), cwd table, pipe rings, lazy-free tag pathnames
alternate-screen stores, per-console foreground job table
80-column text, aux half: the video scanner reads bank 0 and no other
never scheduled as a process: its zero page and stack are unused
own zero page ($0000, via ALTZP)
own stack ($0100, via ALTZP)
program and data $0200-$BFFF own language card view $D000-$FEFF no relocation: every process sees $0000 up
$C000-$CFFF is never process memory
$FF00-$FFFF: syscall and IRQ stubs
Selected by one write to $C073 (RamWorks bank select; write-only).
Main memory, the annex in aux bank 0, and one bank per process.
Main memory holds the kernel and ProDOS 8, which shares the machine. The
shipped kernel is assembled at $2000 and runs up to about
$97E8, so it borrows the hires pages for itself; text page 1 stays the
display. The language card is ProDOS 8's (the MLI and its drivers), and the
$BF00 global page is in main RAM. maux's own use of the card is bank 2:
the bye resident window at $D100-$D3FF and the kernel's cold
segment at $D400. The $FF00 vector page is ProDOS's too; maux
patches two bytes of it, the IRQ vector.
Aux bank 0 is the kernel's annex: the process table, the per-process working
directories, the pipe rings and the other per-process kernel structures. It has to be
bank 0 because the video scanner reads auxiliary memory from bank 0 and nowhere else (see
the 80STORE story below). Every other bank is one process.
User space is $0000-$BFFF plus $D000-$FEFF. The
whole $C000-$CFFF window is carved out: it is I/O and slot ROM,
always main, never process memory. The kernel's entire footprint in a
process bank is the $FF00-$FFFF page the hardware already claims
for vectors.
The release kernel does not probe for banks. It starts with a fixed list: banks
15 down to 2 are free for processes, and the shell is bank 1. So maux uses banks
$00 to $0F and nothing else. It needs a RamWorks-compatible card
with at least 1,024 KB (a period RamWorks II or III main board fully
populated gives exactly that), and it runs at most 15 processes besides the
kernel. The bye save banks come from the same list. A boot-time bank probe exists
in the tree and is linked only into a test image. The population the gates exercise is
dense; sparse and aliased cards are not verified.
2. A context switch
AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYTo2NjljYzdiZi01NDU4LTRmMGYtYjE5Yy1kMmE3MzBhOTFkMzQAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQAbLy2qZbAoyGzQr8zix5IQBmV7pZ4m/S2vclftap6KbW8dZwfysnnk+zxZ6nwKfLFy7XzDoZJWmR0WKmJ/dpRc=
A context switch, step by step
A process takes a syscall or interrupt. Its own $FFxx page pushes a six byte frame on its own stack and switches reads and writes to main memory. The kernel then switches the zero page and stack to main, picks the next process, writes the new bank number to $C073, switches the zero page and stack back to aux, and returns with RTI.
process A (bank 3)
process B (bank 5)
the kernel (main memory)
1. JSR $FF00 or IRQ
2. the call or IRQ already pushed PC (and P, for an IRQ); its $FFxx stub pushes P (syscall door) and A,X,Y on ITS stack 3. RAMRD/RAMWRT -> main
9. exit tail: RAMRD/ RAMWRT -> aux,
restore A,X,Y 10. RTI: B runs on, B's PC, B's stack
4. TSX (A's SP); ALTZP -> main: zero page and stack are now the kernel's own
5. load kernel SP; serve the call or the tick; choose next = B
6. save A's SP in its PCB
7. write 5 to $C073 <-- the switch
8. ALTZP -> aux, then TXS from B's saved SP (no push in between: page 1 is now B's stack)
Registers, zero page, stack and the address space all change with one bank number and a few soft switches.
One interrupt, process A to process B.
Both ways into the kernel, the JSR $FF00 syscall door and the
interrupt door, build the same six-byte frame on the process's own stack, so
one exit tail serves both. The kernel then switches ALTZP and the stack
pointer to its own, does its work, writes the next process's bank number to
$C073, flips ALTZP back, and returns by RTI onto
the other process's stack. The one rule inside the switch is that nothing is
pushed between the ALTZP flip and TXS: for that moment the stack
page belongs to somebody else.
Preemption comes from a 60 Hz tick. At boot the kernel probes for an AppleMouse
card and uses its vertical-blanking interrupt; failing that, it looks for a Mockingboard
and runs the 6522's timer 1 free-running at about 60 Hz. With neither, no hardware source is
armed and the tick counter never advances. Writes to
$C073 also trip the paddle strobe, so joystick reads need the
scheduler held briefly. The register is write-only and is not cleared by a
reset, so the kernel never trusts what it last selected: it keeps its own
copy of the current bank and writes the register before any aux access.
What this does not buy is protection. Soft switches are plain addresses,
and any process can write $C073, flip RAMRD or execute
SEI. Bank-per-process gives isolation for correctness, not
security: a well-behaved process cannot touch another by accident, and a
wild store into $C0xx can take the machine down.
3. fork, and the trap in the copy
AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYTo3MzMzNmU2MC0xY2I5LTQ2YjMtYmI1Yi04NGFmYmE5ZjM3OGIAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAAAKoAOJtxE2MycGEuaW5ncmVkaWVudC52MwAAAAAYYzJzaFYOhQiJ9caAOxwjUw21srkAAABwY2JvcqNpZGM6Zm9ybWF0bWltYWdlL3N2Zyt4bWxqaW5zdGFuY2VJRHgseG1wOmlpZDo4YmFkNzE5MC1hMTY3LTQwNDktOGY0NS0zYWY4OWE1NmNjZDdscmVsYXRpb25zaGlwaHBhcmVudE9mAAAB4mp1bWIAAABBanVtZGNib3IAEQAQgAAAqgA4m3ETYzJwYS5hY3Rpb25zLnYyAAAAABhjMnNok8nzy5NgFHWt1R0PEL1AhgAAAZljYm9yomdhY3Rpb25zgqJmYWN0aW9ua2MycGEub3BlbmVkanBhcmFtZXRlcnOha2luZ3JlZGllbnRzgaJjdXJseC1zZWxmI2p1bWJmPWMycGEuYXNzZXJ0aW9ucy9jMnBhLmluZ3JlZGllbnQudjNkaGFzaFgg0eRTGNliwpi9PkoBZnWp5KpnSz7QWsoDv0tRtZQ5gn+kZmFjdGlvbngdY29tLmFudGhyb3BpYy5jbGF1ZGUucHJvdmlkZWRqcGFyYW1ldGVyc6F4H2NvbS5hbnRocm9waWMub3JpZ2luLWNvbmZpZGVuY2VndW5rbm93bmtkZXNjcmlwdGlvbnhmQ2xhdWRlIHByb3ZpZGVkIHRoaXMgZmlsZSBhdCB0aGUgcmVxdWVzdCBvZiBhIHVzZXIg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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQO3HGYb8F6vCTRFmNbFkVE0eUKPg29AEcnyoy9sC81mPhI2iRvFwL0jJDogB3lLLdIZpEuBzSoKW5mMg2FCaQMs=
The 80STORE trap in a bank copy
Left: fork copies a process bank into a new bank. Without the bracket, with 80STORE set, the copy of the text page window reads and writes main memory instead of the aux bank, so main is copied onto itself and the child never receives that window. Right: with the bracket, 80STORE is cleared for the copy and set again after, and the window arrives.
Unbracketed copy of $2000-$3FFF
With CLR80STORE ... SET80STORE
parent bank window holds the program's data
child bank window stays empty: it never arrives
main memory read AND written: copied onto itself, silently
parent bank window holds the program's data
child bank window arrives, byte for byte
With 80STORE set, RAMRD and RAMWRT are ignored for $0400-$07FF
and (with HIRES) $2000-$3FFF; PAGE2 alone routes them. No crash, no log.
The gate, check-fork, forks with 80STORE
and HIRES both set, because with the
switches off it passes with the bracket
deleted. The documentation already says
so; the first fork design, reasoned
from first principles, missed it.
A bank copy that silently copies main onto itself.
The primary way to start a program is spawn: allocate a bank,
stamp its $FFxx page, load the image, apply the file-descriptor
actions. Nothing is copied from a parent. fork exists too, as the
slow path for programs that need it: it clones the process's bank.
The copy is where the trap is. With 80STORE set, RAMRD and RAMWRT are
ignored for $0400-$07FF and, with HIRES also set, for
$2000-$3FFF; only PAGE2 routes them. A bank-copy loop that does
not bracket those windows with CLR80STORE and SET80STORE reads and writes
main memory instead of the aux bank, so main is copied onto itself. Nothing
crashes and nothing is logged; the child simply never receives that window.
maux's first fork design was reasoned from first principles and had no
bracket, and it was wrong: the IIe's documented soft-switch behaviour
says exactly what 80STORE does to those windows. The design was corrected from the documentation, and the gate for
fork sets both switches on purpose, because with them off it
passes with the bracket deleted. Hardware claims on this site, and in the
tree, are checked against the manuals and on an emulator, not against
what seems plausible.
4. bye: leave maux, run ProDOS, come back
AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYTozMjExODIyZi1kMjZiLTRhNTUtOTU5NS1lOWQyYTYyMWQ0MWQAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAAAKoAOJtxE2MycGEuaW5ncmVkaWVudC52MwAAAAAYYzJzaOsxTf69Nw8EUdwgi/2c2OMAAABwY2JvcqNpZGM6Zm9ybWF0bWltYWdlL3N2Zyt4bWxqaW5zdGFuY2VJRHgseG1wOmlpZDplZGE2NDgxMi1iZDk0LTQ1ZjAtOGZlZi1jOGMwZmUwNzFmZWNscmVsYXRpb25zaGlwaHBhcmVudE9mAAAB4mp1bWIAAABBanVtZGNib3IAEQAQgAAAqgA4m3ETYzJwYS5hY3Rpb25zLnYyAAAAABhjMnNoMGRgu6eye5t5uokcPCFXpgAAAZljYm9yomdhY3Rpb25zgqJmYWN0aW9ua2MycGEub3BlbmVkanBhcmFtZXRlcnOha2luZ3JlZGllbnRzgaJjdXJseC1zZWxmI2p1bWJmPWMycGEuYXNzZXJ0aW9ucy9jMnBhLmluZ3JlZGllbnQudjNkaGFzaFgg4pdf0/ZpfastSMX0LqkfO+5w+lYx5xH5GR0CIp8brI6kZmFjdGlvbngdY29tLmFudGhyb3BpYy5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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQNe967aWjRwstXf5rCNVl39acWsYD0Xg8qX5BSb6U1IZAk6Ak3vxz8d51QnDSW+bcwWc2HCcxnJHTnifoNKuOx8=
bye: suspend maux, run a ProDOS program, come back
Three stages left to right. Before: maux is running. During: main memory and the annex are saved into two RamWorks banks that plain ProDOS cannot see, a small resident sits at $D100 in language card bank 2, /RAM is reinstalled empty, and a ProDOS 8 program runs on what looks like a freshly booted machine. After: the program calls QUIT, ProDOS copies the window at $D100 to $1000 and jumps there, and the resident copies the saved state back, removes /RAM again and resumes the scheduler. The program's own outcome is not passed back.
1. maux is running
2. bye
3. the program QUITs
Your shell types: bye MYPROG.SYSTEM
Processes sit in their own banks, which ProDOS does not know exist.
Open files are closed and remembered; the tick is quiesced and the console released.
Main memory and the annex are saved into TWO banks plain ProDOS cannot see.
A resident is put at $D100-$D3FF, ProDOS's QUIT window.
/RAM is reinstalled, empty, as ProDOS made it.
MYPROG.SYSTEM loads at $2000 and runs on a machine that looks freshly booted.
QUIT is MLI call $65: it copies $D100-$D3FF to $1000 and jumps there. That is the resident.
It removes /RAM again, copies the saved state back, restores the soft switches and the language card, and re-arms the tick.
The shell returns from bye: "Welcome back." The program's own outcome is not passed back.
The program under test can be one you just built with nas and ld, run on ProDOS 8 itself.
Mechanism: docs/BYE.md (2026-09-26 and 2026-09-27 rulings). Gates: check-bye, check-tenant.
Suspend the system into a bank ProDOS cannot see; run a ProDOS 8 program; restore.
The reason is testing. The loop is: edit in vi, assemble with
nas, link with ld, build with make, all
under maux, and then run the result on ProDOS 8 itself, not under a shim. ProDOS's
QUIT call, MLI $65, copies $D100-$D3FF from language-card
bank 2 to $1000 and jumps there; every program selector works by replacing that
window. bye puts a small resident there, so the QUIT the program makes to
leave is the moment maux is restored.
Plain ProDOS 8 knows only aux bank 0 (through /RAM), so main memory and the
annex are saved into two RamWorks banks it cannot see. For the program,
/RAM is reinstalled, empty, as ProDOS makes it; on the way back it is
removed again and whatever the program wrote there is discarded. The program runs on a
machine that is, as far as it can tell, freshly booted. ProDOS's QUIT carries no status,
so bye cannot return the program's outcome to the shell: whether it succeeded
is whatever it left on the volume.
Read further
The design is written down in the repository, in the order it was
decided. Start with the current-state documents; read the design diaries for the
reasoning, but trust the source and the gates over an old status line.
The links below point into the source repository.
Start here
PROJECT-STATE : what works, what is proven, what is not, and the accepted risks.
The documentation map : which document is the authority for which question.
ARCHITECTURE : the invariants (one bank per process, the $FFxx page, no hardware protection) and the dated design history.
The machine
MEMMAP : byte-accurate layout of main memory, the annex and a process bank.
SYSCALL : the trapframe and the JSR $FF00 ABI.
FORK : the bank clone, the frame patch, and the 80STORE bracket.
BYE : suspend maux, run a ProDOS program, come back.
CONSOLE : the terminal backends, virtual consoles, and the VT102 target.
JOB-CONTROL , KSEG (the kernel cold segment in language-card bank 2) and DEV-BLOCK (block devices).
The toolchain
The evidence
How to read them
A design document can contain dated amendments, and an old NEXT is
not an assignment. When a document and the source disagree, the source and its
named gate win. Hardware claims are checked against primary sources (manuals,
patents, a second emulator) and graded as fact, likely or reported; only a
fact is allowed to carry weight unchecked.