1 title 'general utility routines'
3 ; i/o port init routines
5 public ioiniml,ioini1l ;
9 public add_hla ; add a to hl
10 public div32_16,div32_r ; divide 32 bit by 16 bit number (rounded)
14 public ?pmsg ; print message
15 public pr.inln,pr.crlf ; print message inline, print newline
16 public phex2,phex4 ; print 2 digit hex (A) or 4 digit hex (HL)
17 public pr.dec,pr.decl ; print 16 or 32 bit decimal number
18 public ?pderr ; print BIOS disk error message header
23 extrn @adrv,@trk,@sect ; used by disk error message
25 ;-------------------------------------------------------------------------------
34 ;----------------------------------------------------------------------
35 ; output bytes to consecutive portaddresses
37 ; hl: table with following structure:
38 ; db n, port1, val1, val2,... valn
39 ; db m, port1, val1, val2,... valm
41 ; db 0 ; Terminate table
60 ;----------------------------------------------------------------------
61 ; output bytes to ports
63 ; hl: tables of port,value pairs:
64 ; db n, port1,val1, port2,val2,... portn,valn
66 ; db 0 ; Terminate table
72 ld c,(hl) ;port address
85 ;--------------------------------------------------------------------
99 ;--------------------------------------------------------------------
100 ; rounded div 32 by 16 bit
105 ; HLDE: Rounded Quotient (q)
112 add hl,bc ;low x + y/2
119 ;--------------------------------------------------------------------
120 ; Divide 32 bit by 16
131 push de ;save alternate registers (de,bc)
142 ex (sp),hl ;hl' = lx, save alternate hl
143 ld de,0 ;de' = lr = 0
144 ex de,hl ;de = x, hl = r
149 ; de: x (de: hx, de': lx)
150 ; bc: y (bc: hy, bc': ly)
181 jr nz,div_lp ;while (--count)
184 ; de: q (de: hq, de': lq)
185 ; hl: r (hl: hr, hl': lr)
188 ex de,hl ;hl = lq, de = lr
197 pop bc ;restore alternate registers
202 ;-------------------------------------------------------------------------------
203 ; print message @<HL> up to a null
224 ;-------------------------------------------------------------------------------
225 ; print message inline up to a null
226 ; saves all registers
236 ;-------------------------------------------------------------------------------
238 ; saves all registers
245 ;-------------------------------------------------------------------------------
246 ; print hl as a 4 digit hexadecimal number
247 ; saves all registers
255 ;-------------------------------------------------------------------------------
256 ; print a as a 2 digit hexadecimal number
257 ; saves all registers
289 ;-------------------------------------------------------------------------------
290 ; print decimal 16 bit number from HL
292 ; HL: unsigned binary number to print
293 ; C: minimum print field width
294 ; number is prined right-aligned
295 ; B: pad character, typically ' ' or '0'
304 ;-------------------------------------------------------------------------------
305 ; print decimal 32 bit number from DEHL
307 ; DEHL: unsigned binary number to print
308 ; C: minimum print field width
309 ; number is prined right-aligned
310 ; B: pad character, typically ' ' or '0'
313 push bc ;save width and fillchar
316 ex (sp),hl ;save hl', get width and fill
320 ld d,a ;clear counter
322 push af ; string terminator
328 call div32_16 ; get a digit
330 add a,'0' ; make it printable
342 prd_filloop: ;h=filler, l=field width
352 add hl,sp ;ptr to beginning of number string (hl==0 here)
357 inc sp ;remove string terminator
365 ;-------------------------------------------------------------------------------
369 call ?pmsg ; error header
373 call ?cono ; drive code
375 call ?pmsg ; track header
378 call pr.dec ; track number
380 call ?pmsg ; sector header
382 call pr.dec ; sector number
385 ; error message components
386 drive$msg: db cr,lf,bell,'BIOS Error on ',0
387 track$msg: db ': T-',0
388 sector$msg: db ', S-',0