1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Functions for preparing data buffer for transfer.
|
---|
3 |
|
---|
4 | ; Section containing code
|
---|
5 | SECTION .text
|
---|
6 |
|
---|
7 | ;---------------------------------------------------------------------
|
---|
8 | ; PrepareBuffer_ToESSIforOldInt13hTransfer
|
---|
9 | ; Parameters:
|
---|
10 | ; AL: Number of sectors to transfer
|
---|
11 | ; SS:BP: Ptr to IDEPACK
|
---|
12 | ; Parameters on INTPACK:
|
---|
13 | ; ES:BX: Ptr to data buffer
|
---|
14 | ; Returns:
|
---|
15 | ; ES:SI: Ptr to normalized data buffer
|
---|
16 | ; Exits INT 13h if error
|
---|
17 | ; Corrupts registers:
|
---|
18 | ; BX
|
---|
19 | ;--------------------------------------------------------------------
|
---|
20 | ALIGN JUMP_ALIGN
|
---|
21 | PrepareBuffer_ToESSIforOldInt13hTransfer:
|
---|
22 | ; Normalize buffer pointer
|
---|
23 | mov bx, [bp+IDEPACK.intpack+INTPACK.bx] ; Load offset
|
---|
24 | mov si, bx
|
---|
25 | eSHR_IM bx, 4 ; Divide offset by 16
|
---|
26 | add bx, [bp+IDEPACK.intpack+INTPACK.es]
|
---|
27 | mov es, bx ; Segment normalized
|
---|
28 | and si, BYTE 0Fh ; Offset normalized
|
---|
29 |
|
---|
30 | ; Check if valid number of sectors
|
---|
31 | test al, al
|
---|
32 | js SHORT .CheckZeroOffsetFor128Sectors
|
---|
33 | jz SHORT .InvalidNumberOfSectorsRequested
|
---|
34 | ret ; Continue with transfer
|
---|
35 |
|
---|
36 | ALIGN JUMP_ALIGN
|
---|
37 | .CheckZeroOffsetFor128Sectors:
|
---|
38 | cmp al, 128
|
---|
39 | ja SHORT .InvalidNumberOfSectorsRequested
|
---|
40 | mov ah, RET_HD_BOUNDARY
|
---|
41 | test si, si ; Offset must be zero to xfer 128 sectors
|
---|
42 | jnz SHORT .CannotAlignPointerProperly
|
---|
43 | ret ; Continue with transfer
|
---|
44 |
|
---|
45 | .InvalidNumberOfSectorsRequested:
|
---|
46 | mov ah, RET_HD_INVALID
|
---|
47 | .CannotAlignPointerProperly:
|
---|
48 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
49 |
|
---|