CP/M 3 System Control Block

Overview

Original:Jim LopushinskyJune 24, 1986
Some work:Werner CirsoviusJune 23, 1993
More hints:Simeon Cran (ZPM3) 
 John ElliottNovember 3, 1995

Here is a complete description of the fields in the CP/M 3.1 System Control Block, as far as I can determine. The undocumented fields were discovered while dissambling the CCP, Resident BDOS, and Banked BDOS. Digital Research documents the SCB as 100 decimal bytes, but in fact it is 152 or 98 hex bytes long. The SCB occupies the last 152 bytes of the resident portion of the BDOS (just before the BIOS). It begins at xx68h, where xx is the last page in the BDOS; therefore, offset 62h-63h (top of TPA address) is at xxFEh, just before JMP BOOT bios entry. The address of the SCB can also be determined as follows:
	LXI	D,SCBPB
	MVI	C,49
	CALL	BDOS	;page address of SCB in reg H
	..
	..
SCBPB:	DB	3AH	;this is where SCB address is
	DB	0	;get operation
To access a field in the SCB, use the above code sequence, then load register L with the field offset as determined from the table below. HL then contains the address of the field.
Of course it is possible to access SCB fields by BDOS function 49 as above. The Control Block has the general form:
SCBPB:	DB	Offset
	DB	Mode
{	DB	Lo	}
{	DB	Hi	}
  • If Mode is 00H Register HL contains 16 bit value of the selected field and the Accumulator holds the byte value, which is the same as the conteny of Register L.
  • If Mode is FFH the selected field will be set by the Lo byte value.
  • If Mode is FEH the selected field will be set by the Lo and Hi bytes.
To accomodate RSXs that modify the BIOS character I/O jump vectors (GET and PUT RSXs), a second jump vector for WBOOT, CONST, CONIN, CONOUT, and LIST are included in the SCB. Only the banked BDOS uses these vectors. Each entry consists of 2 3-byte entries which are normally jumps. An RSX can change the first JMP to an LXI H,addr, where addr is the redirected address of the particular routine in bank 1. The second JMP always points to a Resident BDOS bank switch routine which switches to bank 1, calls the routine as loaded in HL, and on return, switches back to bank 0 and returns to the banked BDOS. The banked BDOS always calls these 5 BIOS routines via the SCB jump table. This feature can be used by BYE RSXs for safely redirecting console I/O in RCP/M systems.

Categories

[BIOS intercept vector]
POINTEROFFSETTYPEDescription
68H inst.Warm boot jump vector for the banked BDOS. Normally a jump to the BIOS WBOOT vector, but can be changed to LXI H,wboot-addr to redirect Warm boots to a routine in bank 1.
6BH inst.Jump instruction to resident BDOS bank switch routine for redirected WBOOT.
6EH inst.Console status jump vector for the banked BDOS. Normally a jump to the BIOS CONST vector, but can be changed to LXI H,const-addr to redirect console status to a routine in bank 1.
71H inst.Jump instruction to resident BDOS bank switch routine for redirected CONST.
74H inst.Console input jump vector for the banked BDOS. Normally a jump to the BIOS CONIN vector, but can be changed to LXI H,conin-addr to redirect console input to a routine in bank 1.
77H inst.Jump instruction to resident BDOS bank switch routine for redirected CONIN.
7AH inst.Console output jump vector for the banked BDOS. Normally a jump to the BIOS CONOUT vector, but can be changed to LXI H,conout-addr to redirect console output to a routine in bank 1.
7DH inst.Jump instruction to resident BDOS bank switch routine for redirected CONOUT.
80H inst.List output jump vector for the banked BDOS. Normally a jump to the BIOS LIST vector, but can be changed to LXI H,list-addr to redirect list output to a routine in bank 1.
83H inst.Jump instruction to resident BDOS bank switch routine for redirected LIST.
86H-8FH  Unknown.
90H wordBit mapped vector of drives with open files.
92H wordBit mapped vector of drives accessed.
94H-97H  Unknown.
98H wordBDOS entry point address.
9AH wordReserved for use by non-banked BDOS
[System Control Block]
[Expansion area - 6 bytes]
POINTEROFFSETTYPEDescription
9CH00HbyteHash length 0, 2, or 3
9DH-A0H01H2 wordsHash entry
A1H05HbyteCP/M version. Contains 31H.
[Utilities Section - 8 bytes]
POINTEROFFSETTYPEDescription
A2H-A5H06H 4 bytes for user use.
A6H-A9H0AH Unknown.
[CLP Section - 4 bytes]
POINTEROFFSETTYPEDescription
AAH0EH Unknown.
ABH0FHbyteSubmit file drive.
ACH10HwordProgram return code.
[CCP Section - 8 bytes]
POINTEROFFSETTYPEDescription
AEH12HbyteBase page of RSX containing the 2nd of multiple commands (next to be executed).
AFH13HbyteCCP drive.
B0H14HbyteCCP user number.
B1H15HwordIf non-zero, address of 2nd of multiple commands.
B3H17HbyteBit mapped CCP flags:
0Submit flag
1RSX flag
2-5Unknown
6Set CCP drive/user to current drive/user.
7Chain flag. Next command is taken from default DMA buffer (80H).
B4H18HbyteBit mapped CCP flags:
0-1Display command source drive/user.
2Unknown
3-4File type search order:
00.COM only
01.COM, then .SUB
10.SUB, then .COM
11.PRL, then .COM
5Reset disk system
6GET RSX flag. Set if GET RSX is redirecting.
7CCP is executing (used by ^W recall)
B5H19HbyteBit mapped CCP flags:
0Unknown
1Cold start flag (0=cold)
2-7Unknown
[Device I/O Section - 32 bytes]
POINTEROFFSETTYPEDescription
B6H1AHbyteConsole width [eg 79 for 80-column screen]
B7H1BHbyteCurrent console column position
B8H1CHbyteConsole page length [eg 23 for 24-line screen]
B9H1DH Unknown
BAH1EHwordIf non-zero, address of redirected console input characters.
BCH20HwordIf non-zero, address of next line of redirected console input characters.
BEH22HwordBit mapped console input physical devices.
C0H24HwordBit mapped console output physical devices.
C2H26HwordBit mapped auxiliary input physical devices.
C4H28HwordBit mapped auxiliary output physical devices.
C6H2AHwordBit mapped list output physical devices.
C8H2CHbyteConsole page mode (0 = page pause).
C9H2DHbyteDefault page mode.
CAH2EHbyteCtrl-H mode (backspace). [0 => backspace, else echo deleted character]
CBH2FHbyteRub/Del mode. [0 => Echo deleted character, else backspace]
CCH30HbyteWhen this byte is 0FFh, the BDOS does not check for Control-S during the Console status call.
CDH31HwordUsed by console routines. Use unknown.
CFH33HwordConsole mode.
D1H35HwordAddress of 128 byte buffer in common memory. This buffer is used only during BDOS function calls by the system, so it can be used freely between BDOS calls as a scratch buffer. Also used by the BIOS during warm boot.
D3H37HbyteOutput delimiter. [normally '$']
D4H38HbyteList echo flag (non-zero = echo console output).
D5H39HbyteScroll flag (used by console routines), bit map:
7Set if the next call to CONST is to check for Control-C.
6Set if the next call to CONST or CONIN is to check for Control-S or Control-Q.
[BDOS Section - 42 bytes]
POINTEROFFSETTYPEDescription
D6H3AHwordAddress of System Control Block.
D8H3CHwordCurrent DMA address.
DAH3EHbyteCurrent drive.
DBH3FHwordCurrent FCB address (in common memory).
DDH41HbyteFCB error flag. If this byte is FFH, the word at 3FH is a valid FCB address.
DEH42HbyteSame drive flag.
DFH43HbyteCurrent BDOS function number.
E0H44HbyteCurrent user number.
E1H45HwordLast directory slot number accessed (first = 0)
E3H47HwordAddress of FCB for function 18 (search next).
E5H49HbyteFunction 17, 18 search type (0 = ? in drive code, 0FH = normal search).
E6H4AHbyteMulti-sector count.
E7H4BHbyteBDOS error mode.
E8H4CH4 bytesDrive search chain 1..4. [0=Current, 1-16 = drive A-P, 255=end of chain]
ECH50HbyteTemporary file drive. [0=Current, 1-16 = drive A-P]
EDH51HbyteError drive.
EEH-EFH52H Unknown.
F0H54HbyteDrive door open flag.
F1-F2H55H Unknown.
F3H57HbyteBit mapped BDOS flags:
0-5Unknown.
6Single allocation vectors.
7Expanded error messages.
F4H58HwordDate (days since Jan 1, 1978).
F6H5AHbyteHour (BCD).
F7H5BHbyteMinute (BCD).
F8H5CHbyteSecond (BCD).
F9H5DHwordCommon memory base address (non-banked = 0).
FBH5FHinst.Error message jump instruction to a routine in the banked BDOS.
FDH61HbyteBDOS page in bank 0.
FEH62HwordCurrent top of TPA (points to entry in lowest RSX).

Last updated: 17.Mai 2004