Jump to content

Zero page (CP/M)

From Wikipedia, the free encyclopedia
(Redirected from CALL 5 (CP/M))

The Zero Page (or Base 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 (PSP), a 256-byte (page-sized) 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:

Offset Size Contents
00–02 Code Exit program (jumps to the BIOS, and is also used to find BIOS entry points).[1]
03 Byte I/O byte, an optional feature allowing device reassignment in CP/M 2.
04 Byte Current command processor drive (low 4 bits) and user number (high 4 bits).
05–07 Code Jump 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.[1]
08–3A Code 8080 restart/interrupt vectors.
3B–3F Bytes Reserved
40–4F Bytes Reserved for use by the BIOS[2]
50 Byte The drive from which the program was loaded (CP/M 3)
51–52 Word Address of the password for the first FCB (CP/M 3)
53 Byte Length of the password for the first FCB (CP/M 3)
54–55 Word Address of the password for the second FCB (CP/M 3)
56 Byte Length of the password for the second FCB (CP/M 3)
57–5B Bytes Reserved
5C–6B Default FCB 1
6C–7F Default FCB 2 (overwritten if FCB 1 is opened)
80 Byte Number of characters in command tail.
81–FF Bytes Command tail (everything after the program name).

In CP/M-86, the structure is:

Offset Size Contents
00–02 Bytes Length of code group in bytes
03–04 Word Segment address of code group
05 Byte 8080 model flag - set if program only has one segment
06–08 Bytes Length of data group in bytes
09–0A Word Segment address of data group
0B Byte Reserved
0C–11 Descriptor for extra group - same format as for data
12–17 Descriptor for stack group
18–1D Descriptor for X1 group
1E–23 Descriptor for X2 group
24–29 Descriptor for X3 group
2A–2F Descriptor for X4 group
30–4F Bytes Reserved
50 Byte The drive from which the program was loaded (CP/M 3)
51–52 Word Address of the password for the first FCB (CP/M 3)
53 Byte Length of the password for the first FCB (CP/M 3)
54–55 Word Address of the password for the second FCB (CP/M 3)
56 Byte Length of the password for the second FCB (CP/M 3)
57–5B Bytes Reserved
5C–6B Default FCB 1
6C–7F Default FCB 2 (overwritten if FCB 1 is opened)
80 Byte Number of characters in command tail.
81–FF Bytes Command tail (everything after the program name).

See also

[edit]

References

[edit]
  1. ^ a b Taylor, Roger; Lemmons, Phil (June 1982). "Upward migration - Part 1: Translators - Using translation programs to move CP/M-86 programs to CP/M and MS-DOS" [Using translation programs to move CP/M programs to CP/M-86 and MS-DOS] (PDF). BYTE. Vol. 7, no. 6. BYTE Publications Inc. pp. 321–322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344 [342, 344]. ISSN 0360-5280. CODEN BYTEDJ. Archived (PDF) from the original on 2020-01-16. Retrieved 2020-01-15. […] Gaining Access to CP/M-86 […] Gaining access to CP/M-86 requires placing the function code in the CL register, placing the byte parameter in the DL register or placing the word parameter in the DX register, placing the data segment in the DS register (the data segment is usually not changed for a converted program), and executing a software interrupt, INT #224. The result is returned in the AL register if it is a byte value; if the result is a word value, it is returned in both the AX and BX registers. Double-word values are returned with the offset in the BX registers and the segment in the ES register. Conversion of programs from CP/M-80 to CP/M-86, then, requires replacing the call to location 5 with the software interrupt INT #224. Another necessary change involves the warm boot. Under CP/M-80, the warm boot may be accessed by a system call with a function code of 0 for a jump to location 0. CP/M-86, however, does not support the jump to location 0. As a result, you must change this program exit in the translated program if the program is to run correctly. Provided that the call to location 5 is replaced with INT #224, that the warm boot change is made, and that the registers are mapped correctly, there should be little problem in getting the translated program to access the CP/M-86 system functions. […] Gaining Access to MS-DOS […] Although MS-DOS has a "preferred" mechanism through a soft-ware interrupt, INT #33, for accessing the system, an additional mechanism is provided for "preexisting" programs that is compatible with CP/M-80 calling conventions, at least for functions in the range of 0-36. As far as system calls within the allowed function range are concerned, the programmer doesn't have to do anything to translated programs to get them to run under MS-DOS other than to correctly map the registers. MS-DOS also supports the warm boot function of CP/M-80. A jump to location 0 under MS-DOS executes a software interrupt, INT #32, which is functionally a program end and the normal way to exit from a program. […] [1] [2][3][4][5][6][7][8][9][10][11][12][13][14] (13 pages)
  2. ^ CP/M 2.0 Alteration Guide (PDF). Digital Research. 1979. p. 23.

Further reading

[edit]