mk90.basic

MBC compiler

Two-pass compilation on the MK90 and transactional executable creation.

Invocation and output

mbc program.bas

Takes exactly one pathname, which must end in .bas case-insensitively. Replaces the suffix with lowercase .mbx in the same directory. There is no output-name option. The output component must still fit the filesystem’s 12-character limit.

Copy a ROM source to a writable volume first. Successful compilation reports the output path and executable size, ending with B OK.

Passes

PhaseWork
Pass 1Stream the source; tokenize; parse statements and expressions; count bytes; build up to 64 line-number/offset pairs.
Pass 2Reopen the source; resolve numeric branch targets; emit the 16-byte MBX1 header and bytecode into the exact-length writer.
PublicationValidate source reads, flush output and close the writer. Only a successful close makes the new executable visible.

Expressions become stack operations; branch targets become byte offsets. The result is compiled bytecode, not the original source renamed with another extension.

Workspace and cooperation

The source is buffered in 256-byte blocks. The console TEXT/SHADOW area is temporarily used for scanner data and the target table. The compiler does not render a live screen or poll for keyboard cancellation while those buffers are in use.

It yields between source lines so compatible native workers can run. Parser/common services stay in an upper module while lower compiler phases are exchanged through a stable call gate. PID 0 remains suspended during the command.

Errors and preservation

Syntax and resource errors report BASIC @ line code. Status 32 is syntax, 33 a compiler limit, and 34 a missing branch target. File or ROM failures retain their OS code. On failure, handles are aborted and the console is restored.

The previous executable is preserved when a compile or publication fails. There is no partly compiled executable published under its name. Compilation still needs free contiguous space for the proposed output alongside protected older extents.

Workflow

edit /mnt/smp1/app.bas
mbc /mnt/smp1/app.bas
exec /mnt/smp1/app.mbx

Leave EDIT after saving before entering the compiler command. Compiler input is the saved file, not the editor’s unsaved buffer. Exact syntax · MBX1 format.