source: trunk/bootcode/regular/auxio.asm@ 107

Last change on this file since 107 was 92, checked in by Ben Rietbroek, 8 years ago

Added function to print decimal value to com-port [v1.1.1-testing]

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File size: 13.6 KB
Line 
1; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
2;
3; This file is part of AiR-BOOT
4;
5; AiR-BOOT is free software: you can redistribute it and/or modify it under
6; the terms of the GNU General Public License as published by the Free
7; Software Foundation, either version 3 of the License, or (at your option)
8; any later version.
9;
10; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
11; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
12; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13; details.
14;
15; You should have received a copy of the GNU General Public License along with
16; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
17;
18;---------------------------------------------------------------------------
19; AiR-BOOT / AUXILARY I/O
20;---------------------------------------------------------------------------
21
22
23; -----------------------
24; Rousseau: # AUXIO.ASM #
25; -----------------------
26; Output some stuff to the serial port.
27; The aux parameters in the MBR must be initialized for this.
28; Lower byte is com-port, 0=disabled, 1=com1, etc.
29; High byte is initialization; see below. (0e3h)
30
31IFDEF MODULE_NAMES
32DB 'AUXIO',0
33ENDIF
34
35; Initialize the com-port, but only when logging is enabled.
36; It get's it's parameters from the value in the MBR.
37; Out: AX - line status
38AuxIO_Init Proc Near Uses dx si
39 ; bits 7-5 = datarate (000=110,001=150,010=300,011=600,100=1200,101=2400,110=4800,111=9600 bps)
40 ; bits 4-3 = parity (00 or 10 = none, 01 = odd, 11 = even)
41 ; bit 2 = stop-bits (set = 2 stop-bits, clear = 1 stop-bit)
42 ; bits 1-0 = data-bits (00 = 5, 01 = 6, 10 = 7, 11 = 8)
43 ; mov [BIOS_AuxParms],ax ; save initialization and port
44 mov dx,[BIOS_AuxParms] ; DL=port, 0=disabled, 1=com1; DH=config-parms
45 test dl,dl ; see if logging is enabled, if not, skip initialization
46 jz AuxIO_Init_NoLogging
47
48 dec dl ; adjust port-number
49 and dl,03h ; 3 is max value
50
51 ; Initialization message
52 mov si,offset AuxInitMsg
53 call MBR_Teletype
54
55 ; Port number
56 call VideoIO_SyncPos
57 mov al,dl
58 inc al
59 call VideoIO_PrintByteDynamicNumber
60 xor si,si
61 call MBR_TeletypeNL
62
63 ; Do the initialization
64 mov al,dh ; initialization parameters to al
65 mov dh,0 ; DX now contains port-number
66 mov ah,0
67 int 14h ; intialize com-port
68 AuxIO_Init_NoLogging:
69 ret
70AuxIO_Init EndP
71
72
73;
74; Send the Build Information to the COM-port.
75;
76AuxIO_PrintBuildInfo Proc Near Uses ax cx si di
77 ; Print header.
78 mov si, offset build_info
79 call AuxIO_Print
80
81 ; Prepare info in temorary buffer.
82 mov si,offset bld_level_date_start
83 mov cx,offset bld_level_date_end
84 sub cx,si
85 mov di,offset Scratch
86 cld
87 rep movsb
88
89 ; Fill spaces until assembler specification.
90 mov al,' '
91 mov cx,37
92 rep stosb
93
94 ; Copy assembler specification.
95 IFDEF JWASM
96 mov al,'['
97 stosb
98 mov si,offset jwasm_txt
99 ELSEIFDEF TASM
100 mov al,' '
101 stosb
102 mov al,'['
103 stosb
104 mov si,offset tasm_txt
105
106 ELSEIFDEF WASM
107 mov al,' '
108 stosb
109 mov al,'['
110 stosb
111 mov si,offset wasm_txt
112 ELSEIFDEF MASM
113 mov al,' '
114 stosb
115 mov al,'['
116 stosb
117 mov si,offset masm_txt
118 ELSE
119 mov al,' '
120 stosb
121 mov al,'['
122 stosb
123 mov si,offset unknown_txt
124 ENDIF
125
126 AuxIO_PrintBuildInfo_a1:
127 lodsb
128 test al,al
129 jz AuxIO_PrintBuildInfo_e1
130 stosb
131 jmp AuxIO_PrintBuildInfo_a1
132 AuxIO_PrintBuildInfo_e1:
133 mov al,']'
134 stosb
135
136 ; Insert NULL Terminator.
137 xor al,al
138 stosb
139
140 ; Print Info.
141 mov si, offset Scratch
142 call AuxIO_Print
143 call AuxIO_TeletypeNL
144
145 ; OS/2 BLDLEVEL information.
146 mov si, offset bld_level
147 call AuxIO_Print
148 call AuxIO_TeletypeNL
149
150 ret
151AuxIO_PrintBuildInfo EndP
152
153
154; Print char to com-port (teletype style)
155AuxIO_Teletype Proc Near Uses ax dx
156 mov dx,[BIOS_AuxParms] ; get port and parameters
157 xor dh,dh ; we don't need the parameters
158 test dl,dl ; test if logging is enabled
159 jz AuxIO_Teletype_NoLogging ; nope, return immediately
160 dec dl ; adjust port-number
161 and dl,03h ; 3 is max value
162 mov ah,01h
163 int 14h ; send char to com-port
164 AuxIO_Teletype_NoLogging:
165 ret
166AuxIO_Teletype EndP
167
168
169; Print newline char (unix) to com-port (teletype style)
170AuxIO_TeletypeNL Proc Near Uses ax
171 mov al,10
172 call AuxIO_Teletype
173 ret
174AuxIO_TeletypeNL EndP
175
176
177; Print byte as decimal to com-port (teletype style)
178AuxIO_TeletypeDecByte Proc Near Uses ax dx
179 call CONV_BinToPBCD ; Convert to PBCD
180 mov dx, ax ; Save PBCD value
181 shr ah, 4 ; Move digit count to low nibble
182 cmp ah, 3 ; Less than 3 digits ?
183 jb @F ; Yep, skip digit with index 2
184 mov al, dh ; Get byte with digit
185 and al, 0fh ; Mask it out
186 add al, '0' ; To ASCII
187 call AuxIO_Teletype
188 @@:
189 shr dh, 4 ; Move digit count to low nibble
190 cmp dh, 2 ; Less that 2 digits ?
191 jb @F ; Yep, skip digit with index 1
192 mov al, dl ; Get byte with digit
193 shr al, 4 ; Move to lower nibble
194 add al, '0' ; To ASCII
195 call AuxIO_Teletype
196 @@:
197 mov al, dl ; Get byte with digit
198 and al, 0fh ; Mask it out
199 add al, '0' ; To ASCII
200 call AuxIO_Teletype
201 ret
202AuxIO_TeletypeDecByte EndP
203
204
205; Print Bin-byte to com-port (teletype style)
206; This outputs 8 characters ('0' or '1' for each bit)
207; In: AL - byte to send
208; Out: AL - byte sent
209; Destroyed: None
210AuxIO_TeletypeBinByte Proc Near Uses ax cx
211 mov ah,al
212 mov cx,8
213 AuxIO_TeletypeBinByte_nextchar:
214 xor al,al
215 rcl ah,1
216 rcl al,1
217 add al,'0'
218 call AuxIO_Teletype
219 loop AuxIO_TeletypeBinByte_nextchar
220 ret
221AuxIO_TeletypeBinByte EndP
222
223; Print Bin-word to com-port (teletype style)
224; This outputs 16 characters ('0' or '1' for each bit)
225; In: AX - byte to send
226; Out: AX - byte sent
227; Destroyed: None
228AuxIO_TeletypeBinWord Proc
229 xchg al,ah ; High byte first
230 call AuxIO_TeletypeBinByte ; Output to com-port
231 xchg al,ah ; low byte next
232 call AuxIO_TeletypeBinByte ; Output to com-port
233 ret
234AuxIO_TeletypeBinWord EndP
235
236; Print Bin-dword to com-port (teletype style)
237; This outputs 32 characters ('0' or '1' for each bit)
238; In: DX:AX - dword to send
239; Out: DX:AX - dword sent
240; Destroyed: None
241AuxIO_TeletypeBinDWord Proc Near
242 xchg ax,dx
243 call AuxIO_TeletypeBinWord ; High word first
244 xchg ax,dx
245 call AuxIO_TeletypeBinWord ; Low word next
246 ret
247AuxIO_TeletypeBinDWord EndP
248
249; Print Bin-qword to com-port (teletype style)
250; This outputs 64 characters ('0' or '1' for each bit)
251; In: BX:CX:DX:AX - qword to send
252; Out: BX:CX:DX:AX - qword sent
253; Destroyed: None
254AuxIO_TeletypeBinQWord Proc Near
255 xchg dx,bx
256 xchg ax,cx
257 call AuxIO_TeletypeBinDWord ; High dword first
258 xchg dx,bx
259 xchg ax,cx
260 call AuxIO_TeletypeBinDWord ; Low dword next
261 ret
262AuxIO_TeletypeBinQWord EndP
263
264
265; Print hex-byte to com-port (teletype style)
266; This outputs two characters
267; In: AL - byte to send
268; Out: AL - byte sent
269; Destroyed: None
270AuxIO_TeletypeHexByte Proc Near Uses ax
271 call CONV_BinToAsc ; Returns high hex-nibble in AH, low hex-nibble in AL
272 xchg al,ah ; High hex-nibble first
273 call AuxIO_Teletype ; Output to com-port
274 xchg al,ah ; Low hex-nibble next
275 call AuxIO_Teletype ; Output to com-port
276 ret
277AuxIO_TeletypeHexByte EndP
278
279; Print hex-word to com-port (teletype style)
280; This outputs four characters
281; In: AX - word to send
282; Out: AX - word sent
283; Destroyed: None
284AuxIO_TeletypeHexWord Proc Near
285 xchg al,ah ; High byte first
286 call AuxIO_TeletypeHexByte ; Output to com-port
287 xchg al,ah ; low byte next
288 call AuxIO_TeletypeHexByte ; Output to com-port
289 ret
290AuxIO_TeletypeHexWord EndP
291
292
293; Print hex-dword to com-port (teletype style)
294; This outputs eight characters
295; In: DX:AX - dword to send
296; Out: DX:AX - dword sent
297; Destroyed: None
298AuxIO_TeletypeHexDWord Proc Near
299 xchg ax,dx
300 call AuxIO_TeletypeHexWord ; High word first
301 xchg ax,dx
302 call AuxIO_TeletypeHexWord ; Low word next
303 ret
304AuxIO_TeletypeHexDWord EndP
305
306
307; Print hex-qword to com-port (teletype style)
308; This outputs sixteen characters
309; In: BX:CX:DX:AX - qword to send
310; Out: BX:CX:DX:AX - qword sent
311; Destroyed: None
312AuxIO_TeletypeHexQWord Proc Near
313 xchg dx,bx
314 xchg ax,cx
315 call AuxIO_TeletypeHexDWord ; High dword first
316 xchg dx,bx
317 xchg ax,cx
318 call AuxIO_TeletypeHexDWord ; Low dword next
319 ret
320AuxIO_TeletypeHexQWord EndP
321
322
323
324; Print 0-terminated string to com-port
325AuxIO_Print Proc Near Uses ax bx cx dx
326 AuxIO_PrintNext:
327 lodsb
328 test al,al
329 jz AuxIO_PrintEOS
330 call AuxIO_Teletype
331 jmp AuxIO_PrintNext
332 AuxIO_PrintEOS:
333 ret
334AuxIO_Print EndP
335
336
337; Dump a 16-byte block of memory to the com-port in debug-format (hex-bytes and ascii-bytes)
338; In: DS:SI - pointer to memory to dump
339;
340AuxIO_DumpParagraph Proc Near Uses ax cx dx si
341
342 ; Dump the index dword
343 xor dx,dx
344 mov ax,si
345 call AuxIO_TeletypeHexDWord
346
347 ; Separate it from the dump
348 mov al,' '
349 call AuxIO_Teletype
350 mov al,' '
351 call AuxIO_Teletype
352 mov al,'|'
353 call AuxIO_Teletype
354 mov al,' '
355 call AuxIO_Teletype
356
357 ; Save si for later
358 push si
359
360 ; Four groups of 4 bytes
361 mov cx,4
362
363
364 AuxIO_DumpParagraph_Next_1:
365
366 ; byte at offset 0
367 lodsb
368 call AuxIO_TeletypeHexByte
369
370 ; space separator
371 mov al,' '
372 call AuxIO_Teletype
373
374 ; byte at offset 1
375 lodsb
376 call AuxIO_TeletypeHexByte
377
378 ; space separator
379 mov al,' '
380 call AuxIO_Teletype
381
382 ; byte at offset 2
383 lodsb
384 call AuxIO_TeletypeHexByte
385
386 ; space separator
387 mov al,' '
388 call AuxIO_Teletype
389
390 ; byte at offset 3
391 lodsb
392 call AuxIO_TeletypeHexByte
393
394 ; space separator
395 mov al,' '
396 call AuxIO_Teletype
397
398 ; separator
399 mov al,'|'
400 call AuxIO_Teletype
401
402 ; space separator
403 mov al,' '
404 call AuxIO_Teletype
405
406 loop AuxIO_DumpParagraph_Next_1
407
408 ; space separator
409 mov al,' '
410 call AuxIO_Teletype
411
412 ; recall pointer
413 pop si
414
415 ; 16 ascii bytes to print
416 mov cx,16
417
418 AuxIO_DumpParagraph_Next_2:
419 mov ah,'.' ; char to use ufnot printable
420 lodsb ; load byte
421 call CONV_ConvertToPrintable ; use dot's if not printable
422 call AuxIO_Teletype ; print it
423 loop AuxIO_DumpParagraph_Next_2
424 ret
425AuxIO_DumpParagraph EndP
426
427
428
429AuxIO_DumpSector Proc Near Uses cx si
430 mov cx,32 ; Number of paragraphs in a sector
431 AuxIO_DumpSector_Next:
432 call AuxIO_DumpParagraph ; Dump the paragraph
433 add si,16 ; Advance pointer
434 call AuxIO_TeletypeNL
435 loop AuxIO_DumpSector_Next
436 ret
437AuxIO_DumpSector EndP
438
439
440AuxIOHello db 10,10,10,10,10,'AiR-BOOT com-port debugging',10,0
441
442
Note: See TracBrowser for help on using the repository browser.