source: xtideuniversalbios/trunk/BIOS_Drive_Information_Tool/Src/Print.asm @ 376

Last change on this file since 376 was 376, checked in by gregli@…, 12 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 6.4 KB
Line 
1; Project name  :   BIOS Drive Information Tool
2; Description   :   Functions to print information read from BIOS.
3
4;
5; XTIDE Universal BIOS and Associated Tools 
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12; 
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16; GNU General Public License for more details.     
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;               
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Print_SetCharacterOutputToSTDOUT
25;   Parameters:
26;       Nothing
27;   Returns:
28;       Nothing
29;   Corrupts registers:
30;       AX, BX, DI
31;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33Print_SetCharacterOutputToSTDOUT:
34    mov     bl, ATTRIBUTES_NOT_USED
35    mov     ax, DosCharOut
36    CALL_DISPLAY_LIBRARY    SetCharOutputFunctionFromAXwithAttribFlagInBL
37    ret
38
39;--------------------------------------------------------------------
40; Use DOS standard output so strings can be redirected to a file.
41;
42; DosCharOut
43;   Parameters:
44;       AL:     Character to output
45;       DS:     BDA segment (zero)
46;       ES:DI:  Ptr to video memory where to output
47;   Returns:
48;       DI:     Incremented for next character
49;   Corrupts registers:
50;       AX, DX
51;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
53DosCharOut:
54    xchg    dx, ax
55    mov     ah, 02h     ; DOS 1+ - WRITE CHARACTER TO STANDARD OUTPUT
56    int     21h         ; Call DOS
57    ret
58
59
60;---------------------------------------------------------------------
61; Print_ErrorMessageFromAHifError
62;   Parameters:
63;       AH:     BIOS error code
64;       CF:     Set if error, cleared otherwise
65;   Returns:
66;       Nothing
67;   Corrupts registers:
68;       AX, BP, SI, DI (CF remains unchanged)
69;--------------------------------------------------------------------
70ALIGN JUMP_ALIGN
71Print_ErrorMessageFromAHifError:
72    jnc     SHORT .NoErrors
73    eMOVZX  ax, ah
74    mov     si, g_szBiosError
75    call    Print_BiosFunctionNumberFromAXusingFormatStringInSI
76    stc     ; Keep the CF set
77ALIGN JUMP_ALIGN
78.NoErrors:
79    ret
80
81
82;---------------------------------------------------------------------
83; Print_DriveNumberFromDLusingFormatStringInSI
84; Print_VersionStringFromAXusingFormatStringInSI
85; Print_BiosFunctionNumberFromAXusingFormatStringInSI
86; Print_SectorSizeFromAXusingFormatStringInSI
87;   Parameters:
88;       DL:     Drive Number
89;       AX:     Function number
90;   Returns:
91;       Nothing
92;   Corrupts registers:
93;       AX, BP, DI
94;--------------------------------------------------------------------
95ALIGN JUMP_ALIGN
96Print_DriveNumberFromDLusingFormatStringInSI:
97    eMOVZX  ax, dl
98Print_VersionStringFromAXusingFormatStringInSI:
99Print_BiosFunctionNumberFromAXusingFormatStringInSI:
100Print_SectorSizeFromAXusingFormatStringInSI:
101    mov     bp, sp
102    push    ax
103    jmp     SHORT JumpToFormatNullTerminatedStringFromSI
104
105
106;---------------------------------------------------------------------
107; Print_CHSfromCXDXAX
108;   Parameters:
109;       CX:     Number of cylinders (1...16383)
110;       DX:     Number of heads (1...255)
111;       AX:     Sectors per track (1...63)
112;   Returns:
113;       Nothing
114;   Corrupts registers:
115;       AX, BP, DI
116;--------------------------------------------------------------------
117ALIGN JUMP_ALIGN
118Print_CHSfromCXDXAX:
119    push    si
120
121    mov     bp, sp
122    push    cx
123    push    dx
124    push    ax
125    mov     si, g_szFormatCHS
126    CALL_DISPLAY_LIBRARY    FormatNullTerminatedStringFromCSSI
127
128    pop     si
129    ret
130
131
132;---------------------------------------------------------------------
133; Print_NameFromAtaInfoInBX
134;   Parameters:
135;       DS:BX:  Ptr to ATA information
136;   Returns:
137;       Nothing
138;   Corrupts registers:
139;       AX, CX, BP, SI, DI
140;--------------------------------------------------------------------
141ALIGN JUMP_ALIGN
142Print_NameFromAtaInfoInBX:
143    cld
144    lea     si, [bx+ATA1.strModel]
145    mov     di, si
146    mov     cx, A1_MODEL_NUMBER_LENGTH/2
147ALIGN JUMP_ALIGN
148.ReverseNextWord:
149    lodsw
150    xchg    al, ah
151    stosw
152    loop    .ReverseNextWord
153    dec     di
154    xor     ax, ax
155    stosb               ; Terminate with NULL
156
157    mov     bp, sp
158    lea     si, [bx+ATA1.strModel]
159    push    si
160    mov     si, g_szFormatDrvName
161    jmp     SHORT JumpToFormatNullTerminatedStringFromSI
162
163
164;---------------------------------------------------------------------
165; Print_TotalSectorsFromBXDXAX
166;   Parameters:
167;       BX:DX:AX:   Total number of sectors
168;   Returns:
169;       Nothing
170;   Corrupts registers:
171;       AX, BX, BP, DI
172;--------------------------------------------------------------------
173ALIGN JUMP_ALIGN
174Print_TotalSectorsFromBXDXAX:
175    ePUSH_T di, 0
176    push    bx
177    push    dx
178    push    ax
179    mov     bp, sp
180    mov     bx, 10
181    CALL_DISPLAY_LIBRARY    PrintQWordFromSSBPwithBaseInBX
182    add     sp, BYTE 8
183
184    push    si
185    mov     si, g_szNewline
186    call    Print_NullTerminatedStringFromSI
187    pop     si
188       
189    ret
190
191
192;---------------------------------------------------------------------
193; Print_EbiosVersionFromBXandExtensionsFromCX
194;   Parameters:
195;       BX:     Version of extensions
196;       CX:     Interface support bit map
197;   Returns:
198;       Nothing
199;   Corrupts registers:
200;       AX, BP, SI, DI
201;--------------------------------------------------------------------
202ALIGN JUMP_ALIGN
203Print_EbiosVersionFromBXandExtensionsFromCX:
204    mov     bp, sp
205    push    bx
206    push    cx
207    mov     si, g_szNewExtensions
208    jmp     SHORT JumpToFormatNullTerminatedStringFromSI
209
210
211;---------------------------------------------------------------------
212; JumpToFormatNullTerminatedStringFromSI
213;   Parameters:
214;       BP:     SP before pushing parameters
215;       CS:SI:  Ptr to format string
216;   Returns:
217;       Pushed parameters are cleaned from stack
218;   Corrupts registers:
219;       AX, DI
220;--------------------------------------------------------------------
221ALIGN JUMP_ALIGN
222JumpToFormatNullTerminatedStringFromSI: 
223    CALL_DISPLAY_LIBRARY    FormatNullTerminatedStringFromCSSI
224    ret
225
226
227;---------------------------------------------------------------------
228; Print_NullTerminatedStringFromSI
229;   Parameters:
230;       CS:SI:  Ptr to string to display
231;   Returns:
232;       Nothing
233;   Corrupts registers:
234;       AX, DI
235;--------------------------------------------------------------------
236ALIGN JUMP_ALIGN
237Print_NullTerminatedStringFromSI:
238    CALL_DISPLAY_LIBRARY    PrintNullTerminatedStringFromCSSI
239    ret
Note: See TracBrowser for help on using the repository browser.