From 5e8e5424dca4171fa7aa45b4207cc331bf798588 Mon Sep 17 00:00:00 2001 From: Wayne Warthen Date: Wed, 20 May 2020 21:20:24 -0700 Subject: [PATCH] Cleanup --- Source/CPM3/Build.cmd | 5 +- Source/CPM3/Makefile | 8 +-- Source/CPM3/biosldr.z80 | 103 ++++++++++++++--------------------- Source/CPM3/boot.z80 | 37 +++++++------ Source/CPM3/loader.asm | 5 +- Source/CPM3/util.z80 | 115 +++++++++++++++++++++------------------- Source/HBIOS/romldr.asm | 6 ++- Source/ZPM3/Build.cmd | 5 +- Source/ZPM3/Clean.cmd | 1 + Source/ZPM3/Makefile | 13 +++-- Source/ZPM3/loader.asm | 5 +- 11 files changed, 149 insertions(+), 154 deletions(-) diff --git a/Source/CPM3/Build.cmd b/Source/CPM3/Build.cmd index 557b6c53..aa0c59c9 100644 --- a/Source/CPM3/Build.cmd +++ b/Source/CPM3/Build.cmd @@ -17,15 +17,16 @@ echo. echo *** CPM Loader *** echo. zx RMAC -CPMLDR +zx Z80ASM -UTIL/MF copy optdsk.lib ldropts.lib zx Z80ASM -BIOSLDR/MF move /Y biosldr.rel biosldrd.rel -zx LINK -CPMLDRD[L100]=CPMLDR,BIOSLDRD +zx LINK -CPMLDRD[L100]=CPMLDR,BIOSLDRD,UTIL move /Y cpmldrd.com cpmldr.bin copy optcmd.lib ldropts.lib zx Z80ASM -BIOSLDR/MF move /Y biosldr.rel biosldrc.rel -zx LINK -CPMLDRC[L100]=CPMLDR,BIOSLDRC +zx LINK -CPMLDRC[L100]=CPMLDR,BIOSLDRC,UTIL move /Y cpmldrc.com cpmldr.com rem pause diff --git a/Source/CPM3/Makefile b/Source/CPM3/Makefile index a75b03b3..d64e7e72 100644 --- a/Source/CPM3/Makefile +++ b/Source/CPM3/Makefile @@ -60,12 +60,12 @@ zpmbios3: cp optzpm.lib options.lib make OBJECTS=zpmbios3.spr DEST= -cpmldr.bin: biosldrd.rel cpmldr.rel - $(ZXCC) $(TOOLS)/cpm/bin/LINK -CPMLDRD[L100]=CPMLDR,BIOSLDRD +cpmldr.bin: biosldrd.rel cpmldr.rel util.rel + $(ZXCC) $(TOOLS)/cpm/bin/LINK -CPMLDRD[L100]=CPMLDR,BIOSLDRD,UTIL mv cpmldrd.com cpmldr.bin -cpmldr.com: biosldrc.rel cpmldr.rel - $(ZXCC) $(TOOLS)/cpm/bin/LINK -CPMLDRC[L100]=CPMLDR,BIOSLDRC +cpmldr.com: biosldrc.rel cpmldr.rel util.rel + $(ZXCC) $(TOOLS)/cpm/bin/LINK -CPMLDRC[L100]=CPMLDR,BIOSLDRC,UTIL mv cpmldrc.com cpmldr.com biosldrc.rel: biosldr.z80 optcmd.lib diff --git a/Source/CPM3/biosldr.z80 b/Source/CPM3/biosldr.z80 index ed478b2d..a414cf58 100644 --- a/Source/CPM3/biosldr.z80 +++ b/Source/CPM3/biosldr.z80 @@ -4,6 +4,11 @@ maclib cpm3.lib cseg + + extrn phex16, phex8 + extrn cin, cout + extrn crlf, crlf2 + ; BIOS Jump vector. @@ -100,7 +105,7 @@ boot1: jr c,selerr ; loop if below 0 entered cp 10 ; check for over 9 jr nc,selerr ; loop if over 9 - ld de,crlf ; linefeed + ld de,msgcrlf ; linefeed call writestr ; ... to console jr boot2 ; boot w/ unit & slice @@ -296,6 +301,12 @@ setsec: ld (sect),bc ret setdma: + ;push hl + ;push bc + ;pop hl + ;call crlf + ;call phex16 + ;pop hl ld (dma),bc ret @@ -318,32 +329,6 @@ read: rl d ; carry bit (head) into d jr read3 ; do the disk i/o -; ; *** Simplify this to get rid of slice!!! *** -; ld b,1 ; assume it is floppy, 1 head bit -; ld c,01h ; 1 bit head mask -; push bc ; save bc -; ld a,(slice) ; get slice -; ld e,a ; slice to E -; ld h,65 ; number of tracks per slice -; call mult8 ; HL now has track offset for slice -; pop bc ; recover bc -; push hl ; save track offset for now -; ld hl,(trk) ; get track value -; ld a,l ; lsb of track to a -; and c ; apply mask -; ld d,a ; save in d -;read1: -; srl h ; shift one bit out -; rr l ; ... of hl -; djnz read1 ; do all bits -; ld a,(sect) ; get sector -; ld e,a ; stuff it in e -; ex de,hl ; DE=track, HL=head/sect -; ex (sp),hl ; save head/sect, HL = offset -; add hl,de ; HL has final track value -; pop de ; recover head/sect to de -; jr read3 - ; LBA I/O read2: ld hl,(trk) ; get track @@ -449,20 +434,20 @@ xmove: ld a,9DH halt -cin: - ; Input character from console via HBIOS - ld c,080H ; console unit to C - ld b,00H ; HBIOS func: input char - call 0FFF0H ; HBIOS reads character - ld a,e ; To A for return - ret ; done - -cout: - ; Output character to console via HBIOS - ld e,a ; output char to E - ld c,080H ; console unit to C - ld b,01H ; HBIOS func: output char - jp 0FFF0H ; output & return +;cin: +; ; Input character from console via HBIOS +; ld c,080H ; console unit to C +; ld b,00H ; HBIOS func: input char +; call 0FFF0H ; HBIOS reads character +; ld a,e ; To A for return +; ret ; done + +;cout: +; ; Output character to console via HBIOS +; ld e,a ; output char to E +; ld c,080H ; console unit to C +; ld b,01H ; HBIOS func: output char +; jp 0FFF0H ; output & return writestr: push af @@ -479,19 +464,6 @@ writestr2: pop af ret -mult8: - ; Multiply: H := H * E - ld d,0 - ld l,d - ld b,8 -mult8_loop: - add hl,hl - jr nc,mult8_noadd - add hl,de -mult8_noadd: - djnz mult8_loop - ret - rl32: ; Left shift DE:HL by B bits (B > 0) or a ; clear carry @@ -535,7 +507,7 @@ str_err_api db "HBIOS API failure","$" msgunit db 13,10,13,10,'Boot CP/M 3 from Disk Unit: $' msgslc db ' Slice: $' msginv db 13,10,13,10,'*** Invalid Selection ***$' -crlf db 13,10,'$' +msgcrlf db 13,10,'$' dpb$start: dpb$rom: ; 384K ROM Drive @@ -718,7 +690,16 @@ medid ds 1 ; media id lba ds 4 ; current lba sps ds 2 ; sectors per slice -;csvbuf ds 128 ; length (CSV) = ((DRM+1)/4) + ds 64 +stack equ $ +stksav ds 2 + +csvbufs equ 256 +alvbufs equ 512 +dirbufs equ 512 +dtabufs equ 512 + +;csvbuf ds 256 ; length (CSV) = ((DRM+1)/4) ;alvbuf ds 512 ; length (ALV) = ((DSM+1)/4) ;dirbuf ds 512 ; sector buffer ;dtabuf ds 512 ; sector buffer @@ -729,12 +710,8 @@ sps ds 2 ; sectors per slice ; in upper memory actually helps quite a bit. csvbuf equ 8000h -alvbuf equ csvbuf + 128 -dirbuf equ alvbuf + 512 -dtabuf equ dirbuf + 512 - - ds 64 -stack equ $ -stksav ds 2 +alvbuf equ csvbuf + csvbufs +dirbuf equ alvbuf + alvbufs +dtabuf equ dirbuf + dirbufs end diff --git a/Source/CPM3/boot.z80 b/Source/CPM3/boot.z80 index 4f55b627..ae0bdd7b 100644 --- a/Source/CPM3/boot.z80 +++ b/Source/CPM3/boot.z80 @@ -14,9 +14,12 @@ extrn @date,@hour,@min,@sec extrn @srch1 extrn @hbbio - extrn addhla, bcd2bin, bin2bcd - extrn cout, phex8, phex16, crlf, crlf2 - + extrn addhla + ;extrn phex16, phex8 + ;extrn cin, cout + ;extrn crlf, crlf2 + extrn bcd2bin, bin2bcd + include c:ver.lib bdos equ 5 @@ -381,18 +384,18 @@ fill: ?ldccp: ; Force CCP to use system boot drive as initial default - ld a,(@sysdr) ; get system boot drive - ld (@ccpdr),a ; set CCP current drive + ;ld a,(@sysdr) ; get system boot drive + ;ld (@ccpdr),a ; set CCP current drive ; First time, load the CCP.COM file into TPA - ld a,(@sysdr) ; get system boot drive - ;ld (4),a ; save in page zero??? - inc a ; drive + 1 for FCB - ld (ccp$fcb),a ; stuff into FCB - add 'A' - 1 ; drive letter - ld (ccp$msg$drv),a ; save for load msg - xor a - ld (ccp$fcb+15),a + ;ld a,(@sysdr) ; get system boot drive + ;;ld (4),a ; save in page zero??? + ;inc a ; drive + 1 for FCB + ;ld (ccp$fcb),a ; stuff into FCB + ;add 'A' - 1 ; drive letter + ;ld (ccp$msg$drv),a ; save for load msg + ;xor a + ;ld (ccp$fcb+15),a ld hl,0 ld (fcb$nr),hl ld de,ccp$fcb @@ -683,11 +686,11 @@ signon$msg db 13,10,'ZPM3' db 13,10,13,10,0 ccp$msg db 13,10,'BIOS Err on ' -ccp$msg$drv db '?' +ccp$msg$drv db 'A' db ': No ZCCP.COM file',0 -ccp$fcb db 0,'ZCCP ','COM',0,0,0,0 +ccp$fcb db 1,'ZCCP ','COM',0,0,0,0 ds 16 fcb$nr db 0,0,0 @@ -702,11 +705,11 @@ signon$msg db 13,10,'CP/M v3.0' db 13,10,13,10,0 ccp$msg db 13,10,'BIOS Err on ' -ccp$msg$drv db '?' +ccp$msg$drv db 'A' db ': No CCP.COM file',0 -ccp$fcb db 0,'CCP ','COM',0,0,0,0 +ccp$fcb db 1,'CCP ','COM',0,0,0,0 ds 16 fcb$nr db 0,0,0 diff --git a/Source/CPM3/loader.asm b/Source/CPM3/loader.asm index 42a8082d..974cd884 100644 --- a/Source/CPM3/loader.asm +++ b/Source/CPM3/loader.asm @@ -28,11 +28,12 @@ #INCLUDE "../ver.inc" ; ; BELOW, SYS_END MUST BE SET TO THE SIZE OF CPMLDR.BIN + SYS_LOC. IF -; THE SIZE OF CPMLDR.BIN CHANGES, SYS_END MUST BE UPDATED!!! +; THE SIZE OF CPMLDR.BIN CHANGES, SYS_SIZ MUST BE UPDATED!!! ; +SYS_SIZ .EQU $0F00 ; SIZE OF CPMLDR.BIN SYS_ENT .EQU $0100 ; SYSTEM (OS) ENTRY POINT ADDRESS SYS_LOC .EQU $0100 ; STARTING ADDRESS TO LOAD SYSTEM IMAGE -SYS_END .EQU $1580 + SYS_LOC ; ENDING ADDRESS OF SYSTEM IMAGE +SYS_END .EQU SYS_SIZ + SYS_LOC ; ENDING ADDRESS OF SYSTEM IMAGE ; SEC_SIZE .EQU 512 ; DISK SECTOR SIZE BLK_SIZE .EQU 128 ; OS BLOCK/RECORD SIZE diff --git a/Source/CPM3/util.z80 b/Source/CPM3/util.z80 index aa916129..7967727d 100644 --- a/Source/CPM3/util.z80 +++ b/Source/CPM3/util.z80 @@ -1,9 +1,10 @@ title 'Utility module for RomWBW' - maclib options.lib - - public addhla, bcd2bin, bin2bcd - public phex16, phex8, cout, crlf, crlf2 + public addhla + public phex16, phex8 + public cin, cout + public crlf, crlf2 + public bcd2bin, bin2bcd cseg @@ -14,45 +15,6 @@ addhla: inc h ret -bcd2bin: - ; convert A from packed bcd to binary - push bc - ld c,a - and 0F0h - srl a - ld b,a - srl a - srl a - add a,b - ld b,a - ld a,c - and 0Fh - add a,b - pop bc - ret - -bin2bcd: - ; convert A from binary to packed bcd - push bc - ld b,10 - ld c,-1 -bin2bcd1: - inc c - sub b - jr nc,bin2bcd1 - add a,b - ld b,a - ld a,c - add a,a - add a,a - add a,a - add a,a - or b - pop bc - ret - - if 1 -; ; Print the hex word value in HL ; phex16: @@ -104,16 +66,29 @@ hexconv: daa ret ; +; input character to A +; +cin: + push bc + push de + push hl + ld bc,0080h + rst 08 + ld a,e + pop hl + pop de + pop bc + ret +; ; output character from A ; cout: - ; save all incoming registers push af push bc push de push hl ld e,a - ld bc,0100h + ld bc,0180h rst 08 pop hl pop de @@ -134,16 +109,44 @@ crlf: call cout pop af ret - - else - -phex16: -phex8: -cout: -crlf2: -crlf: - halt - - endif +; +; Convert A from packed BCD to binary +; +bcd2bin: + push bc + ld c,a + and 0F0h + srl a + ld b,a + srl a + srl a + add a,b + ld b,a + ld a,c + and 0Fh + add a,b + pop bc + ret +; +; Convert A from binary to packed BCD +; +bin2bcd: + push bc + ld b,10 + ld c,-1 +bin2bcd1: + inc c + sub b + jr nc,bin2bcd1 + add a,b + ld b,a + ld a,c + add a,a + add a,a + add a,a + add a,a + or b + pop bc + ret end diff --git a/Source/HBIOS/romldr.asm b/Source/HBIOS/romldr.asm index 9e0bf162..c8940431 100644 --- a/Source/HBIOS/romldr.asm +++ b/Source/HBIOS/romldr.asm @@ -878,6 +878,10 @@ diskboot9: ld de,(bb_cpmloc) ; de := start or a ; clear carry sbc hl,de ; hl := length to load + ; If load length is not a multiple of sector size (512) + ; we need to round up to get everything loaded! + ld de,511 ; 1 less than sector size + add hl,de ; ... and roundup ld a,h ; determine 512 byte sector count rra ; ... by dividing msb by two ld (loadcnt),a ; ... and save it @@ -1886,7 +1890,7 @@ str_help .db "\r\n" .db "\r\n R - Reboot System" #if (BIOS == BIOS_WBW) .db "\r\n I - Set Console Interface" - .db "\r\n V - Set HBIOS Diagnostic Verbosity" + .db "\r\n V [] - View/Set HBIOS Diagnostic Verbosity" #endif .db "\r\n [.] - Boot Disk Unit/Slice" .db 0 diff --git a/Source/ZPM3/Build.cmd b/Source/ZPM3/Build.cmd index 2bf6f800..93ad5eb5 100644 --- a/Source/ZPM3/Build.cmd +++ b/Source/ZPM3/Build.cmd @@ -17,6 +17,7 @@ copy ..\ZCCP\startzpm.com . copy ..\CPM3\genbnk.dat . copy ..\CPM3\zpmbios3.spr bnkbios3.spr copy ..\CPM3\gencpm.com . +copy ..\CPM3\util.rel . copy ..\CPM3\biosldrd.rel . copy ..\CPM3\biosldrc.rel . copy ..\CPM3\cpmldr.com . @@ -27,9 +28,9 @@ echo. echo. echo *** ZPM Loader *** echo. -zx LINK -ZPMLDRD[L100]=ZPM3LDR,BIOSLDRD +zx LINK -ZPMLDRD[L100]=ZPM3LDR,BIOSLDRD,UTIL move /Y zpmldrd.com zpmldr.bin -zx LINK -ZPMLDRC[L100]=ZPM3LDR,BIOSLDRC +zx LINK -ZPMLDRC[L100]=ZPM3LDR,BIOSLDRC,UTIL move /Y zpmldrc.com zpmldr.com rem pause diff --git a/Source/ZPM3/Clean.cmd b/Source/ZPM3/Clean.cmd index 57295d69..c2471144 100644 --- a/Source/ZPM3/Clean.cmd +++ b/Source/ZPM3/Clean.cmd @@ -10,6 +10,7 @@ if exist system.epr del system.epr if exist system.evn del system.evn if exist system.odd del system.odd if exist biosldr.rel del biosldr.rel +if exist util.rel del util.rel if exist *.sym del *.sym if exist zpmldr.com del zpmldr.com if exist cpmldr.com del cpmldr.com diff --git a/Source/ZPM3/Makefile b/Source/ZPM3/Makefile index 30859cef..db2c13dc 100644 --- a/Source/ZPM3/Makefile +++ b/Source/ZPM3/Makefile @@ -5,18 +5,18 @@ OBJECTS += setz3.com clrhist.com autotog.com NODELETE = setz3.com clrhist.com autotog.com makedos.com zinstal.zpm bnkbdos3.spr resbdos3.spr #endif OBJECTS += cpmldr.com cpmldr.sys zinstal.zpm makedos.com gencpm.dat bnkbios3.spr bnkbdos3.spr resbdos3.spr -OTHERS = zpmldr.bin loader.bin biosldrd.rel biosldrc.rel gencpm.com +OTHERS = zpmldr.bin loader.bin biosldrd.rel biosldrc.rel util.rel gencpm.com DEST = ../../Binary/ZPM3/ TOOLS =../../Tools include $(TOOLS)/Makefile.inc -zpmldr.bin: zpm3ldr.rel biosldrd.rel - $(ZXCC) $(CPM)/LINK -ZPMLDRD[L100]=ZPM3LDR,BIOSLDRD +zpmldr.bin: zpm3ldr.rel biosldrd.rel util.rel + $(ZXCC) $(CPM)/LINK -ZPMLDRD[L100]=ZPM3LDR,BIOSLDRD,UTIL mv zpmldrd.com zpmldr.bin -zpmldr.com: zpm3ldr.rel biosldrc.rel - $(ZXCC) $(CPM)/LINK -ZPMLDRC[L100]=ZPM3LDR,BIOSLDRC +zpmldr.com: zpm3ldr.rel biosldrc.rel util.rel + $(ZXCC) $(CPM)/LINK -ZPMLDRC[L100]=ZPM3LDR,BIOSLDRC,UTIL mv zpmldrc.com zpmldr.com zpmldr.sys: zpmldr.bin loader.bin @@ -40,6 +40,9 @@ biosldrc.rel: ../CPM3/biosldrc.rel biosldrd.rel: ../CPM3/biosldrd.rel cp $< $@ +util.rel: ../CPM3/util.rel + cp $< $@ + zccp.com: ../ZCCP/ccp.com cp $< $@ diff --git a/Source/ZPM3/loader.asm b/Source/ZPM3/loader.asm index 42a8082d..cc2ffc0a 100644 --- a/Source/ZPM3/loader.asm +++ b/Source/ZPM3/loader.asm @@ -28,11 +28,12 @@ #INCLUDE "../ver.inc" ; ; BELOW, SYS_END MUST BE SET TO THE SIZE OF CPMLDR.BIN + SYS_LOC. IF -; THE SIZE OF CPMLDR.BIN CHANGES, SYS_END MUST BE UPDATED!!! +; THE SIZE OF ZPMLDR.BIN CHANGES, SYS_SIZ MUST BE UPDATED!!! ; +SYS_SIZ .EQU $0F00 ; SIZE OF CPMLDR.BIN SYS_ENT .EQU $0100 ; SYSTEM (OS) ENTRY POINT ADDRESS SYS_LOC .EQU $0100 ; STARTING ADDRESS TO LOAD SYSTEM IMAGE -SYS_END .EQU $1580 + SYS_LOC ; ENDING ADDRESS OF SYSTEM IMAGE +SYS_END .EQU SYS_SIZ + SYS_LOC ; ENDING ADDRESS OF SYSTEM IMAGE ; SEC_SIZE .EQU 512 ; DISK SECTOR SIZE BLK_SIZE .EQU 128 ; OS BLOCK/RECORD SIZE