source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm @ 148

Last change on this file since 148 was 148, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

  • INT 13h optimizations to save almost 100 bytes.
File size: 3.0 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Functions for swapping drive letters.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; DriveXlate_ToOrBack
9;   Parameters:
10;       DL:     Drive number to be possibly translated
11;       DS:     RAMVARS segment
12;   Returns:
13;       DL:     Translated drive number
14;   Corrupts registers:
15;       DI
16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
18DriveXlate_ToOrBack:
19    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_DRVXLAT
20    jz      SHORT .Return           ; Return if translation disabled
21    xchg    di, ax                  ; Backup AX
22    call    SwapFloppyDriveOrHardDisk
23    xchg    ax, di
24.Return:
25    ret
26
27
28;--------------------------------------------------------------------
29; SwapFloppyDriveOrHardDisk
30;   Parameters:
31;       DL:     Drive number to be possibly swapped
32;       DS:     RAMVARS segment
33;   Returns:
34;       DL:     Translated drive number
35;   Corrupts registers:
36;       AX
37;--------------------------------------------------------------------
38ALIGN JUMP_ALIGN
39SwapFloppyDriveOrHardDisk:
40    mov     ah, 80h                 ; Assume hard disk
41    mov     al, BYTE [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
42    test    dl, ah                  ; Hard disk?
43    jnz     SHORT SwapDrive         ; If so, jump to swap
44    mov     al, BYTE [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
45    cbw
46    ; Fall to SwapDrive
47
48;--------------------------------------------------------------------
49; SwapDrive
50;   Parameters:
51;       AL:     Drive number to swap to 00h/80h
52;       AH:     00h/80h to be swapped to stored drive number
53;       DL:     Drive number to be possibly swapped
54;   Returns:
55;       DL:     Translated drive number
56;   Corrupts registers:
57;       Nothing
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
60SwapDrive:
61    cmp     ah, dl              ; Swap DL from 00h/80h to xxh?
62    je      SHORT .SwapToXXhInAL
63    cmp     al, dl              ; Swap DL from xxh to 00h/80h?
64    je      SHORT .SwapTo00hOr80hInAH
65    ret
66ALIGN JUMP_ALIGN
67.SwapTo00hOr80hInAH:
68    mov     dl, ah
69    ret
70ALIGN JUMP_ALIGN
71.SwapToXXhInAL:
72    mov     dl, al
73    ret
74
75
76;--------------------------------------------------------------------
77; Resets drive swapping variables to defaults (no swapping).
78;
79; DriveXlate_Reset
80;   Parameters:
81;       DS:     RAMVARS segment
82;   Returns:
83;       Nothing
84;   Corrupts registers:
85;       AX
86;--------------------------------------------------------------------
87ALIGN JUMP_ALIGN
88DriveXlate_Reset:
89    mov     WORD [RAMVARS.xlateVars], 8000h ; .bFDSwap and .bHDSwap
90    ret
91
92
93;--------------------------------------------------------------------
94; Stores drive to be swapped.
95;
96; DriveXlate_SetDriveToSwap
97;   Parameters:
98;       DL:     Drive to swap to 00h or 80h
99;       DS:     RAMVARS segment
100;   Returns:
101;       Nothing
102;   Corrupts registers:
103;       Nothing
104;--------------------------------------------------------------------
105ALIGN JUMP_ALIGN
106DriveXlate_SetDriveToSwap:
107    test    dl, dl              ; Floppy drive?
108    js      SHORT .SetHardDiskToSwap
109.SetFloppyDriveToSwap:
110    mov     [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
111    ret
112ALIGN JUMP_ALIGN
113.SetHardDiskToSwap:
114    mov     [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
115    ret
Note: See TracBrowser for help on using the repository browser.