-
Notifications
You must be signed in to change notification settings - Fork 21
Environment
A CP/M 2.2 BIOS should begin:
- with at least 17
JMP
statements, each one directing to a different BIOS call; and - on a 256-byte boundary.
Other version of CP/M start with a different number of JMP
statements, correlating with the number of defined BIOS function calls.
A CALL
to the start of the BIOS should be placed at address 0. Prior to launching software, the stack should be primed with a return address that will cause the CCP to reappear as some applications unwind with a final RET
rather than a call to BIOS function 1.
- MBASIC obtains the BIOS start address from the
CALL
at address 0, then uses 16-bit arithmetic to calculate the offset into the BIOS of each BIOS call'sJMP
statement, then reads the target address from theJMP
and dynamically reprograms itself to branch directly to those addresses, short-circuiting the usual dispatch mechanism for faster character input and output; - WordStar 4 branches directly into the
JMP
table at the start of the BIOS, but does so by taking the high byte of its start address from the CALL at address 0, and replacing the low byte appropriately for its target call. Therefore it has the hard-coded assumption that the BIOS starts on a 256-byte boundary.
Any time the program counter strays above the start of the BIOS, that action is trapped and mapped to a BIOS call. Each JMP
statement is actually a JMP
directly to itself in order to support programs that read the target JMP
address and use it directly.
The first JMP
statement is for starting from a cold boot, and calling it from user code is explicitly undefined behaviour. Therefore it is reused as the BDOS entry point, and BIOS call 0 is effectively redefined from cold boot to perform BDOS action.
Only a very minimal implementation of the BIOS is provided, essentially supporting the console functions only. Application software universally uses the file-level BDOS interfaces rather than direct calls to the paper tape and low-level disk routines provided by the BIOS.
A CALL
to the BDOS dispatcher should be placed at address 5, starting two bytes after the call to a BIOS cold boot.
The transient program is loaded at address 0x100
. RET
is used to terminate some transient programs, so this address is implicitly CALL
d to begin execution.