1 | ; Project name : BIOS Drive Information Tool
|
---|
2 | ; Description : Functions to print information read from BIOS.
|
---|
3 |
|
---|
4 |
|
---|
5 | ; Section containing code
|
---|
6 | SECTION .text
|
---|
7 |
|
---|
8 | ;--------------------------------------------------------------------
|
---|
9 | ; Use DOS standard output so strings can be redirected to a file.
|
---|
10 | ;
|
---|
11 | ; Print_DosCharOut
|
---|
12 | ; Parameters:
|
---|
13 | ; AL: Character to output
|
---|
14 | ; DS: BDA segment (zero)
|
---|
15 | ; ES:DI: Ptr to video memory where to output
|
---|
16 | ; Returns:
|
---|
17 | ; DI: Incremented for next character
|
---|
18 | ; Corrupts registers:
|
---|
19 | ; AX, DX
|
---|
20 | ;--------------------------------------------------------------------
|
---|
21 | ALIGN JUMP_ALIGN
|
---|
22 | Print_DosCharOut:
|
---|
23 | xchg dx, ax
|
---|
24 | mov ah, 02h ; DOS 1+ - WRITE CHARACTER TO STANDARD OUTPUT
|
---|
25 | int 21h ; Call DOS
|
---|
26 | ret
|
---|
27 |
|
---|
28 |
|
---|
29 | ;---------------------------------------------------------------------
|
---|
30 | ; Print_ErrorMessageFromAHifError
|
---|
31 | ; Parameters:
|
---|
32 | ; AH: BIOS error code
|
---|
33 | ; CF: Set if error, cleared otherwise
|
---|
34 | ; Returns:
|
---|
35 | ; Nothing
|
---|
36 | ; Corrupts registers:
|
---|
37 | ; AX, BP, SI, DI (CF remains unchanged)
|
---|
38 | ;--------------------------------------------------------------------
|
---|
39 | ALIGN JUMP_ALIGN
|
---|
40 | Print_ErrorMessageFromAHifError:
|
---|
41 | jnc SHORT .NoErrors
|
---|
42 | eMOVZX ax, ah
|
---|
43 | mov si, g_szBiosError
|
---|
44 | call Print_BiosFunctionNumberFromAXusingFormatStringInSI
|
---|
45 | stc ; Keep the CF set
|
---|
46 | ALIGN JUMP_ALIGN
|
---|
47 | .NoErrors:
|
---|
48 | ret
|
---|
49 |
|
---|
50 |
|
---|
51 | ;---------------------------------------------------------------------
|
---|
52 | ; Print_DriveNumberFromDLusingFormatStringInSI
|
---|
53 | ; Print_BiosFunctionNumberFromAXusingFormatStringInSI
|
---|
54 | ; Print_SectorSizeFromAXusingFormatStringInSI
|
---|
55 | ; Parameters:
|
---|
56 | ; DL: Drive Number
|
---|
57 | ; AX: Function number
|
---|
58 | ; Returns:
|
---|
59 | ; Nothing
|
---|
60 | ; Corrupts registers:
|
---|
61 | ; AX, BP, DI
|
---|
62 | ;--------------------------------------------------------------------
|
---|
63 | ALIGN JUMP_ALIGN
|
---|
64 | Print_DriveNumberFromDLusingFormatStringInSI:
|
---|
65 | eMOVZX ax, dl
|
---|
66 | Print_BiosFunctionNumberFromAXusingFormatStringInSI:
|
---|
67 | Print_SectorSizeFromAXusingFormatStringInSI:
|
---|
68 | mov bp, sp
|
---|
69 | push ax
|
---|
70 | jmp SHORT JumpToFormatNullTerminatedStringFromSI
|
---|
71 |
|
---|
72 |
|
---|
73 | ;---------------------------------------------------------------------
|
---|
74 | ; Print_CHSfromCXDXAX
|
---|
75 | ; Parameters:
|
---|
76 | ; CX: Number of cylinders (1...16383)
|
---|
77 | ; DX: Number of heads (1...255)
|
---|
78 | ; AX: Sectors per track (1...63)
|
---|
79 | ; Returns:
|
---|
80 | ; Nothing
|
---|
81 | ; Corrupts registers:
|
---|
82 | ; AX, BP, DI
|
---|
83 | ;--------------------------------------------------------------------
|
---|
84 | ALIGN JUMP_ALIGN
|
---|
85 | Print_CHSfromCXDXAX:
|
---|
86 | push si
|
---|
87 |
|
---|
88 | mov bp, sp
|
---|
89 | push cx
|
---|
90 | push dx
|
---|
91 | push ax
|
---|
92 | mov si, g_szFormatCHS
|
---|
93 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
94 |
|
---|
95 | pop si
|
---|
96 | ret
|
---|
97 |
|
---|
98 |
|
---|
99 | ;---------------------------------------------------------------------
|
---|
100 | ; Print_NameFromAtaInfoInBX
|
---|
101 | ; Parameters:
|
---|
102 | ; DS:BX: Ptr to ATA information
|
---|
103 | ; Returns:
|
---|
104 | ; Nothing
|
---|
105 | ; Corrupts registers:
|
---|
106 | ; AX, CX, BP, SI, DI
|
---|
107 | ;--------------------------------------------------------------------
|
---|
108 | ALIGN JUMP_ALIGN
|
---|
109 | Print_NameFromAtaInfoInBX:
|
---|
110 | cld
|
---|
111 | lea si, [bx+ATA1.strModel]
|
---|
112 | mov di, si
|
---|
113 | mov cx, A1_MODEL_NUMBER_LENGTH/2
|
---|
114 | ALIGN JUMP_ALIGN
|
---|
115 | .ReverseNextWord:
|
---|
116 | lodsw
|
---|
117 | xchg al, ah
|
---|
118 | stosw
|
---|
119 | loop .ReverseNextWord
|
---|
120 | dec di
|
---|
121 | xor ax, ax
|
---|
122 | stosb ; Terminate with NULL
|
---|
123 |
|
---|
124 | mov bp, sp
|
---|
125 | lea si, [bx+ATA1.strModel]
|
---|
126 | push si
|
---|
127 | mov si, g_szFormatDrvName
|
---|
128 | jmp SHORT JumpToFormatNullTerminatedStringFromSI
|
---|
129 |
|
---|
130 |
|
---|
131 | ;---------------------------------------------------------------------
|
---|
132 | ; Print_TotalSectorsFromBXDXAX
|
---|
133 | ; Parameters:
|
---|
134 | ; BX:DX:AX: Total number of sectors
|
---|
135 | ; Returns:
|
---|
136 | ; Nothing
|
---|
137 | ; Corrupts registers:
|
---|
138 | ; AX, BX, BP, DI
|
---|
139 | ;--------------------------------------------------------------------
|
---|
140 | ALIGN JUMP_ALIGN
|
---|
141 | Print_TotalSectorsFromBXDXAX:
|
---|
142 | ePUSH_T di, 0
|
---|
143 | push bx
|
---|
144 | push dx
|
---|
145 | push ax
|
---|
146 | mov bp, sp
|
---|
147 | mov bx, 10
|
---|
148 | CALL_DISPLAY_LIBRARY PrintQWordFromSSBPwithBaseInBX
|
---|
149 | add sp, BYTE 8
|
---|
150 |
|
---|
151 | CALL_DISPLAY_LIBRARY PrintNewlineCharacters
|
---|
152 | ret
|
---|
153 |
|
---|
154 |
|
---|
155 | ;---------------------------------------------------------------------
|
---|
156 | ; Print_EbiosVersionFromBXandExtensionsFromCX
|
---|
157 | ; Parameters:
|
---|
158 | ; BX: Version of extensions
|
---|
159 | ; CX: Interface support bit map
|
---|
160 | ; Returns:
|
---|
161 | ; Nothing
|
---|
162 | ; Corrupts registers:
|
---|
163 | ; AX, BP, SI, DI
|
---|
164 | ;--------------------------------------------------------------------
|
---|
165 | ALIGN JUMP_ALIGN
|
---|
166 | Print_EbiosVersionFromBXandExtensionsFromCX:
|
---|
167 | mov bp, sp
|
---|
168 | push bx
|
---|
169 | push cx
|
---|
170 | mov si, g_szNewExtensions
|
---|
171 | jmp SHORT JumpToFormatNullTerminatedStringFromSI
|
---|
172 |
|
---|
173 |
|
---|
174 | ;---------------------------------------------------------------------
|
---|
175 | ; JumpToFormatNullTerminatedStringFromSI
|
---|
176 | ; Parameters:
|
---|
177 | ; BP: SP before pushing parameters
|
---|
178 | ; CS:SI: Ptr to format string
|
---|
179 | ; Returns:
|
---|
180 | ; Pushed parameters are cleaned from stack
|
---|
181 | ; Corrupts registers:
|
---|
182 | ; AX, DI
|
---|
183 | ;--------------------------------------------------------------------
|
---|
184 | ALIGN JUMP_ALIGN
|
---|
185 | JumpToFormatNullTerminatedStringFromSI:
|
---|
186 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
187 | ret
|
---|
188 |
|
---|
189 |
|
---|
190 | ;---------------------------------------------------------------------
|
---|
191 | ; Print_NullTerminatedStringFromSI
|
---|
192 | ; Parameters:
|
---|
193 | ; CS:SI: Ptr to string to display
|
---|
194 | ; Returns:
|
---|
195 | ; Nothing
|
---|
196 | ; Corrupts registers:
|
---|
197 | ; AX, DI
|
---|
198 | ;--------------------------------------------------------------------
|
---|
199 | ALIGN JUMP_ALIGN
|
---|
200 | Print_NullTerminatedStringFromSI:
|
---|
201 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
202 | ret
|
---|