home *** CD-ROM | disk | FTP | other *** search
- ; This creates a SYSGEN for the Kaypro 2/4 floppy disks.
- ; If no SYSGEN is supplied with your system try modifying this.
- ; Be sure to change the identification sign-on at the end.
- ;
- ; If modifying for hard disks, note 1 byte used for trk/sector sets.
- ;
- ; 87/05/02 slaved bad drive message to maxdv. cbf
- ;
- boot equ 0
- @bios equ boot+1
- @cin equ 1
- @cout equ 2
- cpm equ 5
- lf equ 0Ah
- cr equ 0Dh
- yes equ -1
- no equ not yes
-
- @fopn equ 15
- @rdsq equ 20
- @stdma equ 26
-
- tfcb equ 5Ch
- tfcbn equ 5Dh
- tfcbr equ 7Ch
- defdma equ 080h
- ;
- ; -------
- ; Modify the following equates for other systems.
- ;
- bootsz equ 1; number of boot loader sectors
- ; (0 for Osborne I ? )
- image equ 0980h - 128 * bootsz; start of memory image
- ;
- ; Applies to all except last system track used.
- tk0bgn equ 0; 1st sector to use on trk 0
- spertk equ 40; sectors / physical trk, use on trk 0
- ;
- ; Kaypro special. Puts rest of system in allocated, unused
- ; bk 1 (dsdd), or bks 2,3 (ssdd). Most others use tk0bgn/spertk here
- ; NOTE not for hard disks, floppies only!!.
- ltkbgn equ 16; 1st sector to use on last trk
- ltksiz equ 16; # sectors to use on last trk
-
- systks equ 2; Kaypro uses 0 and part of 1
- maxdv equ 3; allowed for put/get system 1=A etc.
- ; -------
-
- begin: lxi sp,stktop
- lxi h,signon
- call tstr
- lda tfcbn
- cpi ' '
- jz getsor; no file specified
- lxi d,tfcb
- call fopen
- inr a
- lxi h,nosorf
- jz exitm; not found
- ; " "
- fload: xra a; Load from a file
- sta tfcbr; start at record 0
- mvi b,(image - 100h) / 128; skip 1st 2k
- fload1: push b
- lxi d,tfcb
- lxi h,defdma
- call frdseq; into default dma & discard
- pop b
- ora a
- lxi h,short
- jnz exitm; can't skip
- dcr b
- jnz fload1
- lxi h,image-128; file pos'nd
- fload2: ora h; a was zero
- jm putsys; big input, over 32k!! Truncate
- lxi d,128
- dad d
- lxi d,tfcb
- call frdseq
- ora a
- jz fload2; not eof
- mov a,h
- lxi h,short
- cpi (image + 1700h) shr 8
- jc exitm; must have at least 128 bytes of bios
- jmp putsys
-
- notsor: call badrv; message and try again
- ; " "
- getsor: lxi h,sormsg; Optionally get sys tracks
- call tstrc
- call cinup
- cpi cr
- jz putsys; cr skips get
- sta sordrv
- sui 'A'
- cpi maxdv
- jnc notsor; invalid drive
- call bsetdv
- call crlf
- lxi h,sormnt
- call tstr
- call cinup
- cpi cr
- jnz abort; non-cr aborts everything
- xra a
- ; " "
- ; read if a = 0, else write
- rwsys: sta wrtflg
- call crlf
- call sysio
- lxi h,dunmsg
- call tstr
- jmp putsys
-
- notdst: call badrv; message and try again
- ; " "
- putsys: lxi h,dstmsg; Optionally put sys tracks
- call tstrc
- call cinup
- cpi cr
- jz exit; cr aborts, leaves any image
- sta dstdrv
- sui 'A'
- cpi maxdv
- jnc notdst; invalid drive
- call bsetdv
- lxi h,dstmnt
- call tstrc
- call cinup
- cpi cr
- jnz abort; non-cr aborts everything
- mvi a,1
- jmp rwsys
-
- abort: lxi h,abortm
- ; " "
- exitm: call tstrc
- ; " "
- exit: mvi a,0
- call bsetdv; select drive a on bios
- jmp boot
-
- ; Subroutines
-
- ; console in and upshift
- ; a,f
- cinup: mvi a,@cin
- call dos
- cpi 'a'
- rc; not lower case
- cpi 'z'+1
- rnc; not lower case
- ani 5fh; upshift
- ret
-
- ; cr/lf to console
- ; a,f,e
- crlf: mvi a,cr
- call couta
- mvi a,lf
- ; " "
- ; (a) a to console
- ; a,f,e
- couta: mov e,a
- mvi a,@cout
- jmp dos
-
- badrv: lxi h,baddrv; message
- ; " "
- ; crlf then string hl^
- ; a,f,e,h,l
- tstrc: call crlf
- ; " "
- ; string hl^ to console
- ; a,f,e,h,l
- tstr: mov a,m; 0 terminated message
- ora a
- rz
- call couta
- inx h
- jmp tstr
-
- ; Bios calls. All regs modified
- ;
- ; set drive a
- bsetdv: mov c,a
- mvi e,18h
- ; " "
- xbios: mvi d,0; call entry #e/3
- lhld @bios
- dad d
- pchl
-
- bsetrk: mvi e,1bh
- jmp xbios
-
- bstsec: mvi e,1eh
- jmp xbios
-
- bstdma: mvi e,21h
- jmp xbios
-
- bread: mvi e,24h
- jmp xbios
-
- bwrite: mvi e,27h
- jmp xbios
-
- ; CPM DOS calls
- ;
- ; read next record file de^ into hl^
- ; a,f
- frdseq: xchg
- mvi a,@stdma
- call dos
- xchg
- mvi a,@rdsq
- ; " "
- ; dos call (a), saving regs
- ; a,f
- dos: push h
- push d
- push b
- mov c,a
- call cpm
- pop b
- pop d
- pop h
- ret
-
- ; open file de^
- ; a,f
- fopen: mvi a,@fopn
- jmp dos
-
- ; The actual work - get/put system
- ; a,f,b,c,d,e,h,l
- sysio: lxi h,image
- shld xfradr
- mvi a,0; 1st system track always 0
- sta track
- ; " "
- ; Repeat this code for each full track except the last.
- rept systks - 1
- mvi a,tk0bgn
- sta sector
- mvi a,spertk
- sta nsects
- call trkio; do first track
- endm
- ; " "
- ; following used for LAST system track.
- if systks GT 1
- mvi a,systks-1
- sta track
- mvi a,ltkbgn; Magic for Kaypro
- sta sector; setup for last track
- mvi a,ltksiz; " "
- sta nsects; now do last track
- call trkio
- endif
- ret
- ;
- trkio: lda track; rd/write 1 track area
- mov c,a
- inr a
- sta track; advance for next time
- call bsetrk
- trkio1: lda sector
- mov c,a
- inr a
- sta sector
- call bstsec
- lhld xfradr
- push h
- lxi d,128
- dad d
- shld xfradr
- pop b
- call bstdma; input value
- xra a
- sta errors
- trkio2: lda errors
- cpi 1
- jc trkio3
- lxi h,ioerr
- call tstr
- call cinup
- cpi cr
- jnz exit
- call crlf
- jmp trkio6
-
- trkio3: inr a
- sta errors
- lda wrtflg
- ora a
- jz trkio4
- call bwrite
- jmp trkio5
-
- trkio4: call bread
- trkio5: ora a
- jnz trkio2
- trkio6: lxi h,nsects
- dcr m
- jnz trkio1
- ret
-
- signon: db 'SYSGEN [fn.ft] (for Kaypro only)',0
- sormsg: db 'Source drive ( <ret> to skip) :',0
- sormnt: db 'Source on '
- sordrv: db 0,', then type return ',0
- dstmsg: db 'Destination drive ( <ret> reboots) :',0
- dstmnt: db 'Destination on '
- dstdrv: db 0,', then type return ',0
- ioerr: db 'PERMANENT ERROR, <ret> to ignore',0
- dunmsg: db 'Function complete',0
- baddrv: db 'Invalid drive (A thru '
- db maxdv+'@'
- db ')',0
- nosorf: db 'Source file not found',0
- short: db 'Source file too short',0
- abortm: db 'Aborted',0
-
- track: ds 1
- sector: ds 1
- nsects: ds 1; To read
- wrtflg: ds 1; zero to read, else write
- xfradr: ds 2
- errors: ds 1
- ds 64
- stktop:
- end
- ┌8