From d12d8b38ea365a5878a5c9d74bf76de0a87dce33 Mon Sep 17 00:00:00 2001 From: Leo C Date: Fri, 29 May 2015 22:43:22 +0200 Subject: [PATCH] show cpu clock frequency at startup --- cbios/bioskrnl.180 | 192 +++++++++++++++++++++++++++++++++++---------- cbios/boot.180 | 36 ++++++--- cbios/misc.180 | 27 ++++--- cbios/sdio.180 | 22 +++--- 4 files changed, 198 insertions(+), 79 deletions(-) diff --git a/cbios/bioskrnl.180 b/cbios/bioskrnl.180 index 6ac3726..4338ef0 100644 --- a/cbios/bioskrnl.180 +++ b/cbios/bioskrnl.180 @@ -57,22 +57,25 @@ ccp equ 0100h ; Console Command Processor gets loaded ; memory control - public @cbnk ; current bank - extrn ?xmove,?move ; select move bank, and block move - extrn ?bank ; select CPU bank + 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 + 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 - public pmsg.in ; print message inline - public phex4,phex2 ; print 4 digit hex (HL), or 2 digit hex (A) + public ?pmsg ; print message + public pr.dec,pr.decl ; print 16 or 32 bit decimal number + public ?pderr ; print BIOS disk error message header + public pr.inln,pr.crlf ; print message inline + public phex4,phex2 ; print 4 digit hex (HL), or 2 digit hex (A) - include modebaud.inc ; define mode bits + extrn div32_16 ; divide 32 bit by 16 bit number + + include modebaud.inc ; define mode bits ; External names for BIOS entry points @@ -143,13 +146,13 @@ boot: call hwinit ; first time hardware initialisation - ld c,15 ; initialize all 16 character devices + ld bc,16*256 + 0 ; initialize all 16 character devices c$init$loop: push bc call ?cinit pop bc - dec c - jp p,c$init$loop + inc c + djnz c$init$loop call ?init ; perform any additional system initialization ; and print signon message @@ -512,7 +515,7 @@ pmsg$exit: ; print message inline up to a null ; saves all registers -pmsg.in: +pr.inln: ex (sp),hl push af call ?pmsg @@ -520,6 +523,15 @@ pmsg.in: ex (sp),hl ret +;------------------------------------------------------------------------------- +; print +; saves all registers + +pr.crlf: + call pr.inln + db 13,10,0 + ret + ;------------------------------------------------------------------------------- ; print hl as a 4 digit hexadecimal number ; saves all registers @@ -563,44 +575,139 @@ prd_1: pop hl ret + + if 0 + ;------------------------------------------------------------------------------- +; print 16 bit number from HL +; -?pdec: ; print binary number 0-65535 from - ld bc,table10 - ld de,-10000 -next: - ld a,'0'-1 -pdecl: - push hl - inc a - add hl,de - jp nc,stoploop +pr.dec: + ex de,hl + ld hl,0 + ;fall thru + +pr.decl: + push ix + ld ix,1 ; count chars on stack + push bc + exx + ex (sp),hl +; push de +; push bc + exx + + xor a + push af ; string terminator inc sp +prd_divloop: + ld bc,10 + call div32_16 ; get a digit + ld a,c + add a,'0' ; make it printable + push af inc sp - jp pdecl -stoploop: - push de - push bc - ld c,a - call ?cono - pop bc + inc ix + + ld a,h + or l + or d + or e + jr nz,prd_divloop + exx + push hl + exx + pop bc ;b=filler, c=field width + inc c + push ix pop de -nextdigit: +prd_filloop: + ld a,e + cp c + jr nc,prd_out + push bc + inc sp + inc de + jr prd_filloop +prd_out: + ld hl,0 + add hl,sp ;ptr to beginning of number string (hl==0 here) + call ?pmsg + ex de,hl + add hl,sp + ld sp,hl + exx pop hl - ld a,(bc) + exx + pop ix + ret + + endif + +;------------------------------------------------------------------------------- +; print 16 bit number from HL +; + +pr.dec: + ex de,hl + ld hl,0 + ;fall thru + +pr.decl: + push bc ;save width and fillchar + push bc + exx + ex (sp),hl ;save hl', get width and fill + push de ;save de' + + xor a + ld d,a ;clear counter ld e,a - inc bc - ld a,(bc) - ld d,a - inc bc + push af ; string terminator + inc sp + +prd_divloop: ;do + exx ; (main) + ld bc,10 ; + call div32_16 ; get a digit + ld a,c ; + add a,'0' ; make it printable + push af ; + + ld a,h ; + or l ; + or d ; + or e ; + exx ; (alt) + inc sp ; + inc de ; + jr nz,prd_divloop ; + +prd_filloop: ;h=filler, l=field width ld a,e - or d - jp nz,next + cp l + jr nc,prd_out + push hl + inc sp + inc de + jr prd_filloop +prd_out: + ld hl,0 + add hl,sp ;ptr to beginning of number string (hl==0 here) + call ?pmsg + ex de,hl + add hl,sp + ld sp,hl + inc sp ;remove string terminator + pop de + pop hl + exx ;(main) + pop bc ret -table10: - dw -1000,-100,-10,-1,0 +;------------------------------------------------------------------------------- +; ?pderr: ld hl,drive$msg call ?pmsg ; error header @@ -610,12 +717,13 @@ table10: call ?cono ; drive code ld hl,track$msg call ?pmsg ; track header + ld c,0 ld hl,(@trk) - call ?pdec ; track number + call pr.dec ; track number ld hl,sector$msg call ?pmsg ; sector header ld hl,(@sect) - call ?pdec ; sector number + call pr.dec ; sector number ret diff --git a/cbios/boot.180 b/cbios/boot.180 index fe11486..d908929 100644 --- a/cbios/boot.180 +++ b/cbios/boot.180 @@ -6,7 +6,8 @@ public f_cpu - extrn ?boot,?pmsg,?conin + extrn ?boot,?conin + extrn pr.inln,pr.crlf,pr.dec,pr.decl extrn ioini1l,msginit,mmuinit,intinit,cpu_frq extrn @civec,@covec,@aivec,@aovec,@lovec extrn @cbnk,?bnksl @@ -57,17 +58,25 @@ hwini_skip: ld (@aovec),hl - call intinit ; setup interrupts and vectors + call intinit ; setup interrupts and vectors xor a - ld (@cbnk),a ; right now in bank 0 + ld (@cbnk),a ; right now in bank 0 - ld hl,signon$msg - call ?pmsg ; print signon message + call pr.inln ; print signon message + db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS',13,10,0 + + call pr.inln + db 'CPU clock [Hz]: ',0 + + ld de,(f_cpu) + ld hl,(f_cpu+2) + call pr.decl + call pr.crlf ret - cseg ; boot loading most be done from resident memory + cseg ; boot loading must be done from resident memory ; This version of the boot loader loads the CCP from a file ; called CCP.COM on the system drive (A:). @@ -75,6 +84,7 @@ hwini_skip: ?ldccp: ; First time, load the A:CCP.COM file into TPA + call resetdsk xor a ld (ccp$fcb+15),a ; zero extent ld hl,0 @@ -114,8 +124,9 @@ ld$1: ret no$ccp: ; here if we couldn't find the file - ld hl,ccp$msg - call ?pmsg ; report this... + call pr.inln ; report this... + db 13,10,'BIOS Err on A: No CCP.COM file',0 + call ?conin ; get a response jp ?ldccp ; and try again @@ -142,6 +153,10 @@ rl$1: ; CP/M BDOS Function Interfaces +resetdsk: + ld c,13 + jp bdos ; reset disk system + open: ld c,15 jp bdos ; open file control block @@ -159,11 +174,6 @@ read: jp bdos ; read records -signon$msg: - db 13,10,13,10,'CP/M Version 3.0, Z180-Stamp BIOS',13,10,0 - -ccp$msg:db 13,10,'BIOS Err on A: No CCP.COM file',0 - ccp$fcb:db 1,'CCP ','COM',0,0,0,0 ds 16 diff --git a/cbios/misc.180 b/cbios/misc.180 index 796f319..5d68374 100644 --- a/cbios/misc.180 +++ b/cbios/misc.180 @@ -31,15 +31,14 @@ add_hla: ret ;-------------------------------------------------------------------- -; HLDE: Divident (x) -; BC: Divisor (y) +; Divide 32 bit by 16 ; -; divide x/y -; x: hl -; y: de -; return: -; x/y: hl -; rem: de +; HLDE: Divident (x) +; BC: Divisor (y) +; +; return: +; HLDE: Quotient +; BC: Reminder cseg ; common area div32_16: @@ -60,6 +59,13 @@ div32_16: ex de,hl ;de = x, hl = r exx ;high ld a,32 ;count +; +; divide x/y +; x: hl +; y: de +; result: +; x/y: hl +; rem: de div_lp: ;do exx ; low ex de,hl ; x @@ -86,9 +92,8 @@ div_lp: ;do exx ; high adc hl,bc ; -div_no_restore: - - dec a +div_no_restore: ; + dec a ; jr nz,div_lp ;while (--count) ex de,hl ; q diff --git a/cbios/sdio.180 b/cbios/sdio.180 index 78a8579..b229c8d 100644 --- a/cbios/sdio.180 +++ b/cbios/sdio.180 @@ -22,8 +22,8 @@ ; Utility routines in standard BIOS extrn ?wboot ; warm boot vector - extrn ?pmsg ; print message @ up to 00, saves & - extrn ?pdec ; print binary number in from 0 to 99. + extrn ?pmsg,pr.inln ; print message @, print inline message + extrn pr.crlf ; print extrn ?pderr ; print BIOS disk error header extrn ?conin,?cono ; con in and out extrn ?const ; get console status @@ -73,14 +73,14 @@ sd1: dph 0,dpbsimhd512 dw sd$write dw sd$read dw sd$login - dw sd$init0 + dw sd$init2 db 2,0 ; relative drive zero sd2: dph 0,dpbsimhd512 dw sd$write dw sd$read dw sd$login - dw sd$init1 + dw sd$init3 db 3,0 ; relative drive one sd3: dph 0,dpbsimhd512 @@ -267,8 +267,8 @@ fatfs_err: tst 080h jr z,prompt ; no fatfs error - ld hl,fsmsg - call ?pmsg + call pr.inln + db 'FatFs: ',0 ld hl,fr$msg0 ; point at first FatFs message ld c,fr$msg$count @@ -276,8 +276,9 @@ fatfs_err: call pdecoded prompt: - ld hl,error$msg - call ?pmsg ; print ", Retry (Y/N) ? " + call pr.inln + db ' Retry (Y/N) ? ',0 + call u$conin$echo ; get operator response cp 'Y' jr z,retry ; Yes, then retry 10 more times @@ -391,7 +392,6 @@ drvmsg3: db 'Bus Timeout, ',0 drvmsg_size equ $ - drvmsg0 drvmsg_count equ 3 -fsmsg: db 'FatFs: ',0 ; table of pointers to error message strings @@ -419,8 +419,4 @@ fr$msg20: db 'short read/write,',0 fr$msg$size equ $ - fr$msg0 fr$msg$count equ 20 -error$msg: - db ' Retry (Y/N) ? ',0 - - end -- 2.39.2