[88] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Functions for hard disk capacity calculations. |
---|
| 3 | |
---|
| 4 | ; Section containing code |
---|
| 5 | SECTION .text |
---|
| 6 | |
---|
| 7 | ;-------------------------------------------------------------------- |
---|
| 8 | ; Calculates sector count from L-CHS values returned by INT 13h, AH=08h. |
---|
| 9 | ; |
---|
| 10 | ; HCapacity_GetSectorCountFromForeignAH08h: |
---|
| 11 | ; HCapacity_GetSectorCountFromOurAH08h: |
---|
| 12 | ; Parameters: |
---|
| 13 | ; DL: Drive number |
---|
| 14 | ; DS: RAMVARS segment |
---|
| 15 | ; Returns: |
---|
| 16 | ; DX:AX: Total sector count |
---|
| 17 | ; BX: Zero |
---|
| 18 | ; Corrupts registers: |
---|
| 19 | ; CX |
---|
| 20 | ;-------------------------------------------------------------------- |
---|
| 21 | ALIGN JUMP_ALIGN |
---|
| 22 | HCapacity_GetSectorCountFromForeignAH08h: |
---|
| 23 | mov ah, 08h ; Get Drive Parameters |
---|
[32] | 24 | call Int13h_CallPreviousInt13hHandler |
---|
[3] | 25 | jmp SHORT HCapacity_ConvertAH08hReturnValuesToSectorCount |
---|
| 26 | |
---|
| 27 | ALIGN JUMP_ALIGN |
---|
| 28 | HCapacity_GetSectorCountFromOurAH08h: |
---|
| 29 | push di |
---|
| 30 | call AH8h_GetDriveParameters |
---|
| 31 | pop di |
---|
| 32 | ; Fall to HCapacity_ConvertAH08hReturnValuesToSectorCount |
---|
| 33 | |
---|
| 34 | ALIGN JUMP_ALIGN |
---|
| 35 | HCapacity_ConvertAH08hReturnValuesToSectorCount: |
---|
| 36 | call HAddress_ExtractLCHSFromBiosParams |
---|
| 37 | xor ax, ax ; Zero AX |
---|
| 38 | inc cx ; Max cylinder number to cylinder count |
---|
| 39 | xchg al, bh ; AX=Max head number, BX=Sectors per track |
---|
| 40 | inc ax ; AX=Head count |
---|
| 41 | mul bx ; AX=Head count * Sectors per track |
---|
| 42 | mul cx ; DX:AX = Total sector count |
---|
| 43 | xor bx, bx ; Zero BX for 48-bit sector count |
---|
| 44 | ret |
---|