Index: /trunk/Assembly_Library/Inc/BiosData.inc
===================================================================
--- /trunk/Assembly_Library/Inc/BiosData.inc	(revision 115)
+++ /trunk/Assembly_Library/Inc/BiosData.inc	(revision 116)
@@ -1,7 +1,3 @@
-; File name		:	BiosData.inc
-; Project name	:	IDE BIOS
-; Created date	:	28.7.2007
-; Last update	:	23.3.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Equates for BIOS Data Area.
 %ifndef BIOSDATA_INC
@@ -21,8 +17,8 @@
 	.wLPT1			resb	2		; 0:408h, Parallel I/O Address, Port 1
 	.wLPT2			resb	2		; 0:40Ah, Parallel I/O Address, Port 2
-	.wLPT3			resb	2		; 0:40Ch, Parallel I/O Address, Port 3					
+	.wLPT3			resb	2		; 0:40Ch, Parallel I/O Address, Port 3
 	.wLPT4:							; 0:40Eh, Parallel I/O Address, Port 4 (PC/XT)
 	.wSegEBDA		resb	2		; 0:40Eh, Extended BIOS Data Area segment (AT+)
-	
+
 	.wEquipment		resb	2		; 0:410h, Equipment Word
 	.bTest			resb	1		; 0:412h, Manufacturing test
@@ -36,8 +32,8 @@
 	.wKBTail		resb	2		; 0:41Ch, Keyboard, Tail of buffer pointer
 	.rgwKBBuff		resb	32		; 0:41Eh, Keyboard, 16-word buffer
-	
+
 	.bFDRecal		resb	1		; 0:43Eh, Diskette, Recalibrate status
 	.bFDMotor		resb	1		; 0:43Fh, Diskette, Motor status
-	
+
 	.bFDMotTime		resb	1		; 0:440h, Diskette, Motor timeout counter
 	.bFDRetST		resb	1		; 0:441h, Diskette, Controller status return code
@@ -47,7 +43,7 @@
 	.wVidBpP		resb	2		; 0:44Ch, Video, Total number of bytes per page
 	.wVidPageOff	resb	2		; 0:44Eh, Video, Current page offset
-	
+
 	.rgwVidCurPos	resb	16		; 0:450h, Video, Cursor position, pages 0...7
-	
+
 	.wVidCurShape	resb	2		; 0:460h, Video, Cursor shape
 	.bVidPageIdx	resb	1		; 0:462h, Video, Active display page
@@ -62,5 +58,5 @@
 	.bLastIRQ		resb	1		; 0:46Bh, Last interrupt that occurred (XT+)
 	.dwTimerTicks	resb	4		; 0:46Ch, Timer ticks count
-	
+
 	.bTimer24h		resb	1		; 0:470h, Timer ticks rollover flag
 	.bKBCtrlBrk		resb	1		; 0:471h, Keyboard, Ctrl+Break flag
@@ -68,5 +64,5 @@
 	.bHDLastSt		resb	1		; 0:474h, Hard Disk, Status of Last Operation (XT+)
 	.bHDCount		resb	1		; 0:475h, Hard Disk, Number of HDs Attached (XT+)
-	.bHDCtrl		resb	1		; 0:476h, Hard Disk, Control Byte (temp, XT+) 
+	.bHDCtrl		resb	1		; 0:476h, Hard Disk, Control Byte (temp, XT+)
 	.bHDPortOff		resb	1		; 0:477h, Hard Disk, Port Offset (XT)
 	.bLPT1Timeout	resb	1		; 0:478h, Parallel Printer 1, Timeout (XT+)
@@ -78,5 +74,5 @@
 	.bCOM3Timeout	resb	1		; 0:47Eh, Serial 3, Timeout (XT+)
 	.bCOM4Timeout	resb	1		; 0:47Fh, Serial 4, Timeout (XT+)
-	
+
 	.wKBPtrStart	resb	2		; 0:480h, Keyboard, Pointer to start of buffer (XT+)
 	.wKBPtrEnd		resb	2		; 0:482h, Keyboard, Pointer to end of buffer (XT+)
@@ -92,5 +88,5 @@
 	.bHDTaskFlg		resb	1		; 0:48Eh, Hard Disk, Task Complete Flag (AT+)
 	.bFDCtrlInfo	resb	1		; 0:48Fh, Diskette, Controller information (AT+)
-	
+
 	.bFDMedia0		resb	1		; 0:490h, Diskette 0, Media state (AT+)
 	.bFDMedia1		resb	1		; 0:491h, Diskette 1, Media state (AT+)
@@ -103,5 +99,5 @@
 	.dwWaitPtr		resb	4		; 0:498h, User's wait flag pointer (AT+)
 	.dwWaitCnt		resb	4		; 0:49Ch, User's wait count (AT+)
-	
+
 	.bWaitFlg		resb	1		; 0:4A0h, Wait flag (AT+)
 	.rgbLAN			resb	7		; 0:4A1h, Local Area Network (AT+)
@@ -133,8 +129,14 @@
 ; Load BDA (Bios Data Area) segment to wanted segment register.
 ;
+; Use an exclamation point (!) as the third parameter when you want
+; to force the use of the register in the second parameter. This is
+; useful when that register needs to be zeroed in subsequent code or
+; when stack usage is undesirable (ie speed is critical).
+;
 ; LOAD_BDA_SEGMENT_TO
 ;	Parameters:
 ;		%1:		Destination Segment Register
 ;		%2:		Temporary WORD Register
+;		%3:		Can be ! or empty
 ;	Returns:
 ;		%1:		BDA segment (zero)
@@ -142,7 +144,15 @@
 ;		%2
 ;--------------------------------------------------------------------
-%macro LOAD_BDA_SEGMENT_TO 2
+%macro LOAD_BDA_SEGMENT_TO 2-3
+%ifndef USE_186
 	xor		%2, %2
 	mov		%1, %2
+%elifidn %3, !
+	xor		%2, %2
+	mov		%1, %2
+%else
+	push	BYTE 0
+	pop		%1
+%endif
 %endmacro
 
Index: /trunk/Assembly_Library/Src/File/Directory.asm
===================================================================
--- /trunk/Assembly_Library/Src/File/Directory.asm	(revision 115)
+++ /trunk/Assembly_Library/Src/File/Directory.asm	(revision 116)
@@ -1,7 +1,3 @@
-; File name		:	Directory.asm
 ; Project name	:	Assembly Library
-; Created date	:	3.9.2010
-; Last update	:	6.9.2010
-; Author		:	Tomi Tilli
 ; Description	:	Functions for accessing directories.
 
@@ -70,6 +66,6 @@
 	push	dx
 
-	xor		dx, dx				; Default drive (00h)
-	mov		ah, GET_CURRENT_DIRECTORY
+	mov		ah, GET_CURRENT_DIRECTORY	; GET_CURRENT_DIRECTORY = 47h
+	cwd									; Default drive (00h)
 	int		DOS_INTERRUPT_21h
 
@@ -131,5 +127,5 @@
 ; Directory_UpdateDTAForNextMatchUsingPreviousParameters
 ;	Parameters:
-;		Nothing (Parameters from previous call to 
+;		Nothing (Parameters from previous call to
 ;				Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX are used)
 ;	Returns:
Index: /trunk/Assembly_Library/Src/Menu/MenuAttributes.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuAttributes.asm	(revision 115)
+++ /trunk/Assembly_Library/Src/Menu/MenuAttributes.asm	(revision 116)
@@ -48,5 +48,5 @@
 	push	ds
 
-	LOAD_BDA_SEGMENT_TO	ds, ax
+	LOAD_BDA_SEGMENT_TO	ds, ax, !
 	mov		al, [VIDEO_BDA.bMode]		; Load BIOS display mode (0, 1, 2, 3 or 7)
 	cmp		al, 7
@@ -73,5 +73,4 @@
 	pop		ds
 	ret
-
 
 
Index: /trunk/Assembly_Library/Src/Menu/MenuInit.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 115)
+++ /trunk/Assembly_Library/Src/Menu/MenuInit.asm	(revision 116)
@@ -19,5 +19,5 @@
 	push	es
 	push	ds
-	LOAD_BDA_SEGMENT_TO ds, cx
+	LOAD_BDA_SEGMENT_TO ds, cx, !
 	push	WORD [BDA.wVidCurShape]
 	mov		cl, MENU_size
@@ -74,5 +74,5 @@
 	call	MenuText_RefreshTitle			; Draw title strings
 	call	MenuText_RefreshAllItems		; Draw item strings
-	jmp		MenuText_RefreshInformation		; Draw information strings	
+	jmp		MenuText_RefreshInformation		; Draw information strings
 
 
Index: /trunk/Configurator/Inc/BiosData.inc
===================================================================
--- /trunk/Configurator/Inc/BiosData.inc	(revision 115)
+++ /trunk/Configurator/Inc/BiosData.inc	(revision 116)
@@ -1,7 +1,3 @@
-; File name		:	BiosData.inc
-; Project name	:	IDE BIOS
-; Created date	:	28.7.2007
-; Last update	:	23.3.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Equates for BIOS Data Area.
 %ifndef BIOSDATA_INC
@@ -21,8 +17,8 @@
 	.wLPT1			resb	2		; 0:408h, Parallel I/O Address, Port 1
 	.wLPT2			resb	2		; 0:40Ah, Parallel I/O Address, Port 2
-	.wLPT3			resb	2		; 0:40Ch, Parallel I/O Address, Port 3					
+	.wLPT3			resb	2		; 0:40Ch, Parallel I/O Address, Port 3
 	.wLPT4:							; 0:40Eh, Parallel I/O Address, Port 4 (PC/XT)
 	.wSegEBDA		resb	2		; 0:40Eh, Extended BIOS Data Area segment (AT+)
-	
+
 	.wEquipment		resb	2		; 0:410h, Equipment Word
 	.bTest			resb	1		; 0:412h, Manufacturing test
@@ -36,8 +32,8 @@
 	.wKBTail		resb	2		; 0:41Ch, Keyboard, Tail of buffer pointer
 	.rgwKBBuff		resb	32		; 0:41Eh, Keyboard, 16-word buffer
-	
+
 	.bFDRecal		resb	1		; 0:43Eh, Diskette, Recalibrate status
 	.bFDMotor		resb	1		; 0:43Fh, Diskette, Motor status
-	
+
 	.bFDMotTime		resb	1		; 0:440h, Diskette, Motor timeout counter
 	.bFDRetST		resb	1		; 0:441h, Diskette, Controller status return code
@@ -47,7 +43,7 @@
 	.wVidBpP		resb	2		; 0:44Ch, Video, Total number of bytes per page
 	.wVidPageOff	resb	2		; 0:44Eh, Video, Current page offset
-	
+
 	.rgwVidCurPos	resb	16		; 0:450h, Video, Cursor position, pages 0...7
-	
+
 	.wVidCurShape	resb	2		; 0:460h, Video, Cursor shape
 	.bVidPageIdx	resb	1		; 0:462h, Video, Active display page
@@ -62,5 +58,5 @@
 	.bLastIRQ		resb	1		; 0:46Bh, Last interrupt that occurred (XT+)
 	.dwTimerTicks	resb	4		; 0:46Ch, Timer ticks count
-	
+
 	.bTimer24h		resb	1		; 0:470h, Timer ticks rollover flag
 	.bKBCtrlBrk		resb	1		; 0:471h, Keyboard, Ctrl+Break flag
@@ -68,5 +64,5 @@
 	.bHDLastSt		resb	1		; 0:474h, Hard Disk, Status of Last Operation (XT+)
 	.bHDCount		resb	1		; 0:475h, Hard Disk, Number of HDs Attached (XT+)
-	.bHDCtrl		resb	1		; 0:476h, Hard Disk, Control Byte (temp, XT+) 
+	.bHDCtrl		resb	1		; 0:476h, Hard Disk, Control Byte (temp, XT+)
 	.bHDPortOff		resb	1		; 0:477h, Hard Disk, Port Offset (XT)
 	.bLPT1Timeout	resb	1		; 0:478h, Parallel Printer 1, Timeout (XT+)
@@ -78,5 +74,5 @@
 	.bCOM3Timeout	resb	1		; 0:47Eh, Serial 3, Timeout (XT+)
 	.bCOM4Timeout	resb	1		; 0:47Fh, Serial 4, Timeout (XT+)
-	
+
 	.wKBPtrStart	resb	2		; 0:480h, Keyboard, Pointer to start of buffer (XT+)
 	.wKBPtrEnd		resb	2		; 0:482h, Keyboard, Pointer to end of buffer (XT+)
@@ -92,5 +88,5 @@
 	.bHDTaskFlg		resb	1		; 0:48Eh, Hard Disk, Task Complete Flag (AT+)
 	.bFDCtrlInfo	resb	1		; 0:48Fh, Diskette, Controller information (AT+)
-	
+
 	.bFDMedia0		resb	1		; 0:490h, Diskette 0, Media state (AT+)
 	.bFDMedia1		resb	1		; 0:491h, Diskette 1, Media state (AT+)
@@ -103,5 +99,5 @@
 	.dwWaitPtr		resb	4		; 0:498h, User's wait flag pointer (AT+)
 	.dwWaitCnt		resb	4		; 0:49Ch, User's wait count (AT+)
-	
+
 	.bWaitFlg		resb	1		; 0:4A0h, Wait flag (AT+)
 	.rgbLAN			resb	7		; 0:4A1h, Local Area Network (AT+)
@@ -133,8 +129,14 @@
 ; Load BDA (Bios Data Area) segment to wanted segment register.
 ;
+; Use an exclamation point (!) as the third parameter when you want
+; to force the use of the register in the second parameter. This is
+; useful when that register needs to be zeroed in subsequent code or
+; when stack usage is undesirable (ie speed is critical).
+;
 ; LOAD_BDA_SEGMENT_TO
 ;	Parameters:
 ;		%1:		Destination Segment Register
 ;		%2:		Temporary WORD Register
+;		%3:		Can be ! or empty
 ;	Returns:
 ;		%1:		BDA segment (zero)
@@ -142,7 +144,15 @@
 ;		%2
 ;--------------------------------------------------------------------
-%macro LOAD_BDA_SEGMENT_TO 2
+%macro LOAD_BDA_SEGMENT_TO 2-3
+%ifndef USE_186
 	xor		%2, %2
 	mov		%1, %2
+%elifidn %3, !
+	xor		%2, %2
+	mov		%1, %2
+%else
+	push	BYTE 0
+	pop		%1
+%endif
 %endmacro
 
Index: unk/XTIDE_Universal_BIOS/Inc/BiosData.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/BiosData.inc	(revision 115)
+++ 	(revision )
@@ -1,150 +1,0 @@
-; File name		:	BiosData.inc
-; Project name	:	IDE BIOS
-; Created date	:	28.7.2007
-; Last update	:	23.3.2010
-; Author		:	Tomi Tilli
-; Description	:	Equates for BIOS Data Area.
-%ifndef BIOSDATA_INC
-%define BIOSDATA_INC
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; BIOS DATA AREA VARIABLES ;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-; BIOS Data Area (related to floppy drives and hard disks)
-struc BDA
-					resb	400h	; 40:0h, Start of BDA
-	.wCOM1			resb	2		; 0:400h, Serial I/O Address, Port 1
-	.wCOM2			resb	2		; 0:402h, Serial I/O Address, Port 2
-	.wCOM3			resb	2		; 0:404h, Serial I/O Address, Port 3
-	.wCOM4			resb	2		; 0:406h, Serial I/O Address, Port 4
-	.wLPT1			resb	2		; 0:408h, Parallel I/O Address, Port 1
-	.wLPT2			resb	2		; 0:40Ah, Parallel I/O Address, Port 2
-	.wLPT3			resb	2		; 0:40Ch, Parallel I/O Address, Port 3					
-	.wLPT4:							; 0:40Eh, Parallel I/O Address, Port 4 (PC/XT)
-	.wSegEBDA		resb	2		; 0:40Eh, Extended BIOS Data Area segment (AT+)
-	
-	.wEquipment		resb	2		; 0:410h, Equipment Word
-	.bTest			resb	1		; 0:412h, Manufacturing test
-	.wBaseMem		resb	2		; 0:413h, Base Memory Size in kB
-	.wAdptrMem:						; 0:415h, Adapter Memory Size (PC/XT)
-	.wError			resb	2		; 0:415h, Error Codes (AT+)
-	.bKBFlgs1		resb	1		; 0:417h, Keyboard, Shift Flags, Set 1
-	.bKBFlgs2		resb	1		; 0:418h, Keyboard, Shift Flags, Set 2
-	.bKBNumpad		resb	1		; 0:419h, Keyboard, ALT+Numpad work area
-	.wKBHead		resb	2		; 0:41Ah, Keyboard, Head of buffer pointer
-	.wKBTail		resb	2		; 0:41Ch, Keyboard, Tail of buffer pointer
-	.rgwKBBuff		resb	32		; 0:41Eh, Keyboard, 16-word buffer
-	
-	.bFDRecal		resb	1		; 0:43Eh, Diskette, Recalibrate status
-	.bFDMotor		resb	1		; 0:43Fh, Diskette, Motor status
-	
-	.bFDMotTime		resb	1		; 0:440h, Diskette, Motor timeout counter
-	.bFDRetST		resb	1		; 0:441h, Diskette, Controller status return code
-	.rgbFDStatus	resb	7		; 0:442h, Diskette, Diskette and Disk Controller status bytes
-	.bVidMode		resb	1		; 0:449h, Video, Mode
-	.wVidColumns	resb	2		; 0:44Ah, Video, Number of columns
-	.wVidBpP		resb	2		; 0:44Ch, Video, Total number of bytes per page
-	.wVidPageOff	resb	2		; 0:44Eh, Video, Current page offset
-	
-	.rgwVidCurPos	resb	16		; 0:450h, Video, Cursor position, pages 0...7
-	
-	.wVidCurShape	resb	2		; 0:460h, Video, Cursor shape
-	.bVidPageIdx	resb	1		; 0:462h, Video, Active display page
-	.wVidPort		resb	2		; 0:463h, Video, I/O Port number base
-	.bVidModeReg	resb	1		; 0:465h, Video, Internal mode register
-	.bVidPalette	resb	1		; 0:466h, Video, Color palette
-	.wCasTimeCnt:					; 0:467h, Cassette, Time count at data edge (PC)
-	.wGenOff		resb	2		; 0:467h, General use offset (XT+)
-	.wCasCRC:						; 0:469h, Cassette, CRC register (PC)
-	.wGenSeg		resb	2		; 0:469h, General use segment (XT+)
-	.bCasLast:						; 0:46Bh, Cassette, Last value read
-	.bLastIRQ		resb	1		; 0:46Bh, Last interrupt that occurred (XT+)
-	.dwTimerTicks	resb	4		; 0:46Ch, Timer ticks count
-	
-	.bTimer24h		resb	1		; 0:470h, Timer ticks rollover flag
-	.bKBCtrlBrk		resb	1		; 0:471h, Keyboard, Ctrl+Break flag
-	.wBoot			resb	2		; 0:472h, Warm boot flag
-	.bHDLastSt		resb	1		; 0:474h, Hard Disk, Status of Last Operation (XT+)
-	.bHDCount		resb	1		; 0:475h, Hard Disk, Number of HDs Attached (XT+)
-	.bHDCtrl		resb	1		; 0:476h, Hard Disk, Control Byte (temp, XT+) 
-	.bHDPortOff		resb	1		; 0:477h, Hard Disk, Port Offset (XT)
-	.bLPT1Timeout	resb	1		; 0:478h, Parallel Printer 1, Timeout (XT+)
-	.bLPT2Timeout	resb	1		; 0:479h, Parallel Printer 2, Timeout (XT+)
-	.bLPT3Timeout	resb	1		; 0:47Ah, Parallel Printer 3, Timeout (XT+)
-	.bLPT4Timeout	resb	1		; 0:47Bh, Parallel Printer 4, Timeout (XT+)
-	.bCOM1Timeout	resb	1		; 0:47Ch, Serial 1, Timeout (XT+)
-	.bCOM2Timeout	resb	1		; 0:47Dh, Serial 2, Timeout (XT+)
-	.bCOM3Timeout	resb	1		; 0:47Eh, Serial 3, Timeout (XT+)
-	.bCOM4Timeout	resb	1		; 0:47Fh, Serial 4, Timeout (XT+)
-	
-	.wKBPtrStart	resb	2		; 0:480h, Keyboard, Pointer to start of buffer (XT+)
-	.wKBPtrEnd		resb	2		; 0:482h, Keyboard, Pointer to end of buffer (XT+)
-	.bVidRows		resb	1		; 0:484h, Video, Number of rows (EGA+)
-	.wVidPpC		resb	2		; 0:485h, Video, Pixels per character (EGA+)
-	.bVidOptns		resb	1		; 0:487h, Video, Options (EGA+)
-	.bVidSwitches	resb	1		; 0:488h, Video, Switches (EGA+)
-	.bVidSave1		resb	1		; 0:489h, Video, Save area 1 (VGA+)
-	.bVidSave2		resb	1		; 0:48Ah, Video, Save area 2 (VGA+)
-	.bFDCfgData		resb	1		; 0:48Bh, Diskette, Configuration data (AT+)
-	.bHDStatus		resb	1		; 0:48Ch, Hard Disk, Status Register (AT+)
-	.bHDError		resb	1		; 0:48Dh, Hard Disk, Error Register (AT+)
-	.bHDTaskFlg		resb	1		; 0:48Eh, Hard Disk, Task Complete Flag (AT+)
-	.bFDCtrlInfo	resb	1		; 0:48Fh, Diskette, Controller information (AT+)
-	
-	.bFDMedia0		resb	1		; 0:490h, Diskette 0, Media state (AT+)
-	.bFDMedia1		resb	1		; 0:491h, Diskette 1, Media state (AT+)
-	.bFDOpStart0	resb	1		; 0:492h, Diskette 0, Operational starting state (AT+)
-	.bFDOpStart1	resb	1		; 0:493h, Diskette 1, Operational starting state (AT+)
-	.bFDCurCyl0		resb	1		; 0:494h, Diskette 0, Current cylinder (AT+)
-	.bFDCurCyl1		resb	1		; 0:495h, Diskette 1, Current cylinder (AT+)
-	.bKBFlgs3		resb	1		; 0:496h, Keyboard, Status flags 3 (AT+)
-	.bKBFlgs4		resb	1		; 0:497h, Keyboard, Status flags 4 (AT+)
-	.dwWaitPtr		resb	4		; 0:498h, User's wait flag pointer (AT+)
-	.dwWaitCnt		resb	4		; 0:49Ch, User's wait count (AT+)
-	
-	.bWaitFlg		resb	1		; 0:4A0h, Wait flag (AT+)
-	.rgbLAN			resb	7		; 0:4A1h, Local Area Network (AT+)
-	.dwVidPtr		resb	4		; 0:4A8h, Video, Parameter Control Block Pointer (EGA+)
-					resb	22h		; Reserved from 0:4ACh...0:4CDh
-
-	.dwDays			resb	4		; 0:4CEh, Clock, Days since 1980 (some BIOSes, AT+)
-					resb	2Eh		; Reserved from 0:4D2h...0:4FFh
-
-	.bPrntScrn		resb	1		; 0:500, Print screen status
-endstruc
-
-; BDA struct with only Hard Disk related locations
-struc HDBDA
-					resb	474h
-	.bHDLastSt		resb	1		; 0:474h, Status of Last Operation (XT+)
-	.bHDCount		resb	1		; 0:475h, Number of HDs Attached (XT+)
-	.bHDCtrl		resb	1		; 0:476h, Control Byte (temp, XT+)
-	.bHDPortOff		resb	1		; 0:477h, Port Offset (XT)
-					resb	15h
-	.bHDStatus:						; 0:48Ch, Status Register (AT+)
-	.bHDError:						; 0:48Dh, Error Register (AT+)
-	.wHDStAndErr	resb	2
-	.bHDTaskFlg		resb	1		; 0:48Eh, Task Complete Flag (AT+)
-endstruc
-
-
-;--------------------------------------------------------------------
-; Load BDA (Bios Data Area) segment to wanted segment register.
-;
-; LOAD_BDA_SEGMENT_TO
-;	Parameters:
-;		%1:		Destination Segment Register
-;		%2:		Temporary WORD Register
-;	Returns:
-;		%1:		BDA segment (zero)
-;	Corrupts registers:
-;		%2
-;--------------------------------------------------------------------
-%macro LOAD_BDA_SEGMENT_TO 2
-	xor		%2, %2
-	mov		%1, %2
-%endmacro
-
-
-%endif ; BIOSDATA_INC
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 116)
@@ -99,5 +99,5 @@
 	xchg	ax, bx		; Store BX to AX
 	eMOVZX	bx, BYTE [cs:si+IDEVARS.bBusType]
-	mov		bx, [cs:bx+.rgwBusTypeValues]	; Char to BL, Int to BH	
+	mov		bx, [cs:bx+.rgwBusTypeValues]	; Char to BL, Int to BH
 	eMOVZX	dx, bh
 	push	bx			; Push character
@@ -191,5 +191,5 @@
 	mov		dl, [di+DPT.bDrvNum]		; Load Drive number to DL
 	call	BootInfo_GetOffsetToBX		; ES:BX now points...
-	LOAD_BDA_SEGMENT_TO	es, ax			; ...to BOOTNFO
+	LOAD_BDA_SEGMENT_TO	es, ax, !		; ...to BOOTNFO
 	mov		al, [di+DPT.bIdeOff]
 	xchg	si, ax						; CS:SI now points to IDEVARS
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm	(revision 116)
@@ -28,4 +28,11 @@
 ; POST stack is not large enough when DPTs are stored to 30:0h.
 ;
+; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP
+; then you also have to unconditionally enable the CLI/STI pair.
+; The reason for this is that only some buggy 808x CPU:s need the
+; CLI/STI instruction pair when changing stacks. Other CPU:s disable
+; interrupts automatically when SS is modified for the duration of
+; the immediately following instruction to give time to change SP.
+;
 ; BootVars_SwitchToBootMenuStack
 ;	Parameters:
@@ -39,8 +46,12 @@
 BootVars_SwitchToBootMenuStack:
 	pop		ax							; Pop return address
+%ifndef USE_186
 	cli									; Disable interrupts
+%endif
 	LOAD_BDA_SEGMENT_TO	ss, sp
 	mov		sp, BOOTVARS.rgbMnuStack	; Load offset to stack
+%ifndef USE_186
 	sti									; Enable interrupts
+%endif
 	jmp		ax
 
@@ -48,4 +59,7 @@
 ;--------------------------------------------------------------------
 ; Restores SS and SP to initial boot loader values.
+;
+; Before doing any changes, see the note regarding
+; LOAD_BDA_SEGMENT_TO in BootVars_SwitchToBootMenuStack
 ;
 ; BootVars_SwitchBackToPostStack
@@ -60,5 +74,7 @@
 BootVars_SwitchBackToPostStack:
 	pop		ax							; Pop return address
+%ifndef USE_186
 	cli									; Disable interrupts
+%endif
 	LOAD_BDA_SEGMENT_TO	ss, sp
 %ifndef USE_386
@@ -68,4 +84,6 @@
 	lss		sp, [ss:BOOTVARS.dwPostStack]
 %endif
+%ifndef USE_186
 	sti									; Enable interrupts
+%endif
 	jmp		ax
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm	(revision 116)
@@ -1,7 +1,3 @@
-; File name		:	AH1h_HStatus.asm
-; Project name	:	IDE BIOS
-; Created date	:	27.9.2007
-; Last update	:	24.8.2010
-; Author		:	Tomi Tilli
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=1h, Read Disk Status.
 
@@ -30,7 +26,7 @@
 
 	LOAD_BDA_SEGMENT_TO	ds, di
-	xor		ah, ah					; Zero AH
-	cmp		ah, [BDA.bHDLastSt]		; Set CF if error code is non-zero
 	mov		ah, [BDA.bHDLastSt]		; Last error to AH
+	cmp		ah, 1					; Set CF if error code is zero
+	cmc								; Invert CF
 
 	pop		ds
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm	(revision 116)
@@ -108,5 +108,5 @@
 ;--------------------------------------------------------------------
 ; Returns timeout value for drive detection.
-; Long timeout is required for detecing first drive to make sure it is
+; Long timeout is required for detecting first drive to make sure it is
 ; ready after power-on (ATA specification says up to 31 seconds).
 ; Short timeout is used for additional drives to prevent long boot time
@@ -123,10 +123,9 @@
 ALIGN JUMP_ALIGN
 AH25h_GetDriveDetectionTimeoutValue:
+	mov		cl, B_TIMEOUT_RESET			; Load long timeout (assume first drive)
 	cmp		BYTE [RAMVARS.bDrvCnt], 0	; Detecting first drive?
-	je		SHORT .GetLongDelayForInitialDetection
+	je		SHORT .Return
 	mov		cl, B_TIMEOUT_DRVINFO		; Load short timeout
+ALIGN JUMP_ALIGN, ret	; This speed optimization may be unnecessary
+.Return:
 	ret
-ALIGN JUMP_ALIGN
-.GetLongDelayForInitialDetection:
-	mov		cl, B_TIMEOUT_RESET			; Load long timeout
-	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm	(revision 116)
@@ -1,8 +1,3 @@
-; File name		:	AHCh_HSeek.asm
-; Project name	:	IDE BIOS
-; Created date	:	13.12.2007
-; Last update	:	14.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Int 13h function AH=Ch, Seek.
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 116)
@@ -100,6 +100,5 @@
 	; HSR2: Check_status
 	mov		cl, B_TIMEOUT_RESET			; Reset timeout delay
-	mov		dx, [RAMVARS.wIdeBase]		; Load base port address
-	jmp		HStatus_WaitBsyBase
+	jmp		HStatus_WaitBsy
 
 
@@ -125,5 +124,4 @@
 	call	AH9h_InitializeDriveForUse
 	mov		cl, ah						; Copy error code to CL
-ALIGN JUMP_ALIGN
 .InitializeSlave:
 	pop		dx							; Restore base port address
@@ -132,11 +130,9 @@
 	call	AH9h_InitializeDriveForUse
 	mov		ch, ah						; Copy error code to CH
-ALIGN JUMP_ALIGN
 .CombineErrors:
 	or		cl, ch						; OR error codes, clear CF
-	jnz		SHORT .ReturnError
-	ret
-.ReturnError:
+	jz		SHORT .Return
 	mov		ah, RET_HD_RESETFAIL		; Load Reset Failed error code
 	stc
+.Return:
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm	(revision 116)
@@ -1,3 +1,3 @@
-; Project name	:	IDE BIOS
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	Interrupt handling related functions.
 
@@ -35,5 +35,5 @@
 	push	ds
 
-	LOAD_BDA_SEGMENT_TO	ds, ax			; Zero AX
+	LOAD_BDA_SEGMENT_TO	ds, ax, !		; Zero AX
 	cli									; Disable interrupts
 	cmp		al, [BDA.bHDTaskFlg]		; Task flag already set?
@@ -68,5 +68,5 @@
 HIRQ_ClearTaskFlag:
 	push	ds
-	LOAD_BDA_SEGMENT_TO	ds, ax		; Also zero AX
+	LOAD_BDA_SEGMENT_TO	ds, ax, !		; Also zero AX
 	mov		[BDA.bHDTaskFlg], al
 	pop		ds
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HPIO.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HPIO.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HPIO.asm	(revision 116)
@@ -1,3 +1,3 @@
-; Project name	:	IDE BIOS
+; Project name	:	XTIDE Universal BIOS
 ; Description	:	PIO transfer functions.
 
@@ -15,28 +15,4 @@
 
 ;--------------------------------------------------------------------
-; Normalizes far pointer to that offset overflows won't happen
-; when transferring data using PIO.
-;
-; HPIO_NORMALIZE_PTR
-;	Parameters:
-;		%1:%2:		Far pointer to normalize
-;		%3:			Scratch register
-;		%4:			Scratch register
-;	Returns:
-;		%1:%2:		Normalized far pointer
-;	Corrupts registers:
-;		%3, %4
-;--------------------------------------------------------------------
-%macro HPIO_NORMALIZE_PTR 4
-	mov		%4, %2				; Copy offset to scratch reg
-	and		%2, BYTE 0Fh		; Clear offset bits 15...4
-	eSHR_IM	%4, 4				; Divide offset by 16
-	mov		%3, %1				; Copy segment to scratch reg
-	add		%3, %4				; Add shifted offset to segment
-	mov		%1, %3				; Set normalized segment
-%endmacro
-
-
-;--------------------------------------------------------------------
 ; Reads sectors from hard disk using PIO transfer mode.
 ;
@@ -110,10 +86,11 @@
 	mov		[bp+PIOVARS.fnXfer], bx				; Store offset to transfer function
 	xchg	bx, ax
-	; Fall to HPIO_NormalizePtr
-
-;--------------------------------------------------------------------
-; Initializes PIOVARS members.
-;
-; HPIO_InitializePIOVARS
+	; Fall to HPIO_NormalizeDataPointer
+
+;--------------------------------------------------------------------
+; Normalizes far pointers so that offset overflows won't happen
+; when transferring data using PIO.
+;
+; HPIO_NormalizeDataPointer
 ;	Parameters:
 ;		ES:BX:	Ptr to source or destination data buffer
@@ -125,5 +102,5 @@
 ;ALIGN JUMP_ALIGN
 HPIO_NormalizeDataPointer:
-	HPIO_NORMALIZE_PTR	es, bx, ax, cx
+	NORMALIZE_FAR_POINTER es, bx, ax, cx
 	ret
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 116)
@@ -15,5 +15,4 @@
 ; Included .inc files
 %include "AssemblyLibrary.inc"	; Assembly Library. Must be included first!
-%include "BiosData.inc"			; For BIOS Data area equates
 %include "Interrupts.inc"		; For interrupt equates
 %include "ATA_ID.inc"			; For ATA Drive Information structs
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 115)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 116)
@@ -34,5 +34,5 @@
 	jz		SHORT .InitializeRamvars	; No need to steal RAM
 
-	LOAD_BDA_SEGMENT_TO	ds, ax			; Zero AX
+	LOAD_BDA_SEGMENT_TO	ds, ax, !		; Zero AX
 	mov		al, [cs:ROMVARS.bStealSize]
 	sub		[BDA.wBaseMem], ax
@@ -197,5 +197,5 @@
 ;	Corrupts registers:
 ;		Nothing
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 RamVars_GetHardDiskCountFromBDAtoCX:
@@ -203,5 +203,5 @@
 	push	dx
 
-	LOAD_BDA_SEGMENT_TO	es, cx			; Zero CX
+	LOAD_BDA_SEGMENT_TO	es, cx, !		; Zero CX
 	call	RamVars_GetCountOfKnownDrivesToDL
 	MAX_U	dl, [es:BDA.bHDCount]
@@ -220,5 +220,5 @@
 ;	Corrupts registers:
 ;		Nothing
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 RamVars_GetCountOfKnownDrivesToDL:
@@ -237,5 +237,5 @@
 ;	Corrupts registers:
 ;		Nothing
-;--------------------------------------------------------------------	
+;--------------------------------------------------------------------
 RamVars_GetIdeControllerCountToCX:
 	eMOVZX	cx, BYTE [cs:ROMVARS.bIdeCnt]
