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