KAYPRO II/IV CBIOS for CP/M 2.2. Copyright (C) 1982,1983 By NLS Inc. Z80ASM 1.31 Page 1 K83BIOS Z80 2 ;############################################################### 3 ;## KAYPRO II/IV CBIOS for CP/M 2.2 ## 4 ;## ## 5 ;## By G. Ohnysty ## 6 ;## ## 7 ;## Copyright (C) 1982,83 By Non-Linear Systems, Inc. ## 8 ;## No warranty is made, expressed or implied. ## 9 ;############################################################### 10 ;## Last Update: 02/24/83 [02] ## 11 ;############################################################### 12 ; 13 ;History: 14 ; Add disk motor time out. G. Ohnysty 15 ; Add baud rate set by BIOS. 16 ; 17 ; Add # Pad xlate table. J. Nickerson 18 ; Add list status test of TTY: 19 ; Change default IO byte LST: to UL1 20 ; 21 ; 58K ZCPR3 version 3.1 22 ; Steven M. Cohen, 06/09/85 23 ; 24 ; modified in light of a Kaypro IV BIOS disassembly, as well as 25 ; to better configure to ZCPR3 (fixed long time problem where new 26 ; STARTUPs could not be used). 27 ; Michael Broschat, 88/04/08 for Kaypro Campus User Group, Seattle 28 29 maclib z3base.lib 30 31 0033 cbrev equ 51 ; BIOS revision number: April 1988 32 DB06 bdos equ ccp+806H ; start of Z80DOS 33 E900 bios equ ccp+1600H ; start of Basic I/O Subsystem (BIOS) 34 1600 cpml equ bios-ccp ; length of CP/M system in bytes (less BIOS) 35 002C nsects equ cpml/128 ; length of CP/M system in sectors (less BIOS) 36 0028 trksec equ 40 ; sectors/track 37 38 001C bitport equ 1CH ; status/control bit mapped port 39 0000 baud equ 0 ; baud rate port 40 0005 baud30 equ 05H ; 300 baud rate 41 0003 iobyte equ 3 ; logical to physical map 42 0000 rom equ 00000H ; base of rom 43 FC00 ram equ 0FC00H ; base of scratch ram 44 FC14 dmaadr equ ram+14H ; dma address 45 46 FFFF if rcp ne 0 47 ED00 bufferbase equ rcp 48 else 50 endif 51 52 ; bufferbase is the bottom of the ZCPR-added segments. This version of the 53 ; ..BIOS presumes either a minimal ZCPR system (no FCP, NDR, or RCP) or a 54 ; ..full one (including those segments; a "maximum" system would include the 55 ; ..IOP segment as well). The user should be aware that a system somewhere 56 ; ..between these extremes could be developed having only one or two of the 57 ; ..system segments just mentioned. 58 59 .phase bios 60 E900 C3 E948 jp boot ; arrive here from cold start 61 E903 C3 EA16 jp wboot ; arrive here for warm start 62 E906 C3 EA6C jp const ; console status return in A FF=ready, 00=not 63 E909 C3 EA82 jp conin ; console char in 64 E90C C3 EAA8 jp conout ; console char out 65 E90F C3 EAC1 jp list ; listing char out 66 E912 C3 EABC jp punch ; punch char out 67 E915 C3 EAB7 jp reader ; reader char in 68 E918 C3 EAF5 jp home ; move to track 0 on selected disk drive 69 E91B C3 EAF9 jp seldsk ; select disk drive 70 E91E C3 EAFD jp settrk ; set track # 71 E921 C3 EB01 jp setsec ; set sector # 72 E924 C3 EB05 jp setdma ; set DMA address 73 E927 C3 EB09 jp read ; read selected sector 74 E92A C3 EB11 jp write ; write selected sector 75 E92D C3 EADE jp listst ; list status (Ready to print a char) 76 E930 C3 EB21 jp sectran ; sector translate 77 78 E933 ioconfig: 79 E933 81 defb 10000001b ; initial value for i/o byte; this configures 80 ; ..for parallel printer: serial gets 00000001 81 E934 wrtsafe: 82 E934 00 defb 0 ; write safe flage 0=false 83 E935 vtab: 84 E935 0B 0A 08 0C defb 11, 10, 8, 12 ; vector pad xlate table ^k ^j ^h ^l 85 E939 30 31 32 33 defb '0', '1', '2', '3' 86 E93D 34 35 36 37 defb '4', '5', '6', '7' 87 E941 38 39 2D 2C defb '8', '9', '-', ',' 88 E945 0D 2E defb 0DH, '.' 89 E947 baudrt: 90 E947 05 defb baud30 ; baud rate 91 92 ; Cold boot entry point, set up system pointers and pass control to the CCP 93 ; In the following code, the highest point allowable for non-Kaypro system 94 ; ..code is presumed to be FB00. This, even though the scratch RAM appears 95 ; ..to be at FC00. Tests on a 484 showed that something is using some of the 96 ; ..FB00 block, perhaps as a stack. In effect, this configuration drops the 97 ; ..system 256 bytes lower than perhaps it need be, but the gain is that 98 ; ..all system segments for the 2X/484 series will work interchangably with 99 ; ..this II/IV system. 100 101 E948 boot: 102 E948 CD EAF1 call diskint 103 FFFF if rcp ne 0 104 E94B 21 ED00 ld hl,rcp 105 E94E 11 ED01 ld de,rcp+1 106 else 109 endif 110 E951 01 0DFF ld bc,0faffh-bufferbase 111 ; figure out the size of the ZCPR buffer space 112 E954 AF xor a 113 E955 77 ld (hl),a 114 E956 ED B0 ldir ; zero out all buffer space as initialization 115 116 E958 21 EB54 ld hl,path 117 E95B 11 F8F4 ld de,expath 118 E95E 01 0009 ld bc,9 119 E961 ED B0 ldir 120 E963 21 EB5F ld hl,InitialCommand 121 E966 11 F900 ld de,z3cl 122 E969 01 000C ld bc,0ch ; length of InitialCommand 123 E96C ED B0 ldir 124 125 E96E 21 F900 ld hl,z3cl ; this allows the STARTUP file to be altered 126 E971 22 FA18 ld (z3env+24),hl ; ..at will 127 128 E974 AF xor a ; clear system disk number 129 E975 32 0004 ld (4),a 130 E978 2F cpl 131 E979 32 F8FF ld (z3whl),a ; enable the wheel byte: don't do this if 132 ; ..you want a secure system from boot up 133 E97C 3A E933 ld a,(ioconfig) ; init value for i/o byte 134 E97F 32 0003 ld (iobyte),a 135 E982 3A E947 ld a,(baudrt) ; set baud rate 136 E985 D3 00 out (baud),a 137 138 E987 CD EB48 call print 139 E98A 1A 0D 0A defb 1ah, 0dh, 0ah 140 E98D 4B 61 79 70 defb 'Kaypro II/IV ' 141 E99A 36 30 defb msize/10+'0', msize mod 10+'0' 142 E99C 4B 20 5A 38 defb 'K Z80DOS vers. ' 143 E9AB 31 2E 30 defb vers/10+'0','.', vers mod 10+'0' 144 E9AE 20 26 20 5A defb ' & ZCPR vers. ' 145 E9BC 33 2E 33 defb z3rev/10+'0','.', z3rev mod 10+'0' 146 E9BF 20 77 2F 20 defb ' w/ BIOS vers. ' 147 E9CE 35 2E 31 defb cbrev/10+'0','.', cbrev mod 10+'0' 148 E9D1 0D 0A defb 0dh,0ah 149 E9D3 20 62 79 20 defb ' by Campus Kaypro User Group, Seattle',0DH, 0AH, 00H 150 151 E9FB goccp: 152 E9FB 3E C3 ld a,0c3h ; set up CP/M jumps to bdos and wboot 153 E9FD 21 E903 ld hl,bios+3 ; wboot entry point 154 EA00 32 0000 ld (0000),a 155 EA03 22 0001 ld (0001),hl 156 157 EA06 21 DB06 ld hl,bdos ; entry point to bdos 158 EA09 32 0005 ld (0005),a 159 EA0C 22 0006 ld (0006),hl 160 161 EA0F 3A 0004 ld a,(0004) ; last logical disk unit used 162 EA12 4F ld c,a ; pass to ccp to select 163 EA13 C3 D300 jp ccp ; pass control to ccp 164 165 ; Warm boot entry point, re-load the CCP and BDOS 166 167 EA16 wboot: 168 EA16 CD EAF1 call diskint 169 EA19 CD EB48 call print 170 EA1C 0D 0A 57 61 defb 0DH, 0AH, 'Warm Boot', 0DH, 0AH, 00H 171 EA2A wb0: 172 EA2A 31 0100 ld sp,100H ; re-set stack 173 EA2D 0E 00 ld c,0 ; select drive A: 174 EA2F CD EAF9 call seldsk 175 EA32 01 0000 ld bc,0 ; set track 176 EA35 CD EAFD call settrk 177 EA38 21 D300 ld hl,ccp ; first memory location to load 178 EA3B 22 FC14 ld (dmaadr),hl 179 EA3E 01 2C01 ld bc,nsects*256+1 180 EA41 wb1: 181 EA41 C5 push bc ; save sector count and current sector 182 EA42 CD EB01 call setsec ; select sector 183 EA45 CD EB09 call read 184 EA48 C1 pop bc 185 EA49 B7 or a 186 EA4A 20 DE jr nz,wb0 ; oops, error on warm boot 187 EA4C 2A FC14 ld hl,(dmaadr) ; update dma address for next sector 188 EA4F 11 0080 ld de,128 ; new dma address 189 EA52 19 add hl,de 190 EA53 22 FC14 ld (dmaadr),hl 191 EA56 05 dec b 192 EA57 CA E9FB jp z,goccp ; done loading 193 EA5A 0C inc c ; bump sector count 194 EA5B 3E 28 ld a,trksec ; on to next track? 195 EA5D B9 cp c 196 EA5E C2 EA41 jp nz,wb1 197 EA61 0E 10 ld c,16 ; first sector on next track 198 EA63 C5 push bc ; save counters 199 EA64 0E 01 ld c,1 200 EA66 CD EAFD call settrk ; set track 201 EA69 C1 pop bc 202 EA6A 18 D5 jr wb1 203 204 ; logical devices are con: rdr: pun: and lst: 205 ; physical devices are: 206 ; crt: video and kbd 207 ; tty: serial 208 ; lpt: centronics 209 ; ul1: serial with cts as busy 210 ; pun: same as ul1 211 ; 212 ;con: tty, crt 213 ;rdr: tty 214 ;pun: tty, pun 215 ;lst: tty, crt, lpt, ul1 216 ; 217 EA6C const: 218 EA6C 21 EB6B ld hl,count ; turn off disk drive 219 EA6F 34 inc (hl) 220 EA70 CC EAA1 call z,diskoff 221 EA73 3A 0003 ld a,(iobyte) ; get i/o byte 222 EA76 E6 03 and 03H ; strip to con bits 223 EA78 2E 33 ld l,rom+33H ; serial status 224 EA7A CA EB25 jp z,callrom 225 EA7D 2E 2A ld l,rom+2AH ; assume CRT 226 EA7F C3 EB25 jp callrom 227 EA82 conin: 228 EA82 CD EAA1 call diskoff 229 EA85 3A 0003 ld a,(iobyte) 230 EA88 E6 03 and 03H ; check i/o byte 231 EA8A 2E 36 ld l,rom+36H ; serial input 232 EA8C CA EB25 jp z,callrom 233 EA8F 2E 2D ld l,rom+2DH ; assume input from kbd 234 EA91 CD EB25 call callrom ; go get char 235 EA94 B7 or a 236 EA95 F0 ret p ; msb not set 237 EA96 E6 1F and 01fh ; form table index to VTAB 238 EA98 21 E935 ld hl,vtab 239 EA9B 4F ld c,a 240 EA9C 06 00 ld b,0 241 EA9E 09 add hl,bc 242 EA9F 7E ld a,(hl) ; pick up xlated character 243 EAA0 C9 ret 244 EAA1 diskoff: 245 EAA1 DB 1C in a,(bitport) ; turn off disk drives and sel leds 246 EAA3 CB F7 set 6,a 247 EAA5 D3 1C out (bitport),a 248 EAA7 C9 ret 249 EAA8 conout: 250 EAA8 3A 0003 ld a,(iobyte) ; check i/o byte 251 EAAB E6 03 and 03H 252 EAAD 2E 39 ld l,rom+39H ; serial output 253 EAAF CA EB25 jp z,callrom 254 EAB2 2E 45 ld l,rom+45H ; assume video 255 EAB4 C3 EB25 jp callrom 256 EAB7 reader: 257 EAB7 2E 36 ld l, rom+36H ; serial input 258 EAB9 C3 EB25 jp callrom 259 EABC punch: 260 EABC 2E 39 ld l,rom+39h ;serial punch 261 EABE C3 EB25 jp callrom 262 EAC1 list: 263 EAC1 3A 0003 ld a,(iobyte) 264 EAC4 E6 C0 and 0C0H ; check i/o byte 265 EAC6 2E 39 ld l,rom+39H ; serial 266 EAC8 CA EB25 jp z,callrom 267 EACB 2E 3F ld l,rom+3FH ; centronics 268 EACD FE 80 cp 80H 269 EACF CA EB25 jp z,callrom 270 EAD2 2E 45 ld l,rom+45H ; video 271 EAD4 FE 40 cp 40H 272 EAD6 CA EB25 jp z,callrom 273 EAD9 2E 39 ld l, rom+39h ;ul1: default to serial 274 EADB C3 EB25 jp callrom 275 EADE listst: 276 EADE 3A 0003 ld a,(iobyte) ; check i/o byte 277 EAE1 E6 C0 and 0C0H 278 EAE3 2E 42 ld l,rom+42H ; serial 279 EAE5 CA EB25 jp z,callrom 280 EAE8 2E 3C ld l,rom+3CH ; centronics 281 EAEA FE 80 cp 80H 282 EAEC CA EB25 jp z,callrom 283 EAEF AF xor a ; 0=ready 284 EAF0 C9 ret 285 EAF1 diskint: 286 EAF1 2E 03 ld l,rom+03H ; re-set disk software sub-system 287 EAF3 18 30 jr callrom 288 EAF5 home: 289 EAF5 2E 0C ld l,rom+0CH ; home disk drive rom routine 290 EAF7 18 2C jr callrom 291 EAF9 seldsk: 292 EAF9 2E 0F ld l,rom+0FH ; select disk drive 293 EAFB 18 28 jr callrom 294 EAFD settrk: 295 EAFD 2E 12 ld l,rom+12H ; seek track 296 EAFF 18 24 jr callrom 297 EB01 setsec: 298 EB01 2E 15 ld l,rom+15H ; set sector number 299 EB03 18 20 jr callrom 300 EB05 setdma: 301 EB05 2E 18 ld l,rom+18H ; set dma address 302 EB07 18 1C jr callrom 303 EB09 read: 304 EB09 AF xor a ; reset disk off count 305 EB0A 32 EB6B ld (count),a 306 EB0D 2E 1B ld l,rom+1BH ; read a logical sector 307 EB0F 18 14 jr callrom 308 EB11 write: 309 EB11 AF xor a ; reset disk off count 310 EB12 32 EB6B ld (count),a 311 EB15 2E 1E ld l,rom+1EH ; write a logical sector 312 EB17 3A E934 ld a,(wrtsafe) ; write safe flag 313 EB1A B7 or a ; true or false 314 EB1B 28 08 jr z,callrom ; normal operation 315 EB1D 0E 01 ld c,1 ; directory write code (forces write op) 316 EB1F 18 04 jr callrom 317 EB21 sectran: 318 EB21 2E 21 ld l,rom+21H ; xlate logical to physical sector 319 EB23 18 00 jr callrom 320 EB25 callrom: 321 EB25 D9 exx ; save cp/m arguments 322 EB26 DB 1C in a,(bitport) ; turn rom on 323 EB28 CB FF set 7,a 324 EB2A D3 1C out (bitport),a 325 EB2C ED 73 EB6C ld (savsp),sp ; save current stack (may be under rom) 326 EB30 31 EBAE ld sp,stack ; set a local stack 327 EB33 11 EB3B ld de,biosret ; rom to "RET" here 328 EB36 D5 push de 329 EB37 D9 exx ; restore cp/m arguments and call loc 330 EB38 26 00 ld h,0 331 EB3A E9 jp (hl) ; to rom routine specified in hl 332 EB3B biosret: 333 EB3B 08 ex af,af' ; save reg A 334 EB3C ED 7B EB6C ld sp,(savsp) ; restore stack 335 EB40 DB 1C in a,(bitport) ; off the rom 336 EB42 CB BF res 7,a 337 EB44 D3 1C out (bitport),a 338 EB46 08 ex af,af' ; restore reg A 339 EB47 C9 ret ; done with rom routine 340 EB48 print: 341 EB48 E3 ex (sp),hl ; pop return address, points to text to print 342 EB49 7E ld a,(hl) ; get a byte of text, stop on zero byte 343 EB4A 23 inc hl 344 EB4B E3 ex (sp),hl ; save new return address 345 EB4C B7 or a ; is it a zero byte? 346 EB4D C8 ret z 347 EB4E 4F ld c,a ; no, so print it 348 EB4F CD EAA8 call conout 349 EB52 18 F4 jr print 350 351 352 EB54 01 0F 01 00 path: defb 1,15,1,0,'$','$',1,15,0,0,0 353 EB5F InitialCommand: 354 EB5F F904 defw z3cl+4 355 EB61 C8 defb z3cls 356 EB62 00 53 54 41 defb 0,'STARTUP',0 357 358 EB6B 00 count: defb 0 ; disk off counter 359 EB6C 0002 savsp: defs 2 ; current stack pointer during rom call 360 EBAE stack equ $+64 ; A local stack: 64 is OK for ZCPR configurations, 361 ; ..but cannot be used for straight CP/M, where 34 362 ; ..works fine. 363 .dephase 364 end 0 Error(s) Detected. 622 Absolute Bytes. 77 Symbols Detected. KAYPRO II/IV CBIOS for CP/M 2.2. Copyright (C) 1982,1983 By NLS Inc. Z80ASM 1.31 Page 8 Symbol Table: 0000 BASE 0000 BAUD 0005 BAUD30 E947 BAUDRT DB06 BDOS E900 BIOS EB3B BIOSRET 001C BITPORT E948 BOOT ED00 BUFFERBASE EB25 CALLROM 0033 CBREV D300 CCP EA82 CONIN EAA8 CONOUT EA6C CONST EB6B COUNT 1600 CPML EAF1 DISKINT EAA1 DISKOFF FC14 DMAADR F8F4 EXPATH 0005 EXPATHS F8D0 EXTFCB F9D0 EXTSTK 0000 FALSE F500 FCP 0004 FCPS FFFF FULL E9FB GOCCP EAF5 HOME EB5F INITIALCOMMAND 0003 IOBYTE E933 IOCONFIG 0000 IOP 0000 IOPS EAC1 LIST EADE LISTST 003C MSIZE 002C NSECTS EB54 PATH EB48 PRINT EABC PUNCH FC00 RAM ED00 RCP 0010 RCPS EB09 READ EAB7 READER 0000 ROM EB6C SAVSP EB21 SECTRAN EAF9 SELDSK EB05 SETDMA EB01 SETSEC EAFD SETTRK 0020 SHSIZE F800 SHSTK 0004 SHSTKS EBAE STACK 0028 TRKSEC FFFF TRUE 000A VERS E935 VTAB EA2A WB0 EA41 WB1 EA16 WBOOT EB11 WRITE E934 WRTSAFE F900 Z3CL 00C8 Z3CLS FA00 Z3ENV 0002 Z3ENVS F880 Z3MSG F700 Z3NDIR 000E Z3NDIRS 0021 Z3REV F8FF Z3WHL