MORE ON THE SCB Gordon Wilk 6707 Springpark Ave Los Angeles CA 90056 213 645-6419 A number of execellent articles on the System Control Block of CPM Plus have been published in FOGHORN, yet there is more to tell. The DRI Programmer's Guide insists that we use BDOS function 49 to get or set values in the SCB, yet the CCP does not do it this way. It turns out that a particular location in the SCB (offset of CDh) contains the address of the SCB. We can get this address with function 49 once and then use it to read and write the SCB directly. This location contains the address but it is easier to just use the high byte and refer to all locations by their low byte address on this page. Any SCB value can be easily located by placing the high byte in H and the offset in L. The CCP does it this way. To find the SCB base: LXI D,SCBPB MVI C,49 CALL 05 SHLD SCBBase RET SCPBP DB 03Ah,00 There is no easy way to make a DOS call in BASIC so use this code once or you can assume that SCBBS% = &HF800 (probably). Now we have the base page address stored in SCBBase. To access any value in the SCB LHLD SCBBase ;Get the page address MVI L,offset ;Move an offset into L ;We are now pointing to the value MOV A,M ;Load it into register A RET in BASIC: scbname% = PEEK(SCBBS% + offset) e.g. VERSION% = PEEK(SCBBS% + &HA0) To set any value in the SCB LHLD SCBBase MVI L,Offset MOV M,A RET in BASIC: POKE SCBPG% + offset, value e.g. LISTFLG% = &HD4 POKE SCBPG% + LISTFLG%, 1 This is the way the CCP does it; the BDOS have direct access since BDOS was told the base address by GENCPM when the system was generated. In the list below are the values in the SCB with their addresses expressed as offsets from the base page. On my system this is F800h, it probably is on most Osborne Execs -- you can address the SCB directly without this procedure, but using the procedure allows your code to run on any CPM Plus system. A number of the values in the SCB are listed only as "reserved for system use" in the documentation. I have attempted to describe these based on their use by the CCP and BDOS using the dissassembled code produced by Clark Calkins' SCG31 (see end of article for acknowledgement and more information). Some of them may have multiple uses and I have only listed those I am sure of. Most variables documented by DRI, I have left without comments. A few, I have not figured out and would like to hear from anyone who has. The offsets listed below are relative to the SCB base page address. Official SCB addresses are 9Chex smaller. OFFSET NAME LENGTH DESCRIPTION ------ ---- ------ ----------- 9C-A0 HASHBYTES These are used by the directory and filename routines. 9C HashChek 1 Hash value for directory check 9D HashDrve 1 Drive being checked 9E HashName 2 File being checked A0 HashExt 1 Extant being checked A1 Version 1 CCP resets to 31h at warm boot A2 Users 4 A6 ??? 5 May be used by SUBMIT.COM? AB SavDrv 1 Save current Drv here if SUBMIT may change it. AC RetCode 2 CCP resets to 0 if not chaining The remainder of a multiple command line (the part after the !) is stored as an RSX. RSXPAGE and NXTCMD are used to locate this special area. AE RSXPage 1 HiByte of RSX address AF DefDrv 1 Default drive saved here B0 DefUser 1 Default user # saved here B1 NxtCmd 2 Address of rest of multiple input line B3-B4 CCPFLGS Used by the CCP for a number of purposes. Involved in SUB file, multiple cmd line processing and chaining. Note that Flag2 overlagps SavBuff. B3 Flag1 1 Bit 7: chain requested Bit 6: use default User & Drv Bit 1: remove RSXs B4 Flag2 1 Bit 7: cmd line not finished Bit 6: Use current User code Bit 5: reset dieks Bit 4&3: COM/PRL/SUB code Bit 0: SUB file active B4 SavBuff 2 Address of previously saved input line used to recall last command. B5 Profile 1 Overlaps. If Bit 1 is set, which is only on a cold boot, the PROFILE.SUB command is executed. B6 ConWidth 1 B7 CurCol 1 B8 PageLength 1 B9 ??? 1 Default Page length??? BA BuffPtr 2 input line pointer BC KBPtr 2 keyboard input line pointer BE @CIVEC 2 C0 @COVEC 2 C2 @AIVEC 2 C4 @AOVEC 2 C6 @LOVEC 2 C8 PageMode 1 C9 DefPgMode 1 Page mode stored here by CCP CA CTRL$H 1 CB RUBOUT 1 CC KeyStat 1 Keyboard status for submit mode input CD ??? 2 CF ConMode 1 Console mode CCP resets to 1 @ WarmBoot D0 RSXInput 1 Flag set if an RSX is providing console input. Used by SUBMIT and GET. CCP resets to 0 @ warm boot D1 @BNKBF 2 Address of bank buffer D3 Delim 1 CCP resets to '$' on warm boot D4 OutFlag 1 D5 KeyBdFlg 1 Keyboard locked flag D6 SCBBase 2 The base of this table D8 @CRDMA 2 DA @CRDSK 1 CCP resets to DefDrv at warmboot DB @VINFO 2 (DE) on entry to this function ->fcb DD @RESEL 1 DE @MEDCHG 1 DF @FX 1 Register C on entry to BDOS E0 @USRCD 1 CCP resets to DefUser at Warm boot E1-E5 SEARCH Used by BDOS functions 17 & 18 E1 Entry 2 directory entry location for searching E3 SrchFCB 2 fcb adr for searches E5 MtchCnt 1 char count to match E6 @MLTIO 1 CCP resets to 1 on warm boot E7 @ERMDE 1 CCP resets to 0 on warm boot E8 DrvChain 4 EC TempDrv 1 ED @ERDSK 1 EE ?? 2 F0 @MEDIA 1 door open flag F1 ?? 2 F3 @BFLAGS 1 Bit 7: error message length F4 @DATE 2 F6 @HOUR 1 F7 @MINUTE 1 F8 @SECONDS 1 F9 Common 2 address of common memory base FB ?ERJMP 3 FE @MXTPA 2 Perhaps the most interesting unpublished locations are "DefDrv" and "DefUser". Applications programs either directly or via BDOS calls may set and reset the current drive and user number at will. The CCP will always reset them to the default when the application program ends. The CCP does this by setting @USERCD and @CRDSK to the values in AFh and B0h on warm boot. When the CCP changes the user (the USER command) or the current drive ("B:"), it also sets "DefUser" or "DefDrv". In the normal course of events only the CCP can permanently change either the User or default drive. A sneaky application program can do the same thing by changing "DefUser" and/or "DefDrv". The current user and drive settings will not be affected, but the CCP will reset them on warmboot. This work was based on the disassembled code produced by SCG31, a program copyright by C.C.Software, 1907 Alvarado Ave Walnut Creek CA 94596, 415 939-8153. It costs $75 and is worth it for anyone knowledgeable in assembly language and curious about the way the operating system works. Labels beginning with "@" or "?" are copyright by DRI.  language and curious about the way the operating system wo