Zero page (CP/M)


The Zero Page is a data structure used in CP/M systems for programs to communicate with the operating system. In 8-bit CP/M versions it is located in the first 256 bytes of memory, hence its name.
The equivalent structure in DOS is the Program Segment Prefix, a 256-byte structure, which is by default located exactly before offset 0 of the program's load segment, rather than in segment 0. A segment register is initialised to 0x10 less than the code segment, in order to address it.
In 8-bit CP/M, it has the following structure:
OffsetSizeContents
00–02CodeExit program.
03ByteI/O byte, an optional feature allowing device reassignment in CP/M 2.
04ByteCurrent command processor drive and user number.
05–07CodeJump to CP/M BDOS entry - main system call entry point. This is also the address of the first byte of memory not usable by the program.
08–3ACode8080 restart/interrupt vectors.
3B–3FBytesReserved
40–4FBytesReserved for use by the BIOS
50ByteThe drive from which the program was loaded
51–52WordAddress of the password for the first FCB
53ByteLength of the password for the first FCB
54–55WordAddress of the password for the second FCB
56ByteLength of the password for the second FCB
57–5BBytesReserved
5C–6BDefault FCB 1
6C–7FDefault FCB 2
80ByteNumber of characters in command tail.
81–FFBytesCommand tail.

In CP/M-86, the structure is:
OffsetSizeContents
00–02BytesLength of code group in bytes
03–04WordSegment address of code group
05Byte8080 model flag - set if program only has one segment
06–08BytesLength of data group in bytes
09–0AWordSegment address of data group
0BByteReserved
0C–11Descriptor for extra group - same format as for data
12–17Descriptor for stack group
18–1DDescriptor for X1 group
1E–23Descriptor for X2 group
24–29Descriptor for X3 group
2A–2FDescriptor for X4 group
30–4FBytesReserved
50ByteThe drive from which the program was loaded
51–52WordAddress of the password for the first FCB
53ByteLength of the password for the first FCB
54–55WordAddress of the password for the second FCB
56ByteLength of the password for the second FCB
57–5BBytesReserved
5C–6BDefault FCB 1
6C–7FDefault FCB 2
80ByteNumber of characters in command tail.
81–FFBytesCommand tail.