1 | ; Project name : XTIDE Universal BIOS |
---|
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 | ; DS:DI: Ptr to DPT (HCapacity_GetSectorCountFromOurAH08h) |
---|
16 | ; Returns: |
---|
17 | ; DX:AX: Total sector count |
---|
18 | ; BX: Zero |
---|
19 | ; Corrupts registers: |
---|
20 | ; CX |
---|
21 | ;-------------------------------------------------------------------- |
---|
22 | ALIGN JUMP_ALIGN |
---|
23 | HCapacity_GetSectorCountFromForeignAH08h: |
---|
24 | mov ah, GET_DRIVE_PARAMETERS |
---|
25 | call Int13h_CallPreviousInt13hHandler |
---|
26 | jmp SHORT ConvertAH08hReturnValuesToSectorCount |
---|
27 | |
---|
28 | ALIGN JUMP_ALIGN |
---|
29 | HCapacity_GetSectorCountFromOurAH08h: |
---|
30 | call AH8h_GetDriveParameters |
---|
31 | ; Fall to ConvertAH08hReturnValuesToSectorCount |
---|
32 | |
---|
33 | ConvertAH08hReturnValuesToSectorCount: |
---|
34 | call HAddress_ExtractLCHSFromBiosParams |
---|
35 | xor ax, ax ; Zero AX |
---|
36 | inc cx ; Max cylinder number to cylinder count |
---|
37 | xchg al, bh ; AX=Max head number, BX=Sectors per track |
---|
38 | inc ax ; AX=Head count |
---|
39 | mul bx ; AX=Head count * Sectors per track |
---|
40 | mul cx ; DX:AX = Total sector count |
---|
41 | xor bx, bx ; Zero BX for 48-bit sector count (and clear CF) |
---|
42 | ret |
---|