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

Last change on this file since 230 was 181, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Size optimizations.
  • Added a define (EXCLUDE_FROM_XTIDECFG) to exclude unused library code from XTIDECFG.
  • Tried to minimize time spent with interrupts disabled.
  • Some minor attempts to improve speed (reordering instructions etc).
  • Tried to improve readability, did some cleanup and fixed some errors in comments.
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; AL
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 jne SHORT .Return
65 mov al, ah
66ALIGN JUMP_ALIGN
67.SwapToXXhInAL:
68 mov dl, al
69ALIGN JUMP_ALIGN, ret
70.Return:
71 ret
72
73
74;--------------------------------------------------------------------
75; Resets drive swapping variables to defaults (no swapping).
76;
77; DriveXlate_Reset
78; Parameters:
79; DS: RAMVARS segment
80; Returns:
81; Nothing
82; Corrupts registers:
83; Nothing
84;--------------------------------------------------------------------
85ALIGN JUMP_ALIGN
86DriveXlate_Reset:
87 mov WORD [RAMVARS.xlateVars], 8000h ; .bFDSwap and .bHDSwap
88 ret
89
90
91;--------------------------------------------------------------------
92; Stores drive to be swapped.
93;
94; DriveXlate_SetDriveToSwap
95; Parameters:
96; DL: Drive to swap to 00h or 80h
97; DS: RAMVARS segment
98; Returns:
99; Nothing
100; Corrupts registers:
101; Nothing
102;--------------------------------------------------------------------
103ALIGN JUMP_ALIGN
104DriveXlate_SetDriveToSwap:
105 test dl, dl ; Floppy drive?
106 js SHORT .SetHardDiskToSwap
107.SetFloppyDriveToSwap:
108 mov [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
109 ret
110ALIGN JUMP_ALIGN
111.SetHardDiskToSwap:
112 mov [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
113 ret
Note: See TracBrowser for help on using the repository browser.