\r
; memory control\r
\r
- public @cbnk ; current bank\r
- extrn ?xmove,?move ; select move bank, and block move\r
- extrn ?bank ; select CPU bank\r
+ public @cbnk ; current bank\r
+ extrn ?xmove,?move ; select move bank, and block move\r
+ extrn ?bank ; select CPU bank\r
\r
; clock support\r
\r
- extrn ?time ; signal time operation\r
+ extrn ?time ; signal time operation\r
\r
; general utility routines\r
\r
- public ?pmsg,?pdec ; print message, print number from 0 to 65535\r
- public ?pderr ; print BIOS disk error message header\r
- public pmsg.in ; print message inline\r
- public phex4,phex2 ; print 4 digit hex (HL), or 2 digit hex (A)\r
+ public ?pmsg ; print message\r
+ public pr.dec,pr.decl ; print 16 or 32 bit decimal number\r
+ public ?pderr ; print BIOS disk error message header\r
+ public pr.inln,pr.crlf ; print message inline\r
+ public phex4,phex2 ; print 4 digit hex (HL), or 2 digit hex (A)\r
\r
- include modebaud.inc ; define mode bits\r
+ extrn div32_16 ; divide 32 bit by 16 bit number\r
+\r
+ include modebaud.inc ; define mode bits\r
\r
\r
; External names for BIOS entry points\r
\r
call hwinit ; first time hardware initialisation\r
\r
- ld c,15 ; initialize all 16 character devices\r
+ ld bc,16*256 + 0 ; initialize all 16 character devices\r
c$init$loop:\r
push bc\r
call ?cinit\r
pop bc\r
- dec c\r
- jp p,c$init$loop\r
+ inc c\r
+ djnz c$init$loop\r
\r
call ?init ; perform any additional system initialization\r
; and print signon message\r
; print message inline up to a null\r
; saves all registers\r
\r
-pmsg.in:\r
+pr.inln:\r
ex (sp),hl\r
push af\r
call ?pmsg\r
ex (sp),hl\r
ret\r
\r
+;-------------------------------------------------------------------------------\r
+; print <CR><LF>\r
+; saves all registers\r
+\r
+pr.crlf:\r
+ call pr.inln\r
+ db 13,10,0\r
+ ret\r
+\r
;-------------------------------------------------------------------------------\r
; print hl as a 4 digit hexadecimal number\r
; saves all registers\r
pop hl\r
ret\r
\r
+\r
+;-------------------------------------------------------------------------------\r
+; print decimal 16 bit number from HL\r
+;\r
+; HL: unsigned binary number to print\r
+; C: minimum print field width\r
+; number is prined right-aligned\r
+; B: pad character, typically ' ' or '0'\r
+\r
+pr.dec:\r
+ push de\r
+ ld de,0\r
+ call pr.decl\r
+ pop de\r
+ ret\r
+\r
;-------------------------------------------------------------------------------\r
+; print decimal 32 bit number from DEHL\r
+;\r
+; DEHL: unsigned binary number to print\r
+; C: minimum print field width\r
+; number is prined right-aligned\r
+; B: pad character, typically ' ' or '0'\r
+\r
+pr.decl:\r
+ push bc ;save width and fillchar\r
+ push bc\r
+ exx ;(alt)\r
+ ex (sp),hl ;save hl', get width and fill\r
+ push de ;save de'\r
\r
-?pdec: ; print binary number 0-65535 from <HL>\r
- ld bc,table10\r
- ld de,-10000\r
-next:\r
- ld a,'0'-1\r
-pdecl:\r
- push hl\r
- inc a\r
- add hl,de\r
- jp nc,stoploop\r
+ xor a\r
+ ld d,a ;clear counter\r
+ ld e,a\r
+ push af ; string terminator\r
inc sp\r
+\r
+prd_divloop: ;do\r
+ exx ; (main)\r
+ ld bc,10 ;\r
+ call div32_16 ; get a digit\r
+ ld a,c ;\r
+ add a,'0' ; make it printable\r
+ push af ;\r
+\r
+ ld a,h ;\r
+ or l ;\r
+ or d ;\r
+ or e ;\r
+ exx ; (alt)\r
+ inc sp ;\r
+ inc de ;\r
+ jr nz,prd_divloop ;\r
+\r
+prd_filloop: ;h=filler, l=field width\r
+ ld a,e\r
+ cp l\r
+ jr nc,prd_out\r
+ push hl\r
inc sp\r
- jp pdecl\r
-stoploop:\r
- push de\r
- push bc\r
- ld c,a\r
- call ?cono\r
- pop bc\r
+ inc de\r
+ jr prd_filloop\r
+prd_out:\r
+ ld hl,0\r
+ add hl,sp ;ptr to beginning of number string (hl==0 here)\r
+ call ?pmsg\r
+ ex de,hl\r
+ add hl,sp\r
+ ld sp,hl\r
+ inc sp ;remove string terminator\r
pop de\r
-nextdigit:\r
pop hl\r
- ld a,(bc)\r
- ld e,a\r
- inc bc\r
- ld a,(bc)\r
- ld d,a\r
- inc bc\r
- ld a,e\r
- or d\r
- jp nz,next\r
+ exx ;(main)\r
+ pop bc\r
ret\r
\r
-table10:\r
- dw -1000,-100,-10,-1,0\r
\r
+;-------------------------------------------------------------------------------\r
+;\r
?pderr:\r
ld hl,drive$msg\r
call ?pmsg ; error header\r
call ?cono ; drive code\r
ld hl,track$msg\r
call ?pmsg ; track header\r
+ ld c,0\r
ld hl,(@trk)\r
- call ?pdec ; track number\r
+ call pr.dec ; track number\r
ld hl,sector$msg\r
call ?pmsg ; sector header\r
ld hl,(@sect)\r
- call ?pdec ; sector number\r
+ call pr.dec ; sector number\r
ret\r
\r
\r