|
||
---|---|---|
bdos | ||
bios | ||
boot | ||
com | ||
hdr | ||
lib | ||
rom | ||
src/utils | ||
.gitignore | ||
Makefile | ||
README.md |
Components
The BIOS is in the uppermost 2K of the memory area - it provides basic character and disk I/O functions. It it expected to stay static and not be unloaded by the user program. The BIOS may hook into interrupts if necessary to provide its functionality. Depending on your hardware, a different BIOS binary may be used.
The BDOS is in the 2K below the BIOS, it provides a filesystem driver to work atop of the BIOS. It is agnostic to the underlaying hardware configuration, but different depending on the instruction set. A user program might overwrite memory up to the end of the BDOS. Upon program exit, the BIOS will reload the BDOS from disk.
Memory Layout
On a 8080, there are no segments, the addresses are as displayed.
On on the 8086, a single segment with a value of 0x0100 is assumed. This implies that the first 4k of memory are not used.
The BIOS and BDOS may be recompiled for starting at a lower address, in this case, the minimum memory requirement may be less than 64k.
Start | Size | Function |
---|---|---|
0xF800 | 2k | BIOS / hw drivers |
0xF000 | 2k | BDOS |
... | ... | BDOS data area, disk deblocking buffers |
SP | var | Stack, growing down |
... | ... | Free memory |
... | var | Heap, growing up |
0x0100 | var | Transient Program Area |
0x0080 | 128 bytes | Command line and disk buffer |
0x006C | 20 bytes | Pre-filled FCB 2 |
0x005C | 16 bytes | Pre-filled FCB 1 |
0x0008 | 84 bytes | BIOS data area, specific to BIOS implementation |
0x0005 | 3 bytes | Jump code for BDOS |
0x0004 | 1 byte | default drive for BDOS |
0x0003 | 1 byte | may be used as iobyte by BIOS |
0x0000 | 3 bytes | Jump to BIOS warm boot entry point / program exit |
BIOS Interface
The entry points for the BIOS start at its base address. Each entry point is offset a multiple of 3 from the beginning of the BIOS.
BIOS+0 Boot
The bootloader jumps here after loading the BIOS.
BIOS+3 Warm boot
Reload the BDOS from disk, and call its entry point. The jump opcodes at the start of memory are re-initialized.
BIOS+6 Console status
Checks if keyboard input is available. Returns FFh in AL (A) is character is available, 00 if not.
BIOS+9 Console read
Read a character from keyboard from AL (A). This call does not return until a character is available.
BIOS+12 Console write
Write character in DL (E) to the display.
BIOS+24 Seek disk to zero
Seek current disk (selected with the following call) to its beginning. This is a commonly a no-op.
BIOS+27 Select disk
Select disk by the number given in CL (C).
This is equivalent to the DL number for the PC BIOS Int 13h.
BIOS+30 Set track
Select track number for next disk i/o via register CX (BC).
For CHS-adressed disks, the track number is the current cylinder multiplied by the number of heads plus the current head number.
For disks with one side, the cylinder number is equal to the track number.
BIOS+33 Set disk sector
Select sector on the current track in register CX (BC). This parameter is 1-based, this means the first sector is sector 1. The value 0 is invalid.
For CHS-adressed floppies, the number of sectors per track might vary depending on the inserted floppy disk, even for the same drive.
BIOS+36 Set disk transfer address
Set buffer for disk operations via register CX (BC).
This is somewhat incompatible with CP/M versions since on modern systems, the sector size is 512 instead of 128 bytes. Setting it to the default value of 0x80 (which is the standard disk buffer for CP/M) will overwrite the first 0x180 bytes of the transient program area.
The BDOS is expected to do deblocking to provide the application program with 128-byte disk i/o.
BIOS+39 Read sector
Read sector previously specified. AL (A) is non-zero error code on failure. The error codes are implementation-specific.
BIOS+42 Write sector
Write sector previously specified. AL (A) is non-zero error code on failure. The error codes are implementation-specific
Application program interface
It is using the call 5
convention with CP/M compatible syscall numbers.
File I/O is done via FCB blocks.