Digital Research
This commit is contained in:
2020-11-06 18:50:37 +01:00
parent 621ed8ccaf
commit 31738079c4
8481 changed files with 1888323 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
cp *.mac *.asm *.lib m:
cp bnktype.cpm m:asmtype.lib
m:
m80
< =zbios
< =scb
< =boot
< =chario
< =move
< =flpmod
< =hddmod
< =ramdsk
<^C
rmac dskmod $$sz pz
a:
; ***** ASSEMBLED BANKED SYSTEM *****

View File

@@ -0,0 +1,16 @@
cp *.mac *.asm *.lib m:
cp stdtype.cpm m:asmtype.lib
m:
m80
< =zbios
< =scb
< =boot
< =chario
< =move
< =flpmod
< =hddmod
< =ramdsk
<^C
rmac dskmod $$sz pz
a:
; ***** ASSEMBLED NON BANKED SYSTEM *****

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,158 @@
PRTMSG = Y
PAGWID = 4F
PAGLEN = 18
BACKSPC = N
RUBOUT = N
BOOTDRV = A
MEMTOP = FF
BNKSWT = Y
COMBAS = F0
LERROR = Y
NUMSEGS = 01
MEMSEG00 = 00,B8,00
MEMSEG01 = 00,C0,02
MEMSEG02 = 00,C0,03
MEMSEG03 = 00,C0,04
MEMSEG04 = 00,C0,05
MEMSEG05 = 00,C0,06
MEMSEG06 = 00,C0,07
MEMSEG07 = 00,C0,08
MEMSEG08 = 00,C0,09
MEMSEG09 = 00,C0,0A
MEMSEG0A = 00,C0,0B
MEMSEG0B = 00,C0,0C
MEMSEG0C = 00,C0,0D
MEMSEG0D = 00,C0,0E
MEMSEG0E = 00,C0,0F
MEMSEG0F = 00,C0,10
HASHDRVA = N
HASHDRVB = N
HASHDRVC = N
HASHDRVD = Y
HASHDRVE = Y
HASHDRVF = Y
HASHDRVG = Y
HASHDRVH = Y
HASHDRVI = Y
HASHDRVJ = Y
HASHDRVK = Y
HASHDRVL = Y
HASHDRVM = N
HASHDRVN = Y
HASHDRVO = Y
HASHDRVP = Y
ALTBNKSA = Y
ALTBNKSB = Y
ALTBNKSC = Y
ALTBNKSD = N
ALTBNKSE = N
ALTBNKSF = N
ALTBNKSG = N
ALTBNKSH = N
ALTBNKSI = N
ALTBNKSJ = N
ALTBNKSK = N
ALTBNKSL = N
ALTBNKSM = N
ALTBNKSN = N
ALTBNKSO = N
ALTBNKSP = N
NDIRRECA = 10
NDIRRECB = 10
NDIRRECC = 01
NDIRRECD = 01
NDIRRECE = 01
NDIRRECF = 01
NDIRRECG = 01
NDIRRECH = 01
NDIRRECI = 01
NDIRRECJ = 01
NDIRRECK = 01
NDIRRECL = 01
NDIRRECM = 01
NDIRRECN = 01
NDIRRECO = 01
NDIRRECP = 01
NDTARECA = 10
NDTARECB = 10
NDTARECC = 01
NDTARECD = 01
NDTARECE = 01
NDTARECF = 01
NDTARECG = 01
NDTARECH = 01
NDTARECI = 01
NDTARECJ = 01
NDTARECK = 01
NDTARECL = 01
NDTARECM = 01
NDTARECN = 01
NDTARECO = 01
NDTARECP = 01
ODIRDRVA = A
ODIRDRVB = A
ODIRDRVC = A
ODIRDRVD = A
ODIRDRVE = A
ODIRDRVF = A
ODIRDRVG = A
ODIRDRVH = A
ODIRDRVI = A
ODIRDRVJ = A
ODIRDRVK = A
ODIRDRVL = A
ODIRDRVM = A
ODIRDRVN = A
ODIRDRVO = A
ODIRDRVP = A
ODTADRVA = A
ODTADRVB = A
ODTADRVC = A
ODTADRVD = A
ODTADRVE = A
ODTADRVF = A
ODTADRVG = A
ODTADRVH = A
ODTADRVI = A
ODTADRVJ = A
ODTADRVK = A
ODTADRVL = A
ODTADRVM = A
ODTADRVN = A
ODTADRVO = A
ODTADRVP = A
OVLYDIRA = Y
OVLYDIRB = Y
OVLYDIRC = Y
OVLYDIRD = Y
OVLYDIRE = Y
OVLYDIRF = Y
OVLYDIRG = Y
OVLYDIRH = Y
OVLYDIRI = Y
OVLYDIRJ = Y
OVLYDIRK = Y
OVLYDIRL = Y
OVLYDIRM = Y
OVLYDIRN = Y
OVLYDIRO = Y
OVLYDIRP = Y
OVLYDTAA = Y
OVLYDTAB = Y
OVLYDTAC = Y
OVLYDTAD = Y
OVLYDTAE = Y
OVLYDTAF = Y
OVLYDTAG = Y
OVLYDTAH = Y
OVLYDTAI = Y
OVLYDTAJ = Y
OVLYDTAK = Y
OVLYDTAL = Y
OVLYDTAM = Y
OVLYDTAN = Y
OVLYDTAO = Y
OVLYDTAP = Y
CRDATAF = N
DBLALV = Y


View File

@@ -0,0 +1,3 @@
true equ -1
false equ not true
banked equ true

View File

@@ -0,0 +1,194 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* Boot loader module *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
; - Change the sign-on message.
; - Change COM2 to COM1 for the default auxiliary devices.
;
; v1.00 - 26 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
.z80
;
maclib TPORTS.LIB
maclib ASMTYPE.LIB
;
public ?init, ?ldccp, ?rlccp, ?time
;
extrn @civec, @covec, @aivec, @aovec, @lovec, @date, @hour
extrn ?boot, ?pmsg, ?conin
;
bdos equ 5
;
; BDOS Function equates
open equ 15 ;open file
setdma equ 26 ;set direct memory access address
user equ 32 ;set/get user code
smulti equ 44 ;set multi I/O
read equ 20 ;read file
;
; Character equates
null equ 0 ;null
lf equ 10 ;line feed
cr equ 13 ;carriage return
cls equ 26 ;clear screen
;
dseg ;banked memory
;
; Initial entry point for system startup.
?init: ld hl,1000000000000000b
ld (@covec),hl ;assign CRT1 to @covec
ld hl,0010000000000000b
ld (@civec),hl ;assign KBD1 to @civec
ld hl,0000000010000000b
ld (@lovec),hl ;assign LPT1 to @lovec
ld hl,0000100000000000b
ld (@aivec),hl ;assign COM1 to @aivec
ld hl,0000100000000000b
ld (@aovec),hl ;assign COM1 to @aovec
ld hl,1 ;set date to 1st January 1978
ld (@date),hl
out (gtboot),a ;get the boot drive in reg A
ld hl,?boot ;load address of BIOS
ld de,-0051h ;subtract value for BDOS boot drive value
add hl,de ;do the subtraction (DE is negative)
ld (hl),a ;store the boot drive number
add a,'A' ;make drive letter for error message
ld (errdrv),a ;place drive letter in message
sub 'A' - 1 ;drive number A=1, B=2, C=3 etc
ld (ccpfcb),a ;put drive number in FCB for CCP.COM drive
ld hl,sgnmsg ;sign-on message
jp ?pmsg ;print signon message
;
; get/set date and time
?time: push hl ;must be saved
ld hl,@hour
ld a,c
or a
jr nz,setclk
out (gettme),a ;read time from system clock
ld hl,@date
out (getdte),a ;read date from system clock
pop hl
ret
setclk: out (settme),a ;set time in system clock
ld hl,@date
out (setdte),a ;set date in system clock
pop hl
ret
;
cseg ;common memory
;
; load CCP.COM into the TPA and save image
?ldccp: xor a
ld (ccpext),a ;zero extent
ld hl,0
ld (fcbnr),hl ;start at begining of file
ld de,ccpfcb
ld c,open ;open file containing CCP
call bdos
inc a
jp nz,openok ;if opened then no error
ld hl,errmsg
call ?pmsg
call ?conin ;any key to try again
jp ?ldccp
openok: ld de,0100h
ld c,setdma ;start of TPA
call bdos
ld de,128
ld c,smulti ;allow up to 16k bytes
call bdos
ld de,ccpfcb
ld c,read ;load CCP.COM
call bdos
out (blkcnt),a
or a
ret z
if banked
ld a,1 ;bank #1 (TPA)
out (bnkdma),a
endif
ld c,0 ;starting block # in storage
ld d,c ;starting position in block
ld e,128 ;number of 128 byte blocks to move
ld hl,0100h ;source address
out (blkput),a
ret
;
; reload CCP.COM image into the TPA
?rlccp: out (flhard),a ;flushes Z80HDD file if it exists
out (blkcnt),a
or a
jr z,?ldccp
if banked
ld a,1 ;bank #1 (TPA)
out (bnkdma),a
endif
ld c,0 ;starting block # in storage
ld d,c ;starting position in block
ld e,128 ;number of 128 byte blocks to move
ld hl,0100h ;destination address
out (blkget),a
ret
;
ccpfcb: db 0
db 'CCP COM'
db 0,0,0
ccpext: db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
fcbnr: db 0,0,0
;
errmsg: db cr, lf, lf, lf
db 'BDOS Error on '
errdrv: db 'X: CCP.COM not found'
db cr, lf, lf
db 'Press any key to retry', null
;
dseg ;banked memory
;
if banked
sgnmsg: db cls, cr, lf
db 201
rept 55
db 205
endm
db 187, cr, lf
db 186
db ' CP/M v3.1 Banked System (v1.0.0) for z80em86 emulator '
db 186, cr, lf
db 186
rept 55
db ' '
endm
db 186, cr, lf
db 186
db ' Custom BIOS, Copyright (C) 1992-2009 S.J.Kay '
db 186, cr, lf
db 200
rept 55
db 205
endm
db 188, cr, lf, lf, null
else
sgnmsg: db cls, cr, lf
db 'CP/M Plus v3.1 Non-banked System (v1.0.0) for z80em86 emulator', cr, lf
db 'Custom BIOS, Copyright (C) 1992-2009 S.J.Kay'
db cr, lf, lf, null
endif
;
end

View File

@@ -0,0 +1,305 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* Character I/O driver *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 17 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
.z80
;
maclib MODEBAUD.LIB
maclib TPORTS.LIB
;
public ?cinit, ?cist, ?cost, ?co, ?ci
public @ctbl
;
crt1 equ 0 ;CRT #1 O
crt2 equ 1 ;CRT #2 O
kbd1 equ 2 ;KBD #1 I
kbd2 equ 3 ;KBD #2 I
com1 equ 4 ;COM #1 IO
com2 equ 5 ;COM #2 IO
com3 equ 6 ;COM #3 IO
com4 equ 7 ;COM #4 IO
lpt1 equ 8 ;LPT #1 O
lpt2 equ 9 ;LPT #2 O
lpt3 equ 10 ;LPT #3 O
;
cseg ;common memory
;
; Initialize character devices
?cinit: ld a,c
cp crt1
jp z,cr1int ;CRT #1 initialize
cp crt2
jp z,cr2int ;CRT #2 initialize
cp kbd1
jp z,kb1int ;KBD #1 initialize
cp kbd2
jp z,kb2int ;KBD #2 initialize
cp com1
jp z,comint ;COM #1 initialize
cp com2
jp z,comint ;COM #2 initialize
cp com3
jp z,comint ;COM #3 initialize
cp com4
jp z,comint ;COM #4 initialize
cp lpt1
jp z,lptint ;LPT #1 initialize
cp lpt2
jp z,lptint ;LPT #2 initialize
cp lpt3
jp z,lptint ;LPT #3 initialize
ret ;return if no device
;
; Console input status
?cist: ld a,b
cp kbd1
jp z,kb1ist ;KBD #1 input status
cp kbd2
jp z,kb2ist ;KBD #2 input status
cp com1
jp z,comips ;COM #1 input status
cp com2
jp z,comips ;COM #2 input status
cp com3
jp z,comips ;COM #3 input status
cp com4
jp z,comips ;COM #4 input status
xor a
ret ;return if no device
;
; Console input
?ci: ld a,b
cp kbd1
jp z,kb1ip ;KBD #1 input
cp kbd2
jp z,kb2ip ;KBD #2 input
cp com1
jp z,comip ;COM #1 input
cp com2
jp z,comip ;COM #2 input
cp com3
jp z,comip ;COM #3 input
cp com4
jp z,comip ;COM #4 input
xor a
ret ;return if no device
;
; Console output status
?cost: ld a,b
cp crt1
jp z,cr1ost ;CRT #1 output status
cp crt2
jp z,cr2ost ;CRT #2 output status
cp com1
jp z,comops ;COM #1 output status
cp com2
jp z,comops ;COM #2 output status
cp com3
jp z,comops ;COM #3 output status
cp com4
jp z,comops ;COM #4 output status
cp lpt1
jp z,lptost ;LPT #1 output status
cp lpt2
jp z,lptost ;LPT #2 output status
cp lpt3
jp z,lptost ;LPT #3 output status
ld a,0ffh
ret ;return if no device
;
; Console output
?co: ld a,b
cp crt1
jp z,cr1out ;CRT #1 output
cp crt2
jp z,cr2out ;CRT #2 output
cp com1
jp z,comop ;COM #1 output
cp com2
jp z,comop ;COM #2 output
cp com3
jp z,comop ;COM #3 output
cp com4
jp z,comop ;COM #4 output
cp lpt1
jp z,lptop ;LPT #1 output
cp lpt2
jp z,lptop ;LPT #2 output
cp lpt3
jp z,lptop ;LPT #3 output
ret ;return if no device
;
kb1int: out (kbd1in),a ;keyboard #1 initialize
ret
kb1ist: out (kbd1st),a ;keyboard #1 status
ret
kb1ip: out (kbd1ip),a ;keyboard #1 input
ret
;
kb2int: out (kbd2in),a ;keyboard #2 initialize
ret
kb2ist: out (kbd2st),a ;keyboard #2 status
ret
kb2ip: out (kbd2ip),a ;keyboard #2 input
ret
cr1int: out (crt1in),a ;CRT #1 initialize
ret
cr1ost: out (crt1st),a ;CRT #1 status
ret
cr1out: out (crt1op),a ;CRT #1 output
ret
;
cr2int: out (crt2in),a ;CRT #2 initialize
ret
cr2ost: out (crt2st),a ;CRT #2 status
ret
cr2out: out (crt2op),a ;CRT #2 output
ret
;
comint: ld bc,com1bd
cp com2
jp c,fndbdr
ld bc,com2bd
jp z,fndbdr
ld bc,com3bd
cp com4
jp c,fndbdr
ld bc,com4bd
fndbdr: sub com1
ld d,0 ;COM port # to DE (DX in Z80 emulator)
ld e,a
ld hl,bdrtbl
ld a,(bc) ;get CP/M baud rate code from control table
push de
ld d,0
ld e,a
add hl,de
pop de
ld a,(hl) ;get IBM baud rate code from IBM table
sla a
jr c,badbdr ;baud rate not allowed if C flag set
or 00000011b ;parity none, 1 stop bit, 8 data bits
out (comini),a ;COM initialize
ret
badbdr: xor a
ld (bc),a ;kill baud rate in table
ret
comops: sub com1
ld d,0 ;COM port # to DE (DX in Z80 emulator)
ld e,a
out (comost),a ;COM output status
ret
comop: sub com1
ld d,0 ;COM port # to DE (DX in Z80 emulator)
ld e,a
out (comout),a ;COM output
ret
comips: sub com1
ld d,0 ;COM port # to DE (DX in Z80 emulator)
ld e,a
out (comist),a ;COM input status
ret
comip: sub com1
ld d,0 ;COM port # to DE (DX in Z80 emulator)
ld e,a
out (cominp),a ;COM input
ret
;
lptint: sub lpt1
ld d,0 ;LPT port # to DE (DX in Z80 emulator)
ld e,a
out (lptini),a ;LPT initialize
ret
lptost: sub lpt1
ld d,0 ;LPT port # to DE (DX in Z80 emulator)
ld e,a
out (lptsta),a ;LPT status
ret
lptop: sub lpt1
ld d,0 ;LPT port # to DE (DX in Z80 emulator)
ld e,a
out (lptout),a ;LPT output
ret
;
bdrtbl: db 10000000b ;-- no baud rate
db 10000000b ;50 baud n/a
db 10000000b ;75 baud n/a
db 00000000b ;110 baud - IBM
db 10000000b ;134 baud n/a
db 00010000b ;150 baud - IBM
db 00100000b ;300 baud - IBM
db 00110000b ;600 baud - IBM
db 01000000b ;1200 baud - IBM
db 10000000b ;1800 baud n/a
db 01010000b ;2400 baud - IBM
db 10000000b ;3600 baud n/a
db 01100000b ;4800 baud - IBM
db 10000000b ;7200 baud n/a
db 01110000b ;9600 baud - IBM
db 10000000b ;19200 baud n/a
;
@ctbl: db 'CRT1 ' ;Dev 0, CRT #1 driver
db mb$output
db baud$none
;
db 'CRT2 ' ;Dev 1, CRT #2 driver
db mb$output
db baud$none
;
db 'KBD1 ' ;Dev 2, KBD #1 Keyboard
db mb$input
db baud$none
;
db 'KBD2 ' ;Dev 3, KBD #2 Keyboard
db mb$input
db baud$none
;
db 'COM1 ' ;Dev 4, serial via COM #1
db mb$input+mb$output+mb$serial+mb$soft$baud
com1bd: db baud$9600
;
db 'COM2 ' ;Dev 5, serial via COM #2
db mb$input+mb$output+mb$serial+mb$soft$baud
com2bd: db baud$9600
;
db 'COM3 ' ;Dev 6, serial via COM #3
db mb$input+mb$output+mb$serial+mb$soft$baud
com3bd: db baud$9600
;
db 'COM4 ' ;Dev 7, serial via COM #4
db mb$input+mb$output+mb$serial+mb$soft$baud
com4bd: db baud$9600
;
db 'LPT1 ' ;Dev 8, Centronics via LPT#1
db mb$output
db baud$none
;
db 'LPT2 ' ;Dev 9, Centronics via LPT#2
db mb$output
db baud$none
;
db 'LPT3 ' ;Dev 10, Centronics via LPT#3
db mb$output
db baud$none
;
db 0 ;marks end of table
;
end

View File

@@ -0,0 +1,203 @@
; Macro Definitions for CP/M3 BIOS Data Structures.
; Corrected by Lindsay Probyn for over flow checks
; in dph macro (12 August 1983)
; Copyright 1983 SME Systems
; 22 Queen St Mitcham.
; dtbl <dph0,dph1,...> - drive table
; dph translate$table, - disk parameter header
; disk$parameter$block,
; checksum$size, (optional)
; alloc$size (optional)
; skew sectors, - skew table
; skew$factor,
; first$sector$number
; dpb physical$sector$size, - disk parameter block
; physical$sectors$per$track,
; number$tracks,
; block$size,
; number$dir$entries,
; track$offset,
; checksum$vec$size (optional)
; Drive Table. Contains 16 one word entries.
dtbl macro ?list
local ?n
?n set 0
irp ?drv,<?list>
?n set ?n+1
dw ?drv
endm
if ?n > 16
.' Too many drives. Max 16 allowed'
exitm
endif
if ?n < 16
rept (16-?n)
dw 0
endm
endif
endm
dph macro ?trans,?dpb,?csize,?asize
local ?csv,?alv
dw ?trans ; translate table address
db 0,0,0,0,0,0,0,0,0 ; BDOS Scratch area
db 0 ; media flag
dw ?dpb ; disk parameter block
if not nul ?csize
dw ?csv ; checksum vector
else
dw 0FFFEh ; checksum vector allocated by
endif ; GENCPM
if not nul ?asize
dw ?alv ; allocation vector
else
dw 0FFFEh ; alloc vector allocated by GENCPM
endif
dw 0fffeh,0fffeh,0fffeh ; dirbcb, dtabcb, hash alloc'd
; by GENCPM
db 0 ; hash bank
if not nul ?csize
?csv ds ?csize ; checksum vector
endif
if not nul ?asize
?alv ds ?asize ; allocation vector
endif
endm
dpb macro ?psize,?pspt,?trks,?bls,?ndirs,?off,?ncks
local ?spt,?bsh,?blm,?exm,?dsm,?drm,?al0,?al1,?cks,?psh,?psm
local ?n,?spb,?x,?y,?z
;; physical sector mask and physical sector shift
?psh set 0
?n set ?psize/128
?psm set ?n-1
rept 8
?n set ?n/2
if ?n = 0
exitm
endif
?psh set ?psh + 1
endm
?spt set ?pspt*(?psize/128)
?bsh set 3
?n set ?bls/1024
rept 8
?n set ?n/2
if ?n = 0
exitm
endif
?bsh set ?bsh + 1
endm
?blm set ?bls/128-1
?size set (?trks-?off)*?pspt
?spb set ?bls/?psize
?dsm set (?size/?spb)-1
?exm set ?bls/1024
if ?dsm > 255
if ?bls = 1024
.'Error, can''t have this size disk with 1k block size'
exitm
endif
?exm set ?exm/2
endif
?exm set ?exm-1
if ?ndirs > ?bls/2
.'Error, increase block size or decrease directory entries'
exitm
endif
?all set 0
?x set ?ndirs
?y set ?bls-1
?z set ?bls
rept 16
if ?x > 2047
?x set ?x/2
?y set ?y/2
?z set ?z/2
else
exitm
endif
endm
?n set (?x*32+?y)/?z
rept ?n
?all set (?all shr 1) or 8000h
endm
?al0 set high ?all
?al1 set low ?all
?drm set ?ndirs-1
if not nul ?ncks
?cks set ?ncks
else
?cks set ?ndirs/4
endif
dw ?spt ; 128 byte records per track
db ?bsh,?blm ; block shift and mask
db ?exm ; extent mask
dw ?dsm ; maximum block number
dw ?drm ; maximum directory entry number
db ?al0,?al1 ; alloc vector for directory
dw ?cks ; checksum size
dw ?off ; offset for system tracks
db ?psh,?psm ; physical sector size shift
; and mask
endm
;
gcd macro ?m,?n
;; greatest common divisor of m,n
;; produces value gcdn as result
;; (used in sector translate table generation)
?gcdm set ?m ;;variable for m
?gcdn set ?n ;;variable for n
?gcdr set 0 ;;variable for r
rept 65535
?gcdx set ?gcdm/?gcdn
?gcdr set ?gcdm - ?gcdx*?gcdn
if ?gcdr = 0
exitm
endif
?gcdm set ?gcdn
?gcdn set ?gcdr
endm
endm
skew macro ?secs,?skf,?fsc
;; generate the translate table
?nxtsec set 0 ;;next sector to fill
?nxtbas set 0 ;;moves by one on overflow
gcd %?secs,?skf
;; ?gcdn = gcd(?secs,skew)
?neltst set ?secs/?gcdn
;; neltst is number of elements to generate
;; before we overlap previous elements
?nelts set ?neltst ;;counter
rept ?secs ;;once for each sector
db ?nxtsec+?fsc
?nxtsec set ?nxtsec+?skf
if ?nxtsec >= ?secs
?nxtsec set ?nxtsec-?secs
endif
?nelts set ?nelts-1
if ?nelts = 0
?nxtbas set ?nxtbas+1
?nxtsec set ?nxtbas
?nelts set ?neltst
endif
endm
endm

View File

@@ -0,0 +1,113 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* CP/M 3 Cold Boot Loader *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; works for banked and non banked systems
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 26 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
.z80
;
maclib TPORTS.LIB
;
public rdrv
;
extrn dph, dpb, xlt
;
ver equ 1 ;loader version number
;
; Z80 Emulator starts executing here after loading 1st sector
boot: jp start ;1st byte must be C3 hex
;
; information extracted by PUTLDR.COM utility (do not rearrange order)
dw 0aa55h ;checked by install utility
db ver ;loader version number
dw boot ;execute address used to calculate offsets
dw dph ;disk parameter header
dw dpb ;disk parameter block
dw xlt ;sector translate table
;
; information placed here by PUTLDR.COM utility (do not rearrange order)
seclen: dw 0 ;sector length
sectrk: db 0 ;sectors per track
rdrv: db 0 ;sides, type, density, drive select
tracks: db 0 ;reserved tracks to load
banked: db 0 ;0 = non banked, >0 = banked system
;
; load the remainder of the CPMLDR.SYS code
start: out (gtboot),a ;what drive did boot come from
ld e,a
cp 2 ;floppy A: or B: drive ?
ld a,rdhard
jp nc,settyp
ld a,rdflop
settyp: ld (flphdd+1),a ;set floppy or HDD read port
ld bc,0002h ;track #0, sector #2 (1st sector loaded)
ld d,0 ;side #0
ld hl,boot
load: push bc
ld bc,(seclen) ;sector length
add hl,bc ;next DMA address
pop bc
ld a,2 ;sector size code for floppy driver (2=512)
flphdd: out (0ffh),a ;read 1 sector
or a
jp z,nxtsec
out (failed),a ;boot strap failure
nxtsec: inc c ;next sector
ld a,(sectrk)
cp c
jp nc,load
ld a,(tracks)
dec a
ld (tracks),a
jp z,setsys
ld c,1 ;sector #1
inc d ;change side select
ld a,d
and 00000001b ;keep the odd/even bit
ld d,a
jp nz,load
inc b ;next track #
jp load
setsys: ld hl,0 ;access user byte #0
ld c,0 ;get user byte function
out (usrbyt),a ;get user byte
ld hl,stdnme
cp 1 ;non banked CP/M 3 system ?
jp z,setnme
cp 2 ;banked CP/M 3 system ?
jp z,bnksys
ld a,(banked) ;default banked or non banked flag
or a ;banked CP/M 3 system ?
jp z,setnme
bnksys: ld bc,0f000h ;size of bank #0, bank #1
out (bnkuse),a ;initialize for a banked system
ld hl,bnknme
setnme: ld bc,11 ;bytes to be moved
ld de,loader+172 ;replace CPM3.SYS with new name
ldir
jp loader
bnknme: db 'BNKCPM SYS'
stdnme: db 'STDCPM SYS'
;
ds 128 ;CPMLDR.SYS uses this area
;
loader equ $
;
end

Binary file not shown.

View File

@@ -0,0 +1,43 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* DPH unit byte definition for CP/M 3 *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 17 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
; DPH UNIT (@RDRV) byte mode bits
; bit 7, 6 - cylinder format
uddsk equ 00000000b ;double sided up-down disk
dsdsk equ 01000000b ;double sided disk
ssdsk equ 10000000b ;single sided disk
; bit 5, 4 - disk density
sden equ 00000000b ;single density
dden equ 00010000b ;double density
hden equ 00100000b ;high density
; bit 3, 2 - drive type
flp equ 00000000b ;floppy type
hdd equ 00000100b ;HDD drive type
ram equ 00001000b ;RAM drive type
; bit 1, 0 - drive select
drv0 equ 00000000b ;drive select code 0
drv1 equ 00000001b ;drive select code 1
drv2 equ 00000010b ;drive select code 2
drv3 equ 00000011b ;drive select code 3
; end of file

View File

@@ -0,0 +1,204 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* Emulator CP/M 3 Disk tables *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 17 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
public @dtbl
public HDDdsk, ramdsk, dph2, dpb3
;
extrn ifdsk, lfdsk, rfdsk, wfdsk
extrn ihdsk, lhdsk, rhdsk, whdsk
extrn irdsk, lrdsk, rrdsk, wrdsk
;
maclib cpm3
maclib dphunit
maclib asmtype
;
unt0 equ dsdsk + flp + hden + drv0
unt1 equ dsdsk + flp + hden + drv1
unt2 equ ssdsk + hdd
unt3 equ ssdsk + ram
;
cseg ;common memory
@dtbl: dw dph0 ; A: floppy-disk
dw dph1 ; B: floppy-disk
HDDdsk: dw dph2 ; C: Hard Disk (may change table pos)
dw 0 ; D:
dw 0 ; E:
dw 0 ; F:
dw 0 ; G:
dw 0 ; H:
dw 0 ; I:
dw 0 ; J:
dw 0 ; K:
dw 0 ; L:
ramdsk: dw dph3 ; M: RAM-disk
dw 0 ; N:
dw 0 ; O:
dw 0 ; P:
; Drive A: - 80T DS HD 18 s/t 512 b/s
dpb0: dpb 512, 18, 160, 2048, 512, 1
; Drive B: - 80T DS HD 18 s/t 512 b/s
dpb1: dpb 512, 18, 160, 2048, 512, 1
; Drive C: - HDD-DISK (4 Megabytes)
dpb2: dpb 512, 64, 128, 2048, 1024, 1, 8000h
; Drive M: - RAM-DISK (16k default)
dpb3: dpb 128, 128, 1, 2048, 128, 0, 8000h
dseg ;banked memory
; Disk Parameter Header drive A:
dw wfdsk ;write floppy disk routine
dw rfdsk ;read floppy disk routine
dw lfdsk ;logon floppy disk routine
dw ifdsk ;initialize floppy disk routine
db unt0 ;UNIT
db 0 ;TYPE
dph0: dw xlt0 ;XLT
ds 9 ;-0- (BDOS scratch use)
db 0 ;Media flag
dw dpb0 ;DPB
dw csv0 ;CSV
dw alv0 ;ALV
if banked
dw 0fffeh ;DIRBCB
dw 0fffeh ;DTABCB
else
dw dirbcb ;DIRBCB
dw dtabcb ;DTABCB
endif
dw 0fffeh ;HASH (gencpm option)
db 0 ;HBANK
; Disk Parameter Header drive B:
dw wfdsk ;write floppy disk routine
dw rfdsk ;read floppy disk routine
dw lfdsk ;logon floppy disk routine
dw ifdsk ;initialize floppy disk routine
db unt1 ;UNIT
db 0 ;TYPE
dph1: dw xlt1 ;XLT
ds 9 ;-0- (BDOS scratch use)
db 0 ;Media flag
dw dpb1 ;DPB
dw csv1 ;CSV
dw alv1 ;ALV
if banked
dw 0fffeh ;DIRBCB
dw 0fffeh ;DTABCB
else
dw dirbcb ;DIRBCB
dw dtabcb ;DTABCB
endif
dw 0fffeh ;HASH (gencpm option)
db 0 ;HBANK
; Disk Parameter Header HDD drive
dw whdsk ;write HDD routine
dw rhdsk ;read HDD routine
dw lhdsk ;logon HDD routine
dw ihdsk ;initialize HDD routine
db unt2 ;UNIT
db 0 ;TYPE
dph2 dw xlt2 ;XLT
ds 9 ;-0- (BDOS scratch use)
db 0 ;Media flag
dw dpb2 ;DPB
dw 0 ;CSV
dw alv2 ;ALV
if banked
dw 0fffeh ;DIRBCB
dw 0fffeh ;DTABCB
else
dw dirbcb ;DIRBCB
dw dtabcb ;DTABCB
endif
dw 0fffeh ;HASH (gencpm option)
db 0 ;HBANK (n/a)
; Disk Parameter Header drive M:
dw wrdsk ;write RAM-DISK routine
dw rrdsk ;read RAM-DISK routine
dw lrdsk ;logon RAM-DISK routine
dw irdsk ;initialize RAM-DISK routine
db unt3 ;UNIT
db 0 ;TYPE
dph3: dw 0 ;XLT (no translate table)
ds 9 ;-0- (BDOS scratch use)
db 0 ;Media flag
dw dpb3 ;DPB (Ram-disk)
dw 0 ;CSV (no check sum vector)
dw alv3 ;ALV
if banked
dw 0fffeh ;DIRBCB (gencpm allocates)
else
dw dirbcb ;DIRBCB
endif
dw 0ffffh ;DTABCB (no data buffers)
dw 0fffeh ;HASH (gencpm option)
db 0 ;HBANK
; skew tables
xlt0: db 1, 4, 7, 10, 13, 16
db 2, 5, 8, 11, 14, 17
db 3, 6, 9, 12, 15, 18
ds 32
xlt1: db 1, 4, 7, 10, 13, 16
db 2, 5, 8, 11, 14, 17
db 3, 6, 9, 12, 15, 18
ds 32
xlt2: db 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
db 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
db 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48
db 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
; directory checksum tables
csv0: ds 128 ;512 directory entries maximum
csv1: ds 128 ; " " " "
if banked
; double bit allocation tables BLOCKS 1K BLS 2K BLS 4K BLS
alv0: ds 200 ; 800 800k 1600k 3200k
alv1: ds 200 ; 800 800k 1600k 3200k
alv2: ds 512 ; 2048 2048k 4096k 8192k
alv3: ds 64 ; 256 n/a 512k n/a
else
; single bit allocation tables BLOCKS 1K BLS 2K BLS 4K BLS
alv0: ds 100 ; 800 800k 1600k 3200k
alv1: ds 100 ; 800 800k 1600k 3200k
alv2: ds 256 ; 2048 2048k 4096k 8192k
alv3: ds 32 ; 256 n/a 512k n/a
; directory buffer control block
dirbcb: db 0ffh,0,0,0,0,0,0,0,0,0
dw dirbuf
; data buffer control block
dtabcb: db 0ffh,0,0,0,0,0,0,0,0,0
dw dtabuf
; directory and data buffers
dirbuf: ds 1024 ;1k directory buffer
dtabuf: ds 1024 ;1k data buffer
endif
end

View File

@@ -0,0 +1,191 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* CP/M 3 Loader BIOS *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 17 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
.z80
;
maclib TPORTS.LIB
;
public dph, dpb, xlt
;
extrn rdrv
;
jp boot ;initial entry on cold start
jp null ;not required
jp null ; " "
jp null ; " "
jp crtop ;send console output character
jp null ;not required
jp null ; " "
jp null ; " "
jp home ;set disks to logical home
jp seldsk ;select drive, return disk parameter info
jp settrk ;set disk track
jp setsec ;set disk sector
jp setdma ;set disk I/O memory address
jp read ;read physical block(s)
jp null ;not required
jp null ; " "
jp sectrn ;translate logical to physical sector
jp crtost ;return console output status
jp null ;not required
jp null ; " "
jp null ; " "
jp null ; " "
jp null ; " "
jp null ; " "
jp null ; " "
jp move ;block move memory to memory
jp null ;not required
jp null ; " "
jp null ; " "
jp null ; " "
jp null ; " "
jp null ; " "
jp null ; " "
;
; null code
null: ld a,1ah ;end of file character
ret
;
; boot code
boot: out (crt1in),a ;initialize CRT driver
out (gtboot),a ;what drive did boot come from
cp 2 ;floppy A: or B: drive ?
ld a,rdhard
jp nc,settyp
ld a,rdflop
settyp: ld (flphdd+1),a ;set floppy or HDD read port
ret
;
; block move
move: ex de,hl
ldir
ex de,hl
ret
;
; home disk
home: ld c,0 ;fall through to set track
;
; set track
settrk: ld a,c
ld (track),a
ret
;
; set sector
setsec: ld a,c
ld (sector),a
ret
;
; set DMA address
setdma: ld (dma),bc
ret
;
; select disk
seldsk: ld hl,dph ;DPH address
ret
;
; sector translate
sectrn: ld hl,xlt ;translate table address
add hl,bc ;add logical sector
ld l,(hl) ;get physical sector
ld h,0
ret
;
; read sector from boot disk
read: ld a,(rdrv)
ld h,a
ld d,0 ;side #0
ld a,(track)
sla h
jp c,side0 ;single sided disk if carry
sla h
jp c,dsdisk ;double sided disk if carry
cp 40
jp c,side0 ;side 0 of up-down if carry
ld b,a ;side 1 of up-down
ld a,79
sub b
jp side1
dsdisk: srl a
jp nc,side0
side1: ld d,1 ;side #1
side0: ld b,a ;track number
ld a,(sector)
ld c,a ;sector number
ld hl,(dma)
out (gtboot),a ;what drive did boot come from
ld e,a ;drive information
ld a,2 ;sector size code for floppy driver (2=512)
flphdd: out (0ffh),a ;read 1 sector
or a
ret z
ld a,1
ret
;
crtost: out (crt1st),a ;CRT output status
ret
;
crtop: out (crt1op),a ;CRT output
ret
;
track: db 0
sector: db 0
dma: dw 0
;
; Disk Parameter Header
db 0 ;UNIT
db 0 ;TYPE
dph: dw xlt ;XLT
db 0,0,0 ;-0- (BDOS scratch use)
db 0,0,0 ;-0-
db 0,0,0 ;-0-
db 0 ;Media flag
dw dpb ;DPB
dw csv ;CSV
dw alv ;ALV
dw dirbcb ;DIRBCB
dw dtabcb ;DTABCB
dw 0ffffh ;HASH (n/a)
db 0 ;HBANK (n/a)
;
; Disk Parametr Block table
dpb: ds 17 ;filled in by PUTLDR.COM utility
;
; disk skew table
xlt: ds 128 ;filled in by PUTLDR.COM utility
;
; checksum table
csv: ds 512 ;2048 directory entries maximum
;
; allocation table
alv: ds 512 ;512 * 8 blocks, space = 512 * 8 * BLS
;
; directory buffer control block
dirbcb: db 0ffh,0,0,0,0,0,0,0,0,0
dw buff0
;
; data buffer control block
dtabcb: db 0ffh,0,0,0,0,0,0,0,0,0
dw buff1
;
; directory and data buffers
buff0 equ $ ;1k directory buffer
buff1 equ buff0+1024 ;1k data buffer
;
end

View File

@@ -0,0 +1,107 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* Floppy disk driver *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 17 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
; Entry point 1 : ifdsk - Initialize
; Entry point 2 : lfdsk - Login
; Entry point 3 : wfdsk - Write sector
; Entry point 4 : rfdsk - Read sector
.z80
;
maclib TPORTS.LIB
maclib ASMTYPE.LIB
;
public ifdsk, lfdsk, rfdsk, wfdsk
;
extrn @dtbl, @adrv, @rdrv, @dbnk, @dma, @trk, @sect, @cnt
;
dseg ;banked memory
; Entry point 1 - Initialize floppy drive
ifdsk: ret
; Entry point 2 - Login floppy drive
lfdsk: ret
; Entry point 3 - Write floppy sector
wfdsk: or 0ffh ;write operation flag value
jp fdisk
; Entry point 4 - Read floppy sector
rfdsk: xor a ;read operation flag value
fdisk: push af ;save operation flag
ld a,(@rdrv)
ld h,a
ld l,0 ;side #0
ld a,(@trk)
sla h
jp c,side0 ;single sided disk if carry
sla h
jp c,dsdisk ;double sided disk if carry
cp 40
jp c,side0 ;side 0 of up-down if carry
ld b,a ;side 1 of up-down
ld a,79
sub b
jp side1
dsdisk: srl a
jp nc,side0
side1: ld l,1 ;set side #1
side0: ld (track),a
ld a,l
ld (side),a
ld hl,12 ;offset into DPH for DPB address
add hl,de
ld e,(hl) ;LSB of DPB address
inc hl
ld d,(hl) ;MSB of DPB address
ld hl,15 ;offset into DPB for PSH
add hl,de
ld a,(hl)
ld (secsze),a ;sector size code
ld a,(@rdrv)
ld e,a ;contains physical select code
ld a,(side)
ld d,a
ld a,(track)
ld b,a
ld a,(@sect)
ld c,a
if banked
ld a,(@dbnk)
out (bnkdma),a
endif
ld hl,(@dma)
pop af ;restore operation flag
ld a,(secsze)
jp z,readop
out (wrflop),a
jp result
readop: out (rdflop),a
result: or a
ret z
ld a,1
ret
;
secsze: db 0
side: db 0
track: db 0
;
end

View File

@@ -0,0 +1,90 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* Hard disk driver *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 17 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
; Entry point 1 : ihdsk - Initialize
; Entry point 2 : lhdsk - Login
; Entry point 3 : whdsk - Write sector
; Entry point 4 : rhdsk - Read sector
.z80
;
maclib TPORTS.LIB
maclib ASMTYPE.LIB
;
public ihdsk, lhdsk, rhdsk, whdsk
;
extrn @dtbl, @adrv, @rdrv, @dbnk, @dma, @trk, @sect, @cnt
extrn HDDdsk, dph2
;
dseg ;banked memory
; Entry point 1 - Initialize hard disk
ihdsk: ld hl,0
ld (HDDdsk),hl ;kill the HDD file entry (was for GENCPM)
out (gthard),a ;get the HDD file drive code
cp 16 ;is drive code in range ?
ret nc
inc a ;HDD file present ?
ret z
dec a ;restore drive code number
add a,a
ld d,0
ld e,a
ld hl,@dtbl ;drive table address
add hl,de ;table offset for DPH entry
ld de,dph2 ;DPH address for HDD file
ld (hl),e
inc hl
ld (hl),d
ret
; Entry point 2 - Login hard disk drive
lhdsk: ret
; Entry point 3 - Write hard disk sector
whdsk: or 0ffh ;write operation flag value
jp hdisk
; Entry point 4 - Read hard disk sector
rhdsk: xor a ;read operation flag value
hdisk: push af ;save operation flag
if banked
ld a,(@dbnk)
out (bnkdma),a
endif
ld a,(@trk)
ld b,a
ld a,(@sect)
ld c,a
ld a,(@adrv)
ld e,a
ld hl,(@dma)
pop af ;restore operation flag
ld a,2 ;sector size code (512 bytes)
jp z,readop
out (wrhard),a
jp result
readop: out (rdhard),a
result: or a
ret z
ld a,1
ret
;
end

View File

@@ -0,0 +1,9 @@
; ***** CREATING A BANKED CP/M 3 SYSTEM *****
cp bnkcpm.dat m:gencpm.dat
cp bnkbdos3.spr resbdos3.spr m:
m:
link bnkbios3[b]=zbios,scb,boot,chario,move,flpmod,hddmod,ramdsk,dskmod
gencpm auto
cp cpm3.sys a:bnkcpm.sys
a:
;banked CPM3.SYS is now in A:BNKCPM.SYS

View File

@@ -0,0 +1,9 @@
; ***** CREATING A NON BANKED CP/M 3 SYSTEM *****
cp stdcpm.dat m:gencpm.dat
cp bdos3.spr m:
m:
link bios3[os,nr]=zbios,scb,boot,chario,move,flpmod,hddmod,ramdsk,dskmod
gencpm auto
cp cpm3.sys a:stdcpm.sys
a:
;Non banked CPM3.SYS is now in A:STDCPM.SYS

View File

@@ -0,0 +1,6 @@
; Build the non-banked and banked CP/M 3 systems and the loader.
submit a:asmstd.sub
submit a:lnkstd.sub
submit a:asmbnk.sub
submit a:lnkbnk.sub
submit a:mkeldr.sub

View File

@@ -0,0 +1,10 @@
; ***** BUILDING CP/M 3 LOADER *****
cp cpmboot.mac fdcldr.mac tports.lib cpmldr.rel m:
m:
m80
< =cpmboot
< =fdcldr
<^C
link cpmldr.sys[l0080,nr]=cpmboot,cpmldr,fdcldr
cp -v cpmldr.sys a:
a:

View File

@@ -0,0 +1,32 @@
; equates for mode byte bit fields
;
mb$input equ 00000001b ; device may do input
mb$output equ 00000010b ; device may do output
mb$in$out equ mb$input+mb$output
;
mb$soft$baud equ 00000100b ; software selectable
; baud rates
;
mb$serial equ 00001000b ; device may use protocol
mb$xonxoff equ 00010000b ; XON/XOFF protocol
; enabled
;
baud$none equ 0 ; no baud rate associated
; with this device
baud$50 equ 1 ; 50 baud
baud$75 equ 2 ; 75 baud
baud$110 equ 3 ; 110 baud
baud$134 equ 4 ; 134.5 baud
baud$150 equ 5 ; 150 baud
baud$300 equ 6 ; 300 baud
baud$600 equ 7 ; 600 baud
baud$1200 equ 8 ; 1200 baud
baud$1800 equ 9 ; 1800 baud
baud$2400 equ 10 ; 2400 baud
baud$3600 equ 11 ; 3600 baud
baud$4800 equ 12 ; 4800 baud
baud$7200 equ 13 ; 7200 baud
baud$9600 equ 14 ; 9600 baud
baud$19200 equ 15 ; 19.2k baud
;
; end of file

View File

@@ -0,0 +1,57 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* Bank & Move module *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 17 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
; ?move : move block of memory
; ?bank : select bank for code execution
; ?xmove : setup for interbank move
.z80
;
maclib TPORTS.LIB
maclib ASMTYPE.LIB
;
public ?move, ?xmove, ?bank
;
cseg ;common memory
;
if banked
?move: out (bnkmve),a
add hl,bc
ex de,hl
add hl,bc
ex de,hl
ld bc,0
ret
;
?bank: push af
out (bnksel),a
pop af
ret
?xmove: out (bnkdta),a
ret
else
?move: ex de,hl
ldir
ex de,hl
?bank:
?xmove: ret
endif
;
end

View File

@@ -0,0 +1,3 @@
setdef *,c [temporary=m:, order=(com,sub)]
cpmjob m:
m:cpmjob.sub

View File

@@ -0,0 +1,100 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* RAM Disk driver *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 26 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
; Entry point 1 : irdsk - Initialize
; Entry point 2 : lrdsk - Login
; Entry point 3 : wrdsk - Write sector
; Entry point 4 : rrdsk - Read sector
.z80
;
maclib TPORTS.LIB
maclib ASMTYPE.LIB
;
public irdsk, lrdsk, rrdsk, wrdsk
;
extrn @trk, @sect, @dma, @dbnk
extrn ramdsk, dpb3
;
dseg ;banked memory
;
; Entry point 1 - Initialize
irdsk: out (blkcnt),a
cp 2
jr c,kildsk
dec a
ld b,a ;number of blocks to format
cp 32
jr c,fnddsm
xor a ;setup maximum sized RAM disk
fnddsm: rlca
rla
rla
dec a
setdsm: ld (dpb3+5),a ;set maximum number of blocks
ld c,0 ;get user byte function
ld hl,1 ;access user byte number 1
out (usrbyt),a ;see if system booted before
cp 030h ;CP/M ver 3.0 ?
ret z
ld c,1 ;block #1
format: ld d,0
ld e,128 ;
ld a,0e5h ;format value
out (blkfil),a ;fill 16k block with format byte
inc c ;next block
djnz format
ld c,0ffh ;set user byte function
ld a,030h ;set flag to CP/M ver 3.0
ld hl,1 ;access user byte number 1
out (usrbyt),a
ret
kildsk: ld hl,0
ld (ramdsk),hl ;kill entry in disk table
ret
;
; Entry point 2 - Login
lrdsk: ret ;nothing required
;
; Entry point 3 - Write sector
wrdsk: ld b,0ffh ;write operation flag
jr secmve
;
; Entry point 4 - Read sector
rrdsk: ld b,0 ;read operation flag
;
secmve: ld hl,(@dma) ;transfer address
if banked
ld a,(@dbnk)
out (bnkdma),a
endif
ld a,(@trk) ;track 0 to ?
inc a ;skip block #0 (used for CCP storage)
ld c,a
ld a,(@sect) ;sector 0 to 127
ld d,a
ld e,1 ;1 sector to move
inc b ;test if read or write operation
jr z,write ;write RAM-DISK if Z
out (blkget),a ;read 1 sector
ret ;error code in A
write: out (blkput),a ;write 1 sector
ret ;error code in A
;
end

Binary file not shown.

View File

@@ -0,0 +1,52 @@
;**************************************************************************
;* System Control Block Definition for CP/M 3 BIOS *
;* *
;* Supplied by Digital Research *
;* *
;**************************************************************************
;
public @civec, @covec, @aivec, @aovec, @lovec, @bnkbf
public @crdma, @crdsk, @vinfo, @resel, @fx, @usrcd
public @mltio, @ermde, @erdsk, @media, @bflgs
public @date, @hour, @min, @sec, ?erjmp, @mxtpa
;
scb$base equ 0FE00H ; Base of the SCB
@CIVEC equ scb$base+22h ; Console Input Redirection
; Vector (word, r/w)
@COVEC equ scb$base+24h ; Console Output Redirection
; Vector (word, r/w)
@AIVEC equ scb$base+26h ; Auxiliary Input Redirection
; Vector (word, r/w)
@AOVEC equ scb$base+28h ; Auxiliary Output Redirection
; Vector (word, r/w)
@LOVEC equ scb$base+2Ah ; List Output Redirection
; Vector (word, r/w)
@BNKBF equ scb$base+35h ; Address of 128 Byte Buffer
; for Banked BIOS (word, r/o)
@CRDMA equ scb$base+3Ch ; Current DMA Address
; (word, r/o)
@CRDSK equ scb$base+3Eh ; Current Disk (byte, r/o)
@VINFO equ scb$base+3Fh ; BDOS Variable "INFO"
; (word, r/o)
@RESEL equ scb$base+41h ; FCB Flag (byte, r/o)
@FX equ scb$base+43h ; BDOS Function for Error
; Messages (byte, r/o)
@USRCD equ scb$base+44h ; Current User Code (byte, r/o)
@MLTIO equ scb$base+4Ah ; Current Multi-Sector Count
; (byte,r/w)
@ERMDE equ scb$base+4Bh ; BDOS Error Mode (byte, r/o)
@ERDSK equ scb$base+51h ; BDOS Error Disk (byte,r/o)
@MEDIA equ scb$base+54h ; Set by BIOS to indicate
; open door (byte,r/w)
@BFLGS equ scb$base+57h ; BDOS Message Size Flag (byte,r/o)
@DATE equ scb$base+58h ; Date in Days Since 1 Jan 78
; (word, r/w)
@HOUR equ scb$base+5Ah ; Hour in BCD (byte, r/w)
@MIN equ scb$base+5Bh ; Minute in BCD (byte, r/w)
@SEC equ scb$base+5Ch ; Second in BCD (byte, r/w)
?ERJMP equ scb$base+5Fh ; BDOS Error Message Jump
; (word, r/w)
@MXTPA equ scb$base+62h ; Top of User TPA
; (address at 6,7)(word, r/o)
end

View File

@@ -0,0 +1,158 @@
PRTMSG = N
PAGWID = 4F
PAGLEN = 18
BACKSPC = N
RUBOUT = N
BOOTDRV = A
MEMTOP = FF
BNKSWT = N
COMBAS = 00
LERROR = Y
NUMSEGS = 03
MEMSEG00 = 00,80,00
MEMSEG01 = 00,C0,02
MEMSEG02 = 00,C0,03
MEMSEG03 = 00,C0,04
MEMSEG04 = 00,C0,05
MEMSEG05 = 00,C0,06
MEMSEG06 = 00,C0,07
MEMSEG07 = 00,C0,08
MEMSEG08 = 00,C0,09
MEMSEG09 = 00,C0,0A
MEMSEG0A = 00,C0,0B
MEMSEG0B = 00,C0,0C
MEMSEG0C = 00,C0,0D
MEMSEG0D = 00,C0,0E
MEMSEG0E = 00,C0,0F
MEMSEG0F = 00,C0,10
HASHDRVA = N
HASHDRVB = N
HASHDRVC = N
HASHDRVD = Y
HASHDRVE = Y
HASHDRVF = Y
HASHDRVG = Y
HASHDRVH = Y
HASHDRVI = Y
HASHDRVJ = Y
HASHDRVK = Y
HASHDRVL = Y
HASHDRVM = N
HASHDRVN = Y
HASHDRVO = Y
HASHDRVP = Y
ALTBNKSA = N
ALTBNKSB = N
ALTBNKSC = N
ALTBNKSD = N
ALTBNKSE = N
ALTBNKSF = N
ALTBNKSG = N
ALTBNKSH = N
ALTBNKSI = N
ALTBNKSJ = N
ALTBNKSK = N
ALTBNKSL = N
ALTBNKSM = N
ALTBNKSN = N
ALTBNKSO = N
ALTBNKSP = N
NDIRRECA = 01
NDIRRECB = 01
NDIRRECC = 01
NDIRRECD = 01
NDIRRECE = 01
NDIRRECF = 01
NDIRRECG = 01
NDIRRECH = 01
NDIRRECI = 01
NDIRRECJ = 01
NDIRRECK = 01
NDIRRECL = 01
NDIRRECM = 01
NDIRRECN = 01
NDIRRECO = 01
NDIRRECP = 01
NDTARECA = 01
NDTARECB = 01
NDTARECC = 01
NDTARECD = 01
NDTARECE = 01
NDTARECF = 01
NDTARECG = 01
NDTARECH = 01
NDTARECI = 01
NDTARECJ = 01
NDTARECK = 01
NDTARECL = 01
NDTARECM = 01
NDTARECN = 01
NDTARECO = 01
NDTARECP = 01
ODIRDRVA = A
ODIRDRVB = A
ODIRDRVC = A
ODIRDRVD = A
ODIRDRVE = A
ODIRDRVF = A
ODIRDRVG = A
ODIRDRVH = A
ODIRDRVI = A
ODIRDRVJ = A
ODIRDRVK = A
ODIRDRVL = A
ODIRDRVM = A
ODIRDRVN = A
ODIRDRVO = A
ODIRDRVP = A
ODTADRVA = A
ODTADRVB = A
ODTADRVC = A
ODTADRVD = A
ODTADRVE = A
ODTADRVF = A
ODTADRVG = A
ODTADRVH = A
ODTADRVI = A
ODTADRVJ = A
ODTADRVK = A
ODTADRVL = A
ODTADRVM = A
ODTADRVN = A
ODTADRVO = A
ODTADRVP = A
OVLYDIRA = Y
OVLYDIRB = Y
OVLYDIRC = Y
OVLYDIRD = Y
OVLYDIRE = Y
OVLYDIRF = Y
OVLYDIRG = Y
OVLYDIRH = Y
OVLYDIRI = Y
OVLYDIRJ = Y
OVLYDIRK = Y
OVLYDIRL = Y
OVLYDIRM = Y
OVLYDIRN = Y
OVLYDIRO = Y
OVLYDIRP = Y
OVLYDTAA = Y
OVLYDTAB = Y
OVLYDTAC = Y
OVLYDTAD = Y
OVLYDTAE = Y
OVLYDTAF = Y
OVLYDTAG = Y
OVLYDTAH = Y
OVLYDTAI = Y
OVLYDTAJ = Y
OVLYDTAK = Y
OVLYDTAL = Y
OVLYDTAM = Y
OVLYDTAN = Y
OVLYDTAO = Y
OVLYDTAP = Y
CRDATAF = N
DBLALV = N


View File

@@ -0,0 +1,3 @@
true equ -1
false equ not true
banked equ false

View File

@@ -0,0 +1,82 @@
;**************************************************************************
;* CP/M 3 BIOS for Z80em86 Z80 CPU emulator *
;* *
;* Interfacing Functions for CP/M 3 *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;**************************************************************************
;
; ChangeLog (most recent entries are at top)
; ------------------------------------------
; v1.0.0 - 16 February 2009, S.J.Kay
; - Prepare for public release.
;
; v1.00 - 26 April 1995, S.J.Kay
; - Undocumented changes.
;
; v0.00 - 1992, S.J.Kay
; - Initial creation date.
kbd1in equ 000h ;keyboard #1 initialize
kbd1st equ 001h ;keyboard #1 status
kbd1ip equ 002h ;keyboard #1 input
;
kbd2in equ 010h ;keyboard #2 (STDIN) initialize
kbd2st equ 011h ;keyboard #2 (STDIN) status
kbd2ip equ 012h ;keyboard #2 (STDIN) input
;
crt1in equ 020h ;CRT #1 initialize
crt1st equ 021h ;CRT #1 status
crt1op equ 022h ;CRT #1 output
;
crt2in equ 030h ;CRT #2 (STDOUT) initialize
crt2st equ 031h ;CRT #2 (STDOUT) status
crt2op equ 032h ;CRT #2 (STDOUT) output
;
lptini equ 040h ;CEN initialize
lptsta equ 041h ;CEN status
lptout equ 042h ;CEN output
;
comini equ 050h ;COM initialize
comist equ 051h ;COM input status
cominp equ 052h ;COM input
comost equ 053h ;COM output status
comout equ 054h ;COM output
;
gettme equ 060h ;get time from system clock
settme equ 061h ;set time in system clock
getdte equ 062h ;get date from system clock
setdte equ 063h ;set date in system clock
;
rdflop equ 080h ;read floppy disk sector
wrflop equ 081h ;write floppy disk sector
rdhard equ 082h ;read HDD file disk sector
wrhard equ 083h ;write HDD file disk sector
gtboot equ 084h ;get boot drive
gthard equ 085h ;get HDD file drive
flhard equ 086h ;flush HDD file data
;
blkcnt equ 090h ;return count of blocks available
blkget equ 091h ;get 128 bytes from storage
blkput equ 092h ;put 128 bytes into storage
blkfil equ 093h ;fill 128 bytes in storage with value
;
gtzseg equ 0a0h ;return current Z80 memory map segment
intfnc equ 0a1h ;interface to 8086 software interrupts
;
bnkuse equ 0f0h ;selects banked system and bank size
bnksel equ 0f1h ;select bank #0, #1
bnkmve equ 0f2h ;memory move (use bnkdta 1st if interbank)
bnkdta equ 0f3h ;select banks for interbank memory move
bnkdma equ 0f4h ;sets bank for DMA access
;
prmsta equ 0f8h ;return status of any Z80 Emulator parameters
prmget equ 0f9h ;return Z80 Emulator parameters address
vidsta equ 0fah ;return status of video output
vidset equ 0fbh ;turn video system on/off
usrbyt equ 0fch ;get/set user byte in emulator
failed equ 0fdh ;boot strap failure
rstz80 equ 0feh ;reset the Z80 emulator
extemu equ 0ffh ;exit the Z80 Emulator
;
; end of file

View File

@@ -0,0 +1,720 @@
title 'Root module of relocatable BIOS for CP/M 3.0'
;
; code differs from cp/m 3 book marked with ^^^
;
; ^^^0 : book has, mvi a,jmp
; ^^^1 : book has, dcr b
; ^^^2 : book has not, mvi a,1 | sta @cnt
; ^^^3 : book has not, mov a,c
;
maclib ASMTYPE.LIB
.z80
;
; version 1.0 15 Sept 82
;
;
; Copyright (C), 1982
; Digital Research, Inc
; P.O. Box 579
; Pacific Grove, CA 93950
;
; This is the invariant portion of the modular BIOS and is
; distributed as source for informational purposes only.
; All desired modifications should be performed by
; adding or changing externally defined modules.
; this allows producing "standard" I/O modules that
; can be combined to support a particular system
; configuration.
;
cr equ 13
lf equ 10
bell equ 7
ctlq equ 'Q'-'@'
ctls equ 'S'-'@'
ccp equ 0100h ;console command processor gets loaded into the tpa
;
cseg ; gencpm puts cseg stuff in common memory
;
; variables in system data page
extrn @covec,@civec,@aovec ; I/O re-direction vectors
extrn @aivec,@lovec
extrn @mxtpa ; addr of system entry point
extrn @bnkbf ; 128 byte scratch buffer
;
; initialization
extrn ?init ; general initialization and signon
extrn ?ldccp,?rlccp ; load & reload CCP for BOOT & WBOOT
;
; user defined character I/O routines
extrn ?ci,?co,?cist,?cost ; each take device in <B>
extrn ?cinit ; (re)initialize device in <C>
extrn @ctbl ; physical character device table
;
; disk communication data items
extrn @dtbl ; table of pointers to XDPHs
public @adrv,@rdrv,@trk,@sect ; parameters for disk I/O
public @dma,@dbnk,@cnt ; '' '' '' ''
;
; memory control
public @cbnk ; current bank
extrn ?xmove,?move ; select move bank, and block move
extrn ?bank ; select CPU bank
;
; clock support
extrn ?time ; signal time operation
;
; general utility routines
public ?pmsg,?pdec ; print message, print number from 0 to 65535
public ?pderr ; print BIOS disk error message header
;
maclib MODEBAUD.LIB ; define mode bits
;
; external names for BIOS entry points
public ?boot,?wboot,?const,?conin,?cono,?list,?auxo,?auxi
public ?home,?sldsk,?sttrk,?stsec,?stdma,?read,?write
public ?lists,?sctrn
public ?conos,?auxis,?auxos,?dvtbl,?devin,?drtbl
public ?mltio,?flush,?mov,?tim,?bnksl,?stbnk,?xmov
;
;
; BIOS jump vector.
; all BIOS routines are invoked by calling these
; entry points.
;
?boot: jp boot ; initial entry on cold start
?wboot: jp wboot ; reentry on program exit, warm start
?const: jp const ; return console input status
?conin: jp conin ; return console input character
?cono: jp conout ; send console output character
?list: jp list ; send list output character
?auxo: jp auxout ; send auxilliary output character
?auxi: jp auxin ; return auxilliary input character
?home: jp home ; set disks to logical home
?sldsk: jp seldsk ; select disk drive, return disk parameter info
?sttrk: jp settrk ; set disk track
?stsec: jp setsec ; set disk sector
?stdma: jp setdma ; set disk I/O memory address
?read: jp read ; read physical block(s)
?write: jp write ; write physical block(s)
?lists: jp listst ; return list device status
?sctrn: jp sectrn ; translate logical to physical sector
?conos: jp conost ; return console output status
?auxis: jp auxist ; return aux input status
?auxos: jp auxost ; return aux output status
?dvtbl: jp devtbl ; return address of device def table
?devin: jp ?cinit ; change baud rate of device
?drtbl: jp getdrv ; return address of disk drive table
?mltio: jp multio ; set multiple record count for disk I/O
?flush: jp flush ; flush BIOS maintained disk caching
?mov: jp ?move ; block move memory to memory
?tim: jp ?time ; signal time and date operation
?bnksl: jp bnksel ; set bank for code execution and default DMA
?stbnk: jp setbnk ; select different bank for disk I/O DMA operations.
?xmov: jp ?xmove ; set source and destination banks for one operation
jp 0 ; reserved for system implementor
jp 0 ; reserved for future expansion
jp 0 ; reserved for future expansion
;
;
; BOOT
; Initial entry point for system startup.
;
dseg ; this part can be banked
;
boot:
ld sp,boot$stack
ld c,15 ; initialize all 16 character devices
c$init$loop:
push bc
call ?cinit
pop bc
dec c
jp p,c$init$loop
call ?init ; perform any additional system init.
; and print signon message
ld bc,16*256+0
ld hl,@dtbl ; init all 16 logical disk drives
d$init$loop:
push bc ; save remaining count and abs drive
ld e,(hl)
inc hl
ld d,(hl)
inc hl ; grab @drv entry
ld a,e
or d
jp z,d$init$next ; if null, no drive
push hl ; save @drv pointer
ex de,hl ; XDPH address in <HL>
dec hl
dec hl
ld a,(hl)
ld (@rdrv),a ; get relative drive code
ld a,c
ld (@adrv),a ; get absolute drive code
dec hl ; point to init pointer
ld d,(hl)
dec hl
ld e,(hl) ; get init pointer
ex de,hl
call ipchl ; call init routine
pop hl ; recover @drv pointer
d$init$next:
pop bc ; recover counter and drive #
inc c
dec b
jp nz,d$init$loop ; and loop for each drive
jp boot$1
;
cseg ; following in resident memory
;
boot$1:
call set$jumps
call ?ldccp ; fetch ccp for first time
jp ccp
;
; WBOOT
; Entry for system restarts.
;
wboot: ld sp,boot$stack
call set$jumps ; initialize page zero
call ?rlccp ; reload ccp
jp ccp ; then reset jmp vectors and exit to ccp
set$jumps:
if banked
ld a,1
call ?bnksl
endif
ld a,0c3h ;^^^0
ld (0000h),a
ld (0005h),a ; set up jumps in page zero
ld hl,?wboot
ld (0001h),hl ; BIOS warm start entry
ld hl,(@mxtpa)
ld (0006h),hl ; BDOS system call entry
ret
;
ds 64
;
boot$stack equ $
;
; DEVTBL
; Return address of character device table.
;
devtbl:
ld hl,@ctbl
ret
;
; GETDRV
; Return address of drive table.
;
getdrv:
ld hl,@dtbl
ret
;
; CONOUT
; Console Output. Send character in <C>
; to all selected devices
;
conout:
ld hl,(@covec) ; fetch console output bit vector
jp out$scan
;
; AUXOUT
; Auxiliary Output. Send character in <C>
; to all selected devices
;
auxout:
ld hl,(@aovec) ; fetch aux output bit vector
jp out$scan
;
; LIST
; List output. Send character in <C>
; to all selected devices.
;
list:
ld hl,(@lovec) ; fetch list output bit vector
out$scan:
ld b,0 ; start with device 0
co$next:
add hl,hl ; shift out next bit
jp nc,not$out$device
push hl ; save the vector
push bc ; save the count and character
not$out$ready:
call coster
or a
jp z,not$out$ready
pop bc
push bc ; restore and resave the character and device
call ?co ; if device selected, print it
pop bc ; recover count and character
pop hl ; recover the rest of the vector
not$out$device:
inc b ; next device number
ld a,h
or l ; see if any devices left
jp nz,co$next ; and go find them...
ret
;
; CONOST
; Console Output Status. Return true if
; all selected console output devices
; are ready.
;
conost:
ld hl,(@covec) ; get console output bit vector
jp ost$scan
;
; AUXOST
; Auxiliary Output Status. Return true if
; all selected auxiliary output devices
; are ready.
;
auxost:
ld hl,(@aovec) ; get aux output bit vector
jp ost$scan
;
; LISTST
; List output status. Return true if
; all selected list output devices
; are ready.
;
listst:
ld hl,(@lovec) ; get list output bit vector
ost$scan:
ld b,0 ; start with device 0
cos$next:
add hl,hl ; check next bit
push hl ; save the vector
push bc ; save the count
ld a,0ffh ; assume device ready
call c,coster ; check status for this device
pop bc ; recover count
pop hl ; recover bit vector
or a ; see if device ready
ret z ; if any not ready, return false
inc b ; ^^^1 next device number
ld a,h
or l ; see if any more selected devices
jp nz,cos$next
or 0ffh ; all selected were ready, return true
ret
;
coster: ; check for output device ready, including optional
; xon/xoff support
;
ld l,b
ld h,0 ; make device code 16 bits
push hl ; save it in stack
add hl,hl
add hl,hl
add hl,hl ; create offset into device characteristics tbl
ld de,@ctbl+6
add hl,de ; make address of mode byte
ld a,(hl)
and mb$xonxoff
pop hl ; recover console number in <HL>
jp z,?cost ; not a xon device, go get output status direct
ld de,xofflist
add hl,de ; make pointer to proper xon/xoff flag
call cist1 ; see if this keyboard has character
ld a,(hl)
call nz,ci1 ; get flag or read key if any
cp ctlq
jp nz,not$q ; if its a ctl-Q,
ld a,0ffh ; set the flag ready
not$q:
cp ctls
jp nz,not$s ; if its a ctl-S,
ld a,00h ; clear the flag
not$s:
ld (hl),a ; save the flag
call cost1 ; get the actual output status,
and (hl) ; and mask with ctl-q/ctl-s flag
ret ; return this as the status
;
cist1: ; get input status with <BC> and <HL> saved
push bc
push hl
call ?cist
pop hl
pop bc
or a
ret
;
cost1: ; get output status, saving <BC> & <HL>
push bc
push hl
call ?cost
pop hl
pop bc
or a
ret
;
ci1: ; get input, saving <BC> & <HL>
push bc
push hl
call ?ci
pop hl
pop bc
ret
;
; CONST
; Console Input Status. Return true if
; any selected console input device
; has an available character.
;
const:
ld hl,(@civec) ; get console input bit vector
jp ist$scan
;
; AUXIST
; Auxiliary Input Status. Return true if
; any selected auxiliary input device
; has an available character.
;
auxist:
ld hl,(@aivec) ; get aux input bit vector
ist$scan:
ld b,0 ; start with device 0
cis$next:
add hl,hl ; check next bit
ld a,0 ; assume device not ready
call c,cist1 ; check status for this device
or a
ret nz ; if any ready, return true
inc b ; next device number
ld a,h
or l ; see if any more selected devices
jp nz,cis$next
xor a ; all selected were not ready, return false
ret
; CONIN
; Console Input. Return character from first
; ready console input device.
;
conin:
ld hl,(@civec)
jp in$scan
;
; AUXIN
; Auxiliary Input. Return character from first
; ready auxiliary input device.
;
auxin:
ld hl,(@aivec)
in$scan:
push hl ; save bit vector
ld b,0
ci$next:
add hl,hl ; shift out next bit
ld a,0 ; insure zero a (nonexistant device not ready).
call c,cist1 ; see if the device has a character
or a
jp nz,ci$rdy ; this device has a character
inc b ; else, next device
ld a,h
or l ; see if any more devices
jp nz,ci$next ; go look at them
pop hl ; recover bit vector
jp in$scan ; loop till we find a character
ci$rdy: pop hl ; discard extra stack
jp ?ci
;
; Utility Subroutines
;
ipchl: ; vectored call point
jp (hl)
;
?pmsg: ; print message @<HL> up to a null
; saves <BC> & <DE>
;
push bc
push de
pmsg$loop:
ld a,(hl)
or a
jp z,pmsg$exit
ld c,a
push hl
call ?cono
pop hl
inc hl
jp pmsg$loop
pmsg$exit:
pop de
pop bc
ret
;
?pdec: ; print binary number 0-65535 from <HL>
;
ld bc,table10
ld de,-10000
next:
ld a,'0'-1
pdecl:
push hl
inc a
add hl,de
jp nc,stoploop
inc sp
inc sp
jp pdecl
stoploop:
push de
push bc
ld c,a
call ?cono
pop bc
pop de
nextdigit:
pop hl
ld a,(bc)
ld e,a
inc bc
ld a,(bc)
ld d,a
inc bc
ld a,e
or d
jp nz,next
ret
;
table10:
dw -1000,-100,-10,-1,0
;
?pderr:
ld hl,drive$msg
call ?pmsg ; error header
ld a,(@adrv)
add a,'A'
ld c,a
call ?cono ; drive code
ld hl,track$msg
call ?pmsg ; track header
ld hl,(@trk)
call ?pdec ; track number
ld hl,sector$msg
call ?pmsg ; sector header
ld hl,(@sect)
call ?pdec ; sector number
ret
;
; BNKSEL
; Bank Select. Select CPU bank for further execution.
;
bnksel:
ld (@cbnk),a ; remember current bank
jp ?bank ; and go exit through users
; physical bank select routine
;
xofflist:
db -1,-1,-1,-1,-1,-1,-1,-1 ; ctl-s clears to zero
db -1,-1,-1,-1,-1,-1,-1,-1
;
dseg ; following resides in banked memory
;
; Disk I/O interface routines
;
; SELDSK
; Select Disk Drive. Drive code in <C>.
; Invoke login procedure for drive
; if this is first select. Return
; address of disk parameter header
; in <HL>
;
seldsk: ld a,1 ;^^^2
ld (@cnt),a ;^^^2 clear multi counter
ld a,c
ld (@adrv),a ; save drive select code
ld l,c
ld h,0
add hl,hl ; create index from drive code
ld bc,@dtbl
add hl,bc ; get pointer to dispatch table
ld a,(hl)
inc hl
ld h,(hl)
ld l,a ; point at disk descriptor
or h
ret z ; if no entry in table, no disk
ld a,e
and 1
jp nz,not$first$select ; examine login bit
push hl
ex de,hl ; put pointer in stack & <DE>
ld hl,-2
add hl,de
ld a,(hl)
ld (@rdrv),a ; get relative drive
ld hl,-6
add hl,de ; find login addr
ld a,(hl)
inc hl
ld h,(hl)
ld l,a ; get address of login routine
call ipchl ; call login
pop hl ; recover dph pointer
not$first$select:
ret
;
; HOME
; Home selected drive. Treated as settrk(0).
;
home:
ld bc,0 ; same as set track zero
;
; SETTRK
; Set Track. Saves track address from <BC>
; in @trk for further operations.
;
settrk:
ld l,c
ld h,b
ld (@trk),hl
ret
;
; SETSEC
; Set Sector. Saves sector number from <BC>
; in @sect for further operations.
;
setsec:
ld l,c
ld h,b
ld (@sect),hl
ret
;
; SETDMA
; Set Disk Memory Address. Saves DMA address
; from <BC> in @DMA and sets @dbnk to @cbnk
; so that further disk operations take place
; in current bank.
;
setdma:
ld l,c
ld h,b
ld (@dma),hl
ld a,(@cbnk) ; default DMA bank is current bank
; fall through to set DMA bank
;
; SETBNK
; Set Disk Memory Bank. Saves bank number
; in @dbnk for future disk data
; transfers.
;
setbnk:
ld (@dbnk),a
ret
;
; SECTRN
; Sector Translate. Indexes skew table in <DE>
; with sector in <BC>. Returns physical sector
; in <HL>. If no skew table (<DE>=0) then
; returns physical=logical.
;
sectrn:
ld l,c
ld h,b
ld a,d
or e
ret z
ex de,hl
add hl,bc
ld l,(hl)
ld h,0
ret
;
; READ
; Read physical record from currently selected drive.
; Finds address of proper read routine from
; extended disk parameter header (XDPH).
;
read:
ld hl,(@adrv)
ld h,0
add hl,hl ; get drive code and double it
ld de,@dtbl
add hl,de ; make address of table entry
ld a,(hl)
inc hl
ld h,(hl)
ld l,a ; fetch table entry
push hl ; save address of table
ld de,-8
add hl,de ; point to read routine address
jp rw$common ; use common code
;
; WRITE
; Write physical sector from currently selected drive.
; Finds address of proper write routine from
; extended disk parameter header (XDPH).
;
write:
ld hl,(@adrv)
ld h,0
add hl,hl ; get drive code and double it
ld de,@dtbl
add hl,de ; make address of table entry
ld a,(hl)
inc hl
ld h,(hl)
ld l,a ; fetch table entry
push hl ; save address of table
ld de,-10
add hl,de ; point to write routine address
rw$common:
ld a,(hl)
inc hl
ld h,(hl)
ld l,a ; get address of routine
pop de ; recover address of table
dec de
dec de ; point to relative drive
ld a,(de)
ld (@rdrv),a ; get relative drive code and post it
inc de
inc de ; point to dph again
jp (hl) ; leap to driver
;
; MULTIO
; Set multiple sector count. Saves passed count in
; @CNT
;
multio:
ld a,c ;^^^3 passed in c
ld (@cnt),a
ret
;
; FLUSH
; BIOS deblocking buffer flush. Not implemented.
;
flush:
xor a
ret ; return with no error
;
; error message components
;
drive$msg:
db cr,lf,bell,'BIOS error on ',0
track$msg:
db ': T-',0
sector$msg:
db ', S-',0
;
; disk communication data items
;
@adrv: ds 1 ; currently selected disk drive
@rdrv: ds 1 ; controller relative disk drive
@trk: ds 2 ; current track number
@sect: ds 2 ; current sector number
@dma: ds 2 ; current DMA address
@cnt: db 0 ; record count for multisector transfer
@dbnk: db 0 ; bank for DMA operations
;
cseg ; common memory
;
@cbnk: db 0 ; bank for processor operations
;
end