X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp-cpm3.git/blobdiff_plain/1d26b86661bff5609cb3ae4404a0208c1b651360..f4471ef90f63448efdf36c4e3a5406641e2353bd:/cbios/bioskrnl.180 diff --git a/cbios/bioskrnl.180 b/cbios/bioskrnl.180 index 93d556d..993e60e 100644 --- a/cbios/bioskrnl.180 +++ b/cbios/bioskrnl.180 @@ -26,10 +26,10 @@ bell equ 7 ctlQ equ 'Q'-'@' ctlS equ 'S'-'@' -ccp equ 0100h ; Console Command Processor gets loaded - ; into the TPA +ccp equ 0100h ; Console Command Processor gets loaded + ; into the TPA - cseg ; GENCPM puts CSEG stuff in common memory + cseg ; GENCPM puts CSEG stuff in common memory ; variables in system data page @@ -40,7 +40,7 @@ ccp equ 0100h ; Console Command Processor gets loaded ; initialization - extrn hwinit,?init ; general initialization and signon + extrn hwinit,?init ; general initialization and signon extrn ?ldccp,?rlccp ; load & reload CCP for BOOT & WBOOT ; user defined character I/O routines @@ -67,10 +67,13 @@ ccp equ 0100h ; Console Command Processor gets loaded ; 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) + + extrn div32_16 ; divide 32 bit by 16 bit number include modebaud.inc ; define mode bits @@ -88,45 +91,45 @@ ccp equ 0100h ; Console Command Processor gets loaded ; 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 auxiliary output character -?auxi: jp auxin ; return auxiliary 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 ; select 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 + ; 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 auxiliary output character +?auxi: jp auxin ; return auxiliary 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 ; select 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 future expansion jp 0 ; reserved for future expansion @@ -136,69 +139,69 @@ ccp equ 0100h ; Console Command Processor gets loaded ; BOOT ; Initial entry point for system startup. - dseg ; this part can be banked + dseg ; this part can be banked boot: ld sp,bs$stack - call hwinit ; first time hardware initialisation + 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 + call ?init ; perform any additional system initialization + ; and print signon message ld bc,16*256+0 - ld hl,@dtbl ; init all 16 logical disk drives + ld hl,@dtbl ; init all 16 logical disk drives d$init$loop: - push bc ; save remaining count and abs drive + push bc ; save remaining count and abs drive ld e,(hl) inc hl ld d,(hl) - inc hl ; grab @drv entry + inc hl ; grab @drv entry ld a,e or d - jr z,d$init$next ; if null, no drive - push hl ; save @drv pointer + jr z,d$init$next ; if null, no drive + push hl ; save @drv pointer if 0 - ex de,hl ; XDPH address in + ex de,hl ; XDPH address in dec hl dec hl - ld b,(hl) ; get relative drive code - ld (@ADRV),bc ; save absolute and relative drive code - dec hl ; point to init pointer + ld b,(hl) ; get relative drive code + ld (@ADRV),bc ; save absolute and relative drive code + dec hl ; point to init pointer ld d,(hl) dec hl - ld e,(hl) ; get init pointer + ld e,(hl) ; get init pointer ex de,hl - call ipchl ; call init routine + call ipchl ; call init routine else push de pop ix ld b,(ix-2) - ld (@ADRV),bc ; save absolute and relative drive code + ld (@ADRV),bc ; save absolute and relative drive code ld l,(ix-4) - ld h,(ix-3) ; get init pointer - call ipchl ; call init routine + ld h,(ix-3) ; get init pointer + call ipchl ; call init routine endif - pop hl ; recover @drv pointer + pop hl ; recover @drv pointer d$init$next: - pop bc ; recover counter and drive # + pop bc ; recover counter and drive # inc c - djnz d$init$loop ; and loop for each drive + djnz 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 + call ?ldccp ; fetch CCP for first time jp ccp @@ -207,9 +210,9 @@ boot$1: wboot: ld sp,bs$stack - call set$jumps ; initialize page zero - call ?rlccp ; reload CCP - jp ccp ; then reset jmp vectors and exit to ccp + call set$jumps ; initialize page zero + call ?rlccp ; reload CCP + jp ccp ; then reset jmp vectors and exit to ccp set$jumps: @@ -229,7 +232,7 @@ set$jumps: ret - ds 64 + ds bs$stack$size bs$stack equ $ @@ -288,14 +291,14 @@ not$out$ready: 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 + 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 + or l ; see if any devices left jr nz,co$next ; and go find them... ret @@ -334,7 +337,7 @@ cos$next: add hl,hl ; check next bit push hl ; save the vector push bc ; save the count - ld a,0FFh ; assume device ready + ld a,0FFh ; assume device ready call c,coster ; check status for this device pop bc ; recover count pop hl ; recover bit vector @@ -342,30 +345,31 @@ cos$next: ret z ; if any not ready, return false inc b ; drop device number ld a,h - or l ; see if any more selected devices + or l ; see if any more selected devices jr nz,cos$next - or 0FFh ; all selected were ready, return true + or 0FFh ; all selected were ready, return true ret -coster: ; check for output device ready, including optional - ; xon/xoff support + ; check for output device ready, including optional + ; xon/xoff support +coster: ld l,b - ld h,0 ; make device code 16 bits - push hl ; save it in stack + 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 + add hl,hl ; create offset into device characteristics tbl ld de,@ctbl+6 - add hl,de ; make address of mode byte + add hl,de ; make address of mode byte ld a,(hl) and mb$xon$xoff - pop hl ; recover console number in + pop hl ; recover console number in 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 + 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 + call nz,ci1 ; get flag or read key if any cp ctlq jr nz,not$q ; if its a ctl-Q, ld a,0FFh ; set the flag ready @@ -374,12 +378,12 @@ not$q: jr nz,not$s ; if its a ctl-S, ld a,00h ; clear the flag not$s: - ld (hl),a ; save the flag + ld (hl),a ; save the flag call cost1 ; get the actual output status, - and (hl) ; and mask with ctl-Q/ctl-S flag + and (hl) ; and mask with ctl-Q/ctl-S flag ret ; return this as the status -cist1: ; get input status with and saved +cist1: ; get input status with and saved push bc push hl call ?cist @@ -388,7 +392,7 @@ cist1: ; get input status with and saved or a ret -cost1: ; get output status, saving & +cost1: ; get output status, saving & push bc push hl call ?cost @@ -397,7 +401,7 @@ cost1: ; get output status, saving & or a ret -ci1: ; get input, saving & +ci1: ; get input, saving & push bc push hl call ?ci @@ -434,7 +438,7 @@ cis$next: ret nz ; if any ready, return true inc b ; next device number ld a,h - or l ; see if any more selected devices + or l ; see if any more selected devices jr nz,cis$next xor a ; all selected were not ready, return false ret @@ -511,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 @@ -519,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 @@ -562,59 +575,101 @@ prd_1: pop hl ret + +;------------------------------------------------------------------------------- +; print decimal 16 bit number from HL +; +; HL: unsigned binary number to print +; C: minimum print field width +; number is prined right-aligned +; B: pad character, typically ' ' or '0' + +pr.dec: + push de + ld de,0 + call pr.decl + pop de + ret + ;------------------------------------------------------------------------------- +; print decimal 32 bit number from DEHL +; +; DEHL: unsigned binary number to print +; C: minimum print field width +; number is prined right-aligned +; B: pad character, typically ' ' or '0' + +pr.decl: + push bc ;save width and fillchar + push bc + exx ;(alt) + ex (sp),hl ;save hl', get width and fill + push de ;save de' -?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 + xor a + ld d,a ;clear counter + ld e,a + 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 + cp l + jr nc,prd_out + push hl inc sp - jp pdecl -stoploop: - push de - push bc - ld c,a - call ?cono - pop bc + 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 -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 + exx ;(main) + pop bc ret -table10: - dw -1000,-100,-10,-1,0 +;------------------------------------------------------------------------------- +; ?pderr: ld hl,drive$msg - call ?pmsg ; error header + call ?pmsg ; error header ld a,(@adrv) add a,'A' ld c,a - call ?cono ; drive code + call ?cono ; drive code ld hl,track$msg - call ?pmsg ; track header + 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 + call ?pmsg ; sector header ld hl,(@sect) - call ?pdec ; sector number + call pr.dec ; sector number ret @@ -622,9 +677,9 @@ table10: ; 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 + ld (@cbnk),a ; remember current bank + jp ?bank ; and go exit through users + ; physical bank select routine xofflist: @@ -648,34 +703,34 @@ xofflist: ; in seldsk: - ld a,c ; save drive select code + ld a,c ; save drive select code ld (@adrv),a - ld b,0 ; create index from drive code + ld b,0 ; create index from drive code ld hl,@dtbl - add hl,bc ; get pointer to dispatch table + add hl,bc ; get pointer to dispatch table add hl,bc ld a,(hl) inc hl ld h,(hl) - ld l,a ; point at disk descriptor - ld (@xdph),hl ; save descriptor pointer + ld l,a ; point at disk descriptor + ld (@xdph),hl ; save descriptor pointer or h - ret z ; if no entry in table, no disk + ret z ; if no entry in table, no disk - ld a,e ; examine login bit + ld a,e ; examine login bit and 1 ret nz push ix ld ix,(@xdph) ld a,(ix-2) - ld (@RDRV),a ; get relative drive - ld l,(ix-6) ; get address of LOGIN routine + ld (@RDRV),a ; get relative drive + ld l,(ix-6) ; get address of LOGIN routine ld h,(ix-5) ex (sp),ix pop de - call ipchl ; call LOGIN - ld hl,(@xdph) ; recover DPH pointer + call ipchl ; call LOGIN + ld hl,(@xdph) ; recover DPH pointer ret @@ -751,8 +806,8 @@ sectrn: ; extended disk parameter header (XDPH). read: - ld ix,(@xdph) ; get drive descriptor pointer - ld l,(ix-8) ; get read routine entry + ld ix,(@xdph) ; get drive descriptor pointer + ld l,(ix-8) ; get read routine entry ld h,(ix-7) jp (hl) @@ -763,8 +818,8 @@ read: ; extended disk parameter header (XDPH). write: - ld ix,(@xdph) ; get drive descriptor pointer - ld l,(ix-10) ; get write routine entry + ld ix,(@xdph) ; get drive descriptor pointer + ld l,(ix-10) ; get write routine entry ld h,(ix- 9) jp (hl) @@ -784,7 +839,7 @@ multio: flush: xor a - ret ; return with no error + ret ; return with no error