Index: /trunk/Assembly_Library/Inc/Emulate.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Emulate.inc	(revision 180)
+++ /trunk/Assembly_Library/Inc/Emulate.inc	(revision 181)
@@ -452,5 +452,6 @@
 		times %2	%3		%1, 1
 	%else
-		%if %2 > 7
+;		%if %2 > 7	; Original value
+		%if %2 > 3	; Size optimized value
 			push	cx
 			mov		cl, %2
Index: /trunk/Assembly_Library/Inc/Math.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Math.inc	(revision 180)
+++ /trunk/Assembly_Library/Inc/Math.inc	(revision 181)
@@ -43,5 +43,5 @@
 ;		%2:		Operand 2
 ;	Returns:
-;		%1:		Lesser operand
+;		%1:		Greater operand
 ;	Corrupts registers:
 ;		Nothing
Index: /trunk/Assembly_Library/Src/Display/Display.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/Display.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Display/Display.asm	(revision 181)
@@ -57,38 +57,38 @@
 	jmp		ax
 
-		
-%define InitializeDisplayContext						DisplayContext_Initialize
+
+	%define InitializeDisplayContext						DisplayContext_Initialize
 
 %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
-%define SetCharacterPointerFromBXAX						DisplayContext_SetCharacterPointerFromBXAX
+	%define SetCharacterPointerFromBXAX						DisplayContext_SetCharacterPointerFromBXAX
 %endif
-%define SetCharOutputFunctionFromAXwithAttribFlagInBL	DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
-%define SetCharacterOutputParameterFromAX				DisplayContext_SetCharacterOutputParameterFromAX
-%define SetCharacterAttributeFromAL						DisplayContext_SetCharacterAttributeFromAL
-%define SetCursorShapeFromAX							DisplayCursor_SetShapeFromAX
-%define SetCursorCoordinatesFromAX						DisplayCursor_SetCoordinatesFromAX
-%define SetNewPageFromAL								DisplayPage_SetFromAL
-%define SynchronizeDisplayContextToHardware				DisplayContext_SynchronizeToHardware
+	%define SetCharOutputFunctionFromAXwithAttribFlagInBL	DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
+	%define SetCharacterOutputParameterFromAX				DisplayContext_SetCharacterOutputParameterFromAX
+	%define SetCharacterAttributeFromAL						DisplayContext_SetCharacterAttributeFromAL
+	%define SetCursorShapeFromAX							DisplayCursor_SetShapeFromAX
+	%define SetCursorCoordinatesFromAX						DisplayCursor_SetCoordinatesFromAX
+	%define SetNewPageFromAL								DisplayPage_SetFromAL
+	%define SynchronizeDisplayContextToHardware				DisplayContext_SynchronizeToHardware
 
 %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
-%define GetCharacterPointerToBXAX						DisplayContext_GetCharacterPointerToBXAX
+	%define GetCharacterPointerToBXAX						DisplayContext_GetCharacterPointerToBXAX
 %endif
-%define GetSoftwareCoordinatesToAX						DisplayCursor_GetSoftwareCoordinatesToAX
-%define GetColumnsToALandRowsToAH						DisplayPage_GetColumnsToALandRowsToAH
+	%define GetSoftwareCoordinatesToAX						DisplayCursor_GetSoftwareCoordinatesToAX
+	%define GetColumnsToALandRowsToAH						DisplayPage_GetColumnsToALandRowsToAH
 
-%define FormatNullTerminatedStringFromCSSI				Display_FormatNullTerminatedStringFromCSSI
+	%define FormatNullTerminatedStringFromCSSI				Display_FormatNullTerminatedStringFromCSSI
 %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
-%define PrintSignedWordFromAXWithBaseInBX				DisplayPrint_SignedWordFromAXWithBaseInBX
+	%define PrintSignedWordFromAXWithBaseInBX				DisplayPrint_SignedWordFromAXWithBaseInBX
 %endif
-%define PrintWordFromAXwithBaseInBX						DisplayPrint_WordFromAXWithBaseInBX
-%define PrintCharBufferFromBXSIwithLengthInCX			DisplayPrint_CharacterBufferFromBXSIwithLengthInCX
-%define PrintNullTerminatedStringFromBXSI				DisplayPrint_NullTerminatedStringFromBXSI
-%define PrintNullTerminatedStringFromCSSI				DisplayPrint_NullTerminatedStringFromCSSI
-%define PrintRepeatedCharacterFromALwithCountInCX		DisplayPrint_RepeatCharacterFromALwithCountInCX
-%define PrintCharacterFromAL							DisplayPrint_CharacterFromAL
-%define PrintNewlineCharacters							DisplayPrint_Newline
+	%define PrintWordFromAXwithBaseInBX						DisplayPrint_WordFromAXWithBaseInBX
+	%define PrintCharBufferFromBXSIwithLengthInCX			DisplayPrint_CharacterBufferFromBXSIwithLengthInCX
+	%define PrintNullTerminatedStringFromBXSI				DisplayPrint_NullTerminatedStringFromBXSI
+	%define PrintNullTerminatedStringFromCSSI				DisplayPrint_NullTerminatedStringFromCSSI
+	%define PrintRepeatedCharacterFromALwithCountInCX		DisplayPrint_RepeatCharacterFromALwithCountInCX
+	%define PrintCharacterFromAL							DisplayPrint_CharacterFromAL
+	%define PrintNewlineCharacters							DisplayPrint_Newline
 %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
-%define ClearAreaWithHeightInAHandWidthInAL				DisplayPrint_ClearAreaWithHeightInAHandWidthInAL
+	%define ClearAreaWithHeightInAHandWidthInAL				DisplayPrint_ClearAreaWithHeightInAHandWidthInAL
 %endif
-%define ClearScreenWithCharInALandAttrInAH				DisplayPrint_ClearScreenWithCharInALandAttributeInAH
+	%define ClearScreenWithCharInALandAttrInAH				DisplayPrint_ClearScreenWithCharInALandAttributeInAH
 
Index: /trunk/Assembly_Library/Src/Display/DisplayContext.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Display/DisplayContext.asm	(revision 181)
@@ -268,10 +268,10 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-;%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS	; This appears to be completely unused
-;ALIGN JUMP_ALIGN
-;DisplayContext_GetCharacterOutputParameterToDX:
-;	mov		dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam]
-;	ret
-;%endif
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG	; This is currently unused (dead code)
+ALIGN JUMP_ALIGN
+DisplayContext_GetCharacterOutputParameterToDX:
+	mov		dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam]
+	ret
+%endif
 
 
Index: /trunk/Assembly_Library/Src/Display/DisplayFormat.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/DisplayFormat.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Display/DisplayFormat.asm	(revision 181)
@@ -52,6 +52,6 @@
 	dec		bp
 	dec		bp				; SS:BP now points to next parameter
-	test	cx, cx
-	jnz		SHORT PrependOrAppendSpaces
+	inc		cx
+	loop	PrependOrAppendSpaces
 ReturnFromFormat:
 	ret
Index: /trunk/Assembly_Library/Src/Display/DisplayPrint.asm
===================================================================
--- /trunk/Assembly_Library/Src/Display/DisplayPrint.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Display/DisplayPrint.asm	(revision 181)
@@ -158,5 +158,5 @@
 	loop	.PrintNextCharacter
 
-	mov		ds, cx	; Restore DS to BDA. Not needed unless DisplayPrint_CharacterFromAL changes DS.
+	;mov		ds, cx	; Restore DS to BDA. Not needed unless DisplayPrint_CharacterFromAL changes DS.
 	pop		cx
 	pop		si
@@ -304,5 +304,5 @@
 ;		DI:		Updated offset to video RAM
 ;	Corrupts registers:
-;		AX, DX
+;		DX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
Index: /trunk/Assembly_Library/Src/File/Drive.asm
===================================================================
--- /trunk/Assembly_Library/Src/File/Drive.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/File/Drive.asm	(revision 181)
@@ -72,5 +72,9 @@
 	call	Drive_SetDefaultFromDL
 	eMOVZX	cx, al			; Number of potentially valid drive letters available
-	MIN_U	cx, 32
+	cmp		cl, 32
+	jb		SHORT .Return
+	mov		cl, 32
+ALIGN JUMP_ALIGN, ret
+.Return:
 	ret
 
Index: /trunk/Assembly_Library/Src/Menu/CharOutLineSplitter.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/CharOutLineSplitter.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Menu/CharOutLineSplitter.asm	(revision 181)
@@ -104,5 +104,5 @@
 ;--------------------------------------------------------------------
 .GetOffsetToPartialWordToSIandSizeToCX:
-	xor		cx, cx
+	mov		cx, di
 	mov		si, di
 ALIGN JUMP_ALIGN
@@ -111,12 +111,8 @@
 	dec		si
 	cmp		BYTE [es:si], ' '
-	je		SHORT .PartialWordFound
-	inc		cx
-	jmp		SHORT .ScanNextCharacter
-ALIGN JUMP_ALIGN
-.PartialWordFound:
+	jne		SHORT .ScanNextCharacter
 	inc		si
 	inc		si			; SI now points one past space
-	shl		cx, 1		; Characters to bytes
+	sub		cx, si
 	; Fall to .ChangeLine
 
Index: /trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm	(revision 181)
@@ -127,4 +127,5 @@
 	ret
 
+
 ;--------------------------------------------------------------------
 ; .GetWidthBasedOnParentMenuToAL
@@ -141,6 +142,11 @@
 	mov		al, [ss:bx+MENUINIT.bWidth]
 	sub		al, DIALOG_DELTA_WIDTH_FROM_PARENT
-	MIN_U	al, DIALOG_MAX_WIDTH
-	ret
+	cmp		al, DIALOG_MAX_WIDTH
+	jb		.ALlessThanDIALOG_MAX_WIDTH
+	mov		al, DIALOG_MAX_WIDTH
+ALIGN JUMP_ALIGN, ret
+.ALlessThanDIALOG_MAX_WIDTH:
+	ret
+
 
 ;--------------------------------------------------------------------
@@ -161,6 +167,14 @@
 	add		ah, [bp+MENUINIT.bInfoLines]
 	add		ah, BYTE MENU_VERTICAL_BORDER_LINES
-	MIN_U	ah, bh
-	MIN_U	ah, DIALOG_MAX_HEIGHT
+	cmp		ah, bh
+	jb		.AHlessThanBH
+	xchg	bx, ax
+ALIGN JUMP_ALIGN
+.AHlessThanBH:
+	cmp		ah, DIALOG_MAX_HEIGHT
+	jb		.AHlessThanDIALOG_MAX_HEIGHT
+	mov		ah, DIALOG_MAX_HEIGHT
+ALIGN JUMP_ALIGN, ret
+.AHlessThanDIALOG_MAX_HEIGHT:
 	ret
 
Index: /trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 181)
@@ -265,5 +265,5 @@
 .FilterCurrentDirectory:
 	cmp		WORD [si+DTA.szFile], CURRENTDIR_CHARACTERS
-	je		SHORT .ReturnWithFiltering
+	je		SHORT .DoFilter
 	ret
 
@@ -274,5 +274,5 @@
 	cmp		WORD [si+DTA.szFile], UPDIR_CHARACTERS
 	jne		SHORT .ReturnWithoutFiltering
-.ReturnWithFiltering:
+.DoFilter:
 	add		sp, BYTE 2		; Remove return address from stack
 ALIGN JUMP_ALIGN, ret
@@ -375,16 +375,15 @@
 SortDirectoryContentsStringFromESDIwithCountInCX:
 	call	Registers_CopyESDItoDSSI
-	call	.AddDirectoryContentsStringLengthToDI
-	mov		bx, .FileStringComparator
-	xchg	dx, cx
-	mov		cx, FILE_STRING_LENGTH
-	jmp		Sort_ItemsFromDSSIwithCountInDXsizeInCXandComparatorInBX
-
-ALIGN JUMP_ALIGN
-.AddDirectoryContentsStringLengthToDI:
+
+	; Add directory contents string length to DI
 	mov		ax, FILE_STRING_LENGTH
+	push	ax
 	mul		cx
 	add		di, ax
-	ret
+
+	mov		dx, cx
+	pop		cx
+	mov		bx, .FileStringComparator
+	jmp		Sort_ItemsFromDSSIwithCountInDXsizeInCXandComparatorInBX
 
 ;--------------------------------------------------------------------
@@ -395,5 +394,5 @@
 ;		ES:DI:	Ptr to second item to compare
 ;	Returns:
-;		FLAGS:	Signed comparition between first and second item
+;		FLAGS:	Signed comparison between first and second item
 ;	Corrupts registers:
 ;		Nothing
Index: /trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm	(revision 181)
@@ -1,7 +1,3 @@
-; File name		:	DialogProgress.asm
 ; Project name	:	Assembly Library
-; Created date	:	15.8.2010
-; Last update	:	10.12.2010
-; Author		:	Tomi Tilli
 ; Description	:	Displays progress bar dialog and starts progress task.
 
@@ -41,8 +37,10 @@
 	lds		si, [bp+DIALOG.fpDialogIO]
 	mov		bx, [si+PROGRESS_DIALOG_IO.wMaxProgressValue]
-	MIN_U	ax, bx
-	cmp		ax, bx	; Make sure that last progress character is shown
-	je		SHORT .UpdateProgressBar
-
+	cmp		ax, bx
+	jb		SHORT .AXlessThanBX
+	mov		ax, bx
+	jmp		SHORT .UpdateProgressBar
+ALIGN JUMP_ALIGN
+.AXlessThanBX:
 	mov		bx, ax
 	sub		bx, [si+PROGRESS_DIALOG_IO.wCurrentProgressValue]
@@ -172,26 +170,5 @@
 ALIGN JUMP_ALIGN
 DrawProgressBarFromDialogIoInDSSI:
-	call	.GetFullCharsToCXandEmptyCharsToDXwithDialogIoInDSSI
-
-	mov		al, PROGRESS_COMPLETE_CHARACTER
-	call	.RepeatProgressCharacterCXtimesFromAL
-
-	mov		cx, dx
-	mov		al, PROGRESS_INCOMPLETE_CHARACTER
-	jmp		SHORT .RepeatProgressCharacterCXtimesFromAL
-
-;--------------------------------------------------------------------
-; .GetFullCharsToCXandEmptyCharsToDXwithDialogIoInDSSI
-;	Parameters:
-;		DS:SI:	Ptr to PROGRESS_DIALOG_IO
-;		SS:BP:	Ptr to DIALOG
-;	Returns:
-;		CX:		Number of full progress bar characters
-;		DX:		Number of empty progress bar characters
-;	Corrupts:
-;		AX, BX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.GetFullCharsToCXandEmptyCharsToDXwithDialogIoInDSSI:
+	; Get full chars to CX and empty chars to DX
 	call	MenuLocation_GetMaxTextLineLengthToAX
 	mov		cx, ax
@@ -200,8 +177,13 @@
 	div		bx
 	xchg	cx, ax		; AX = Text line length, CX = Number of full chars
-
 	sub		ax, cx
 	xchg	dx, ax		; DX = Number of empty chars
-	ret
+
+	mov		al, PROGRESS_COMPLETE_CHARACTER
+	call	.RepeatProgressCharacterCXtimesFromAL
+
+	mov		cx, dx
+	mov		al, PROGRESS_INCOMPLETE_CHARACTER
+	; Fall to .RepeatProgressCharacterCXtimesFromAL
 
 ;--------------------------------------------------------------------
@@ -239,5 +221,5 @@
 	ret
 
-	
+
 ;--------------------------------------------------------------------
 ; DrawTimeElapsedFromDX
@@ -286,8 +268,8 @@
 
 	sub		cx, [si+PROGRESS_DIALOG_IO.wMinProgressValue]
-	jcxz	.PreventDivisionByZero
+	jz		SHORT .PreventDivisionByZero
 	div		cx			; AX = Estimated ticks left
 	xchg	dx, ax
-	jmp		SHORT FormatTicksFromDX
+	SKIP2B	f	; cmp ax, <next instruction>
 .PreventDivisionByZero:
 	xor		dx, dx
Index: /trunk/Assembly_Library/Src/Menu/Dialog/ItemLineSplitter.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Dialog/ItemLineSplitter.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Menu/Dialog/ItemLineSplitter.asm	(revision 181)
@@ -115,8 +115,7 @@
 ALIGN JUMP_ALIGN
 .CheckLineLength:
-	cmp		cx, [bp+ITEM_LINE_SPLITTER.wMaxTextLineLength]
-	ja		SHORT .ChangeToNextLine
-	clc
-	ret
+	cmp		[bp+ITEM_LINE_SPLITTER.wMaxTextLineLength], cx
+	jb		SHORT .ChangeToNextLine
+	ret		; With CF cleared
 
 ALIGN JUMP_ALIGN
Index: /trunk/Assembly_Library/Src/Menu/Menu.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Menu.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Menu/Menu.asm	(revision 181)
@@ -31,35 +31,35 @@
 
 
-%define DisplayWithHandlerInBXandUserDataInDXAX		MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX
-;%define Close										MenuInit_CloseMenuWindow				; Special case in CALL_MENU_LIBRARY
-%define RefreshWindow						MenuInit_RefreshMenuWindow
+	%define DisplayWithHandlerInBXandUserDataInDXAX			MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX
+	;%define Close											MenuInit_CloseMenuWindow				; Special case in CALL_MENU_LIBRARY
+	%define RefreshWindow									MenuInit_RefreshMenuWindow
 
-;%define SetUserDataFromDSSI				MenuInit_SetUserDataFromDSSI			; Special case in CALL_MENU_LIBRARY
-;%define GetUserDataToDSSI					MenuInit_GetUserDataToDSSI				; Special case in CALL_MENU_LIBRARY
+	;%define SetUserDataFromDSSI							MenuInit_SetUserDataFromDSSI			; Special case in CALL_MENU_LIBRARY
+	;%define GetUserDataToDSSI								MenuInit_GetUserDataToDSSI				; Special case in CALL_MENU_LIBRARY
 
-;%define SetTitleHeightFromAL				MenuInit_SetTitleHeightFromAL			; Special case in CALL_MENU_LIBRARY
-%define ClearTitleArea						MenuText_ClearTitleArea
-%define RefreshTitle						MenuText_RefreshTitle
+	;%define SetTitleHeightFromAL							MenuInit_SetTitleHeightFromAL			; Special case in CALL_MENU_LIBRARY
+	%define ClearTitleArea									MenuText_ClearTitleArea
+	%define RefreshTitle									MenuText_RefreshTitle
 
-%define HighlightItemFromAX					MenuInit_HighlightItemFromAX
-;%define SetTotalItemsFromAX				MenuInit_SetTotalItemsFromAX			; Special case in CALL_MENU_LIBRARY
-%define RefreshItemFromAX					MenuText_RefreshItemFromAX
+	%define HighlightItemFromAX								MenuInit_HighlightItemFromAX
+	;%define SetTotalItemsFromAX							MenuInit_SetTotalItemsFromAX			; Special case in CALL_MENU_LIBRARY
+	%define RefreshItemFromAX								MenuText_RefreshItemFromAX
 
-;%define SetInformationHeightFromAL						MenuInit_SetInformationHeightFromAL		; Special case in CALL_MENU_LIBRARY
-%define ClearInformationArea							MenuText_ClearInformationArea
-%define RefreshInformation								MenuText_RefreshInformation
+	;%define SetInformationHeightFromAL						MenuInit_SetInformationHeightFromAL		; Special case in CALL_MENU_LIBRARY
+	%define ClearInformationArea							MenuText_ClearInformationArea
+	%define RefreshInformation								MenuText_RefreshInformation
 
-%define StartSelectionTimeoutWithTicksInAX				MenuTime_StartSelectionTimeoutWithTicksInAX
+	%define StartSelectionTimeoutWithTicksInAX				MenuTime_StartSelectionTimeoutWithTicksInAX
 
 %ifdef INCLUDE_MENU_DIALOGS
-%define StartProgressTaskWithIoInDSSIandParamInDXAX		DialogProgress_StartProgressTaskWithIoInDSSIandParamInDXAX
-%define SetProgressValueFromAX							DialogProgress_SetProgressValueFromAX
+	%define StartProgressTaskWithIoInDSSIandParamInDXAX		DialogProgress_StartProgressTaskWithIoInDSSIandParamInDXAX
+	%define SetProgressValueFromAX							DialogProgress_SetProgressValueFromAX
 
-%define DisplayMessageWithInputInDSSI					DialogMessage_DisplayMessageWithInputInDSSI
-%define GetSelectionToAXwithInputInDSSI					DialogSelection_GetSelectionToAXwithInputInDSSI
-%define GetWordWithIoInDSSI								DialogWord_GetWordWithIoInDSSI
-%define GetStringWithIoInDSSI							DialogString_GetStringWithIoInDSSI
-%define GetFileNameWithIoInDSSI							DialogFile_GetFileNameWithIoInDSSI
-%define GetDriveWithIoInDSSI							DialogDrive_GetDriveWithIoInDSSI
+	%define DisplayMessageWithInputInDSSI					DialogMessage_DisplayMessageWithInputInDSSI
+	%define GetSelectionToAXwithInputInDSSI					DialogSelection_GetSelectionToAXwithInputInDSSI
+	%define GetWordWithIoInDSSI								DialogWord_GetWordWithIoInDSSI
+	%define GetStringWithIoInDSSI							DialogString_GetStringWithIoInDSSI
+	%define GetFileNameWithIoInDSSI							DialogFile_GetFileNameWithIoInDSSI
+	%define GetDriveWithIoInDSSI							DialogDrive_GetDriveWithIoInDSSI
 %endif
 
Index: /trunk/Assembly_Library/Src/Menu/MenuLocation.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuLocation.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Menu/MenuLocation.asm	(revision 181)
@@ -4,26 +4,4 @@
 ; Section containing code
 SECTION .text
-
-;--------------------------------------------------------------------
-; MenuLocation_GetTitleTextTopLeftCoordinatesToAX
-; MenuLocation_GetInformationTextTopLeftCoordinatesToAX
-;	Parameters
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		AL:		Column (X)
-;		AH:		Row (Y)
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-MenuLocation_GetTitleTextTopLeftCoordinatesToAX:
-	mov		ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
-	jmp		SHORT MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
-
-ALIGN JUMP_ALIGN
-MenuLocation_GetInformationTextTopLeftCoordinatesToAX:
-	mov		ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
-	jmp		SHORT AddInformationBordersTopLeftCoordinatesToAX
-
 
 ;--------------------------------------------------------------------
@@ -43,10 +21,12 @@
 	xchg	al, ah								; Line to AH, clear AL
 	add		ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
-	jmp		SHORT AddItemBordersTopLeftCoordinatesToAX
-
+	SKIP2B	f	; cmp ax, <next instruction>
+	; Fall to MenuLocation_GetItemBordersTopLeftCoordinatesToAX
 
 ;--------------------------------------------------------------------
+; MenuLocation_GetItemBordersTopLeftCoordinatesToAX
+; MenuLocation_GetTitleTextTopLeftCoordinatesToAX
 ; MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
-; MenuLocation_GetItemBordersTopLeftCoordinatesToAX
+; MenuLocation_GetInformationTextTopLeftCoordinatesToAX
 ; MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
 ;	Parameters
@@ -58,5 +38,12 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+MenuLocation_GetItemBordersTopLeftCoordinatesToAX:
+	xor		ax, ax
+	jmp		SHORT AddItemBordersTopLeftCoordinatesToAX
+
 ALIGN JUMP_ALIGN
+MenuLocation_GetTitleTextTopLeftCoordinatesToAX:
+	mov		ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
+	SKIP2B	f	; cmp ax, <next instruction>
 MenuLocation_GetTitleBordersTopLeftCoordinatesToAX:
 	xor		ax, ax
@@ -64,7 +51,7 @@
 
 ALIGN JUMP_ALIGN
-MenuLocation_GetItemBordersTopLeftCoordinatesToAX:
-	xor		ax, ax
-	jmp		SHORT AddItemBordersTopLeftCoordinatesToAX
+MenuLocation_GetInformationTextTopLeftCoordinatesToAX:
+	mov		ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
+	jmp		SHORT AddInformationBordersTopLeftCoordinatesToAX
 
 ALIGN JUMP_ALIGN
Index: /trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm	(revision 181)
@@ -37,15 +37,19 @@
 MenuScrollbars_GetScrollCharacterToALForLineInDI:
 	call	MenuScrollbars_GetMaxVisibleItemsOnPageToCX
-	call	.GetFirstThumbLineToAX
+	; Get first thumb line to AX
+	mov		ax, [bp+MENU.wFirstVisibleItem]
+	call	.CalculateFirstOrLastThumbLineToAX
+
 	cmp		di, ax				; Before first thumb line?
 	jb		SHORT .ReturnTrackCharacter
 	call	.GetLastThumbLineToAX
-	cmp		di, ax				; After last thumb line?
-	ja		SHORT .ReturnTrackCharacter
-	mov		al, SCROLL_THUMB_CHARACTER
-	ret
+	cmp		ax, di				; After last thumb line?
 ALIGN JUMP_ALIGN
 .ReturnTrackCharacter:
 	mov		al, SCROLL_TRACK_CHARACTER
+	jb		SHORT .Return
+	mov		al, SCROLL_THUMB_CHARACTER
+ALIGN JUMP_ALIGN, ret
+.Return:
 	ret
 
@@ -63,9 +67,10 @@
 .GetLastThumbLineToAX:
 	call	MenuScrollbars_GetLastVisibleItemOnPageToAX
-	jmp		SHORT .CalculateFirstOrLastThumbLineToAX
-
-;--------------------------------------------------------------------
-; .GetFirstThumbLineToAX
-;	Parameters
+	; Fall to .CalculateFirstOrLastThumbLineToAX
+
+;--------------------------------------------------------------------
+; .CalculateFirstOrLastThumbLineToAX
+;	Parameters
+;		AX:		Index of first or last visible item on page
 ;		CX:		Max visible items on page
 ;		SS:BP:	Ptr to MENU
@@ -76,6 +81,4 @@
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-.GetFirstThumbLineToAX:
-	mov		ax, [bp+MENU.wFirstVisibleItem]
 .CalculateFirstOrLastThumbLineToAX:
 	mul		cx
@@ -98,5 +101,26 @@
 	mov		cx, [bp+MENUINIT.wHighlightedItem]
 	add		cx, ax
-	call	.RotateItemInCX
+	; Fall to .RotateItemInCX
+
+;--------------------------------------------------------------------
+; .RotateItemInCX
+;	Parameters
+;		CX:		Possibly under of overflown item to be rotated
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		CX:		Valid item index
+;	Corrupts registers:
+;		DX
+;--------------------------------------------------------------------
+;.RotateItemInCX:
+	mov		dx, [bp+MENUINIT.wItems]
+	test	cx, cx
+	js		SHORT .RotateNegativeItemInCX
+	sub		cx, dx
+	jae		SHORT .ScrollPageForNewItemInCX
+
+ALIGN JUMP_ALIGN
+.RotateNegativeItemInCX:
+	add		cx, dx
 	; Fall to .ScrollPageForNewItemInCX
 
@@ -111,4 +135,5 @@
 ;		AX, BX, CX, DX, SI, DI
 ;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
 .ScrollPageForNewItemInCX:
 	call	MenuScrollbars_IsItemInCXonVisiblePage
@@ -117,8 +142,24 @@
 	mov		dx, [bp+MENU.wFirstVisibleItem]
 	sub		dx, [bp+MENUINIT.wHighlightedItem]
+
+	; Get MaxFirstVisibleItem to AX
+	push	cx
+	call	MenuScrollbars_GetMaxVisibleItemsOnPageToCX
+	mov		ax, [bp+MENUINIT.wItems]
+	sub		ax, cx
+	pop		cx
+
 	add		dx, cx
-	MAX_S	dx, 0
-	call	.GetMaxFirstVisibleItemToAX
-	MIN_U	ax, dx
+	jns		.DXisPositive
+	cwd		; This won't work if MaxFirstVisibleItem > 32767
+
+ALIGN JUMP_ALIGN
+.DXisPositive:
+	cmp		ax, dx
+	jb		.AXisLessThanDX
+	xchg	dx, ax
+
+ALIGN JUMP_ALIGN
+.AXisLessThanDX:
 	mov		[bp+MENU.wFirstVisibleItem], ax
 	call	MenuText_RefreshAllItems
@@ -127,55 +168,4 @@
 .HighlightNewItemOnCX:
 	jmp		MenuEvent_HighlightItemFromCX
-
-;--------------------------------------------------------------------
-; .GetMaxFirstVisibleItemToAX
-;	Parameters
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		AX:		Max first visible item
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.GetMaxFirstVisibleItemToAX:
-	push	cx
-
-	call	MenuScrollbars_GetMaxVisibleItemsOnPageToCX
-	mov		ax, [bp+MENUINIT.wItems]
-	sub		ax, cx
-
-	pop		cx
-	ret
-
-;--------------------------------------------------------------------
-; .RotateItemInCX
-;	Parameters
-;		CX:		Possibly under of overflown item to be rotated
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		CX:		Valid item index
-;	Corrupts registers:
-;		DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.RotateItemInCX:
-	mov		dx, [bp+MENUINIT.wItems]
-	test	cx, cx
-	js		SHORT .RotateNegativeItemInCX
-	cmp		cx, dx
-	jae		SHORT .RotatePositiveItemInCX
-	ret
-
-ALIGN JUMP_ALIGN
-.RotatePositiveItemInCX:
-	sub		cx, dx
-	;jae	SHORT .RotatePositiveItemInCX	; Not needed by scrolling
-	ret
-
-ALIGN JUMP_ALIGN
-.RotateNegativeItemInCX:
-	add		cx, dx
-	;js		SHORT .RotateNegativeItemInCX	; Not needed by scrolling
-	ret
 
 
@@ -216,12 +206,9 @@
 ALIGN JUMP_ALIGN
 MenuScrollbars_GetLastVisibleItemOnPageToAX:
-	push	cx
-
+	xchg	cx, ax
 	call	MenuScrollbars_GetActualVisibleItemsOnPageToCX
 	xchg	ax, cx
 	dec		ax
 	add		ax, [bp+MENU.wFirstVisibleItem]
-
-	pop		cx
 	ret
 
@@ -239,5 +226,9 @@
 MenuScrollbars_GetActualVisibleItemsOnPageToCX:
 	call	MenuScrollbars_GetMaxVisibleItemsOnPageToCX
-	MIN_U	cx, [bp+MENUINIT.wItems]
+	cmp		cx, [bp+MENUINIT.wItems]
+	jb		SHORT .Return
+	mov		cx, [bp+MENUINIT.wItems]
+ALIGN JUMP_ALIGN, ret
+.Return:
 	ret
 
Index: /trunk/Assembly_Library/Src/String/Char.asm
===================================================================
--- /trunk/Assembly_Library/Src/String/Char.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/String/Char.asm	(revision 181)
@@ -161,8 +161,5 @@
 Char_ALtoLowerCaseLetter:
 	call	Char_IsUpperCaseLetterInAL	; Is upper case character?
-	jnc		SHORT .Return				;  If not, return
-	add		al, 'a'-'A'					; Convert to lower case
-.Return:
-	ret
+	jmp		SHORT Char_ALtoUpperCaseLetter.CheckCF
 %endif
 
@@ -179,9 +176,21 @@
 Char_ALtoUpperCaseLetter:
 	call	Char_IsLowerCaseLetterInAL	; Is lower case character?
-	jnc		SHORT .Return				;  If not, return
-	sub		al, 'a'-'A'					; Convert to upper case
+.CheckCF:
+	jnc		SHORT Char_ChangeCaseInAL.Return
+	; Fall to Char_ChangeCaseInAL
+
+;--------------------------------------------------------------------
+; Char_ChangeCaseInAL
+;	Parameters:
+;		AL:		Character to convert (must be A-Z or a-z)
+;	Returns:
+;		AL:		Character converted
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+Char_ChangeCaseInAL:
+	xor		al, 32
 .Return:
 	ret
-
 
 ;--------------------------------------------------------------------
Index: /trunk/Assembly_Library/Src/Util/Math.asm
===================================================================
--- /trunk/Assembly_Library/Src/Util/Math.asm	(revision 180)
+++ /trunk/Assembly_Library/Src/Util/Math.asm	(revision 181)
@@ -17,6 +17,7 @@
 ;		AX
 ;--------------------------------------------------------------------
+%ifndef EXCLUDE_FROM_XTIDECFG	; Not used in XTIDECFG
 ALIGN JUMP_ALIGN
-Math_DivQWatSSBPbyCX:		; This procedure is included but not used in XTIDECFG
+Math_DivQWatSSBPbyCX:
 	xor		dx, dx
 	mov		ax, [bp+6]		; Load highest divident WORD to DX:AX
@@ -36,4 +37,5 @@
 	mov		[bp], ax
 	ret
+%endif
 
 
@@ -49,7 +51,7 @@
 ;		Nothing
 ;--------------------------------------------------------------------
-%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
+%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
 ALIGN JUMP_ALIGN
-Math_DivDXAXbyCX:			; This procedure is included but not used in XTIDECFG
+Math_DivDXAXbyCX:	; This is currently unused (dead code)
 	xor		bx, bx
 	xchg	bx, ax
Index: /trunk/Configurator/Src/BiosFile.asm
===================================================================
--- /trunk/Configurator/Src/BiosFile.asm	(revision 180)
+++ /trunk/Configurator/Src/BiosFile.asm	(revision 181)
@@ -29,7 +29,8 @@
 
 	; Ask if user wants to save
-	mov		ax, cs
-	mov		ds, ax
-	mov		es, ax
+	push	cs
+	pop		ds
+	push	cs
+	pop		es
 	call	BiosFile_DoesUserWantToSaveChanges
 	jnc		SHORT .Return
Index: /trunk/Configurator/Src/Libraries/math.asm
===================================================================
--- /trunk/Configurator/Src/Libraries/math.asm	(revision 180)
+++ /trunk/Configurator/Src/Libraries/math.asm	(revision 181)
@@ -1,9 +1,4 @@
-; File name		:	math.asm
 ; Project name	:	Math library
-; Created date	:	7.10.2009
-; Last update	:	4.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
-; Description	:	ASM library to for math related functions.		
+; Description	:	ASM library for math related functions.
 
 ;--------------- Equates -----------------------------
@@ -27,5 +22,5 @@
 ;--------------------------------------------------------------------
 ; Macro to select lesser of two unsigned operands.
-; 
+;
 ; MIN_U
 ;	Parameters:
@@ -48,5 +43,5 @@
 ;--------------------------------------------------------------------
 ; Macro to select greater of two unsigned operands.
-; 
+;
 ; MAX_U
 ;	Parameters:
@@ -69,5 +64,5 @@
 ;--------------------------------------------------------------------
 ; Macro to select lesser and greater of two unsigned operands.
-; 
+;
 ; MINMAX_U
 ;	Parameters:
@@ -82,5 +77,5 @@
 %macro MINMAX_U 2
 	cmp		%1, %2				; Is %1 smaller?
-	jbe		%%Return			;  If so, return
+	jb		%%Return			;  If so, return
 	xchg	%1, %2				; Exchange operands
 ALIGN JUMP_ALIGN
@@ -93,5 +88,5 @@
 ; Multiplies unsigned 32-bit integer by unsigned 16-bit integer.
 ; Result is unsigned 32-bit integer, so overflow is possible.
-; 
+;
 ; Math_MulDWbyW
 ;	Parameters:
@@ -130,5 +125,5 @@
 ;--------------------------------------------------------------------
 ; Divide a 32-bit unsigned integer so that quotient can be 32-bit.
-; 
+;
 ; Math_DivDWbyW
 ;	Parameters:
@@ -157,5 +152,5 @@
 ;--------------------------------------------------------------------
 ; Converts remainder to tenths.
-; 
+;
 ; Math_RemToTenths
 ;	Parameters:
Index: /trunk/Configurator/Src/Libraries/menu/menudraw.asm
===================================================================
--- /trunk/Configurator/Src/Libraries/menu/menudraw.asm	(revision 180)
+++ /trunk/Configurator/Src/Libraries/menu/menudraw.asm	(revision 181)
@@ -287,6 +287,5 @@
 	test	BYTE [bp+MENUVARS.bFlags], FLG_MNU_HIDENFO	; Information hidden?
 	jnz		SHORT .JumpToBottomBorder
-	test	cx, cx							; Any info strings?
-	jz		SHORT MenuDraw_BottomBorder
+	jcxz	MenuDraw_BottomBorder			; Any info strings?
 	push	cx
 	call	MenuDraw_MiddleBorder			; Draw middle border
Index: /trunk/Configurator/Src/Libraries/menu/menumsg.asm
===================================================================
--- /trunk/Configurator/Src/Libraries/menu/menumsg.asm	(revision 180)
+++ /trunk/Configurator/Src/Libraries/menu/menumsg.asm	(revision 181)
@@ -1,8 +1,4 @@
-; File name		:	menumsg.asm
 ; Project name	:	Menu library
-; Created date	:	13.11.2009
-; Last update	:	10.1.2010
-; Author		:	Tomi Tilli
-; Description	:	ASM library to menu system.
+; Description	:	ASM library for menu system.
 ;					Contains functions for displaying messages.
 
@@ -156,6 +152,5 @@
 ALIGN JUMP_ALIGN
 MenuMsg_GetTokenForLine:
-	test	cx, cx				; Line 0 wanted?
-	jz		.GetFirst			;  If so, just get token length
+	jcxz	.GetFirst			; Line 0 wanted? If so, just get token length
 	push	bp
 	push	si
@@ -218,5 +213,5 @@
 	jnc		.EndOfString					; Return if no tokens
 	eMOVZX	dx, BYTE [bp+MENUVARS.bWidth]	; Menu width
-	sub		dl, SIZE_MSG_HBRDR				; To line length 
+	sub		dl, SIZE_MSG_HBRDR				; To line length
 	mov		bl, ' '							; Space character
 ALIGN JUMP_ALIGN
Index: /trunk/Configurator/Src/Libraries/print.asm
===================================================================
--- /trunk/Configurator/Src/Libraries/print.asm	(revision 180)
+++ /trunk/Configurator/Src/Libraries/print.asm	(revision 181)
@@ -1,8 +1,3 @@
-; File name		:	print.asm
 ; Project name	:	Print library
-; Created date	:	6.10.2009
-; Last update	:	4.1.2011
-; Author		:	Tomi Tilli,
-;				:	Krister Nordvall (optimizations)
 ; Description	:	ASM library for character and string
 ;					printing related functions.
@@ -95,5 +90,5 @@
 ;--------------------------------------------------------------------
 ; Debugging macro that prints wanted character and newline.
-; 
+;
 ; PRINT_DBG_CH
 ;	Parameters:
@@ -141,5 +136,5 @@
 ;
 ;	NOTE! Caller must clean the stack variables!
-; 
+;
 ; Print_Format
 ;	Parameters:
@@ -341,5 +336,5 @@
 ;--------------------------------------------------------------------
 ; Prints newline character to change line.
-; 
+;
 ; Print_Newline
 ;	Parameters:
@@ -363,9 +358,9 @@
 	ret
 %endif
-	
+
 
 ;--------------------------------------------------------------------
 ; Prints wanted number of characters.
-; 
+;
 ; Print_CharBuffer
 ;	Parameters:
@@ -404,5 +399,5 @@
 ;--------------------------------------------------------------------
 ; Repeats wanted character.
-; 
+;
 ; Print_Repeat
 ;	Parameters:
@@ -429,5 +424,5 @@
 ;--------------------------------------------------------------------
 ; Prints boolean value.
-; 
+;
 ; Print_Bool
 ;	Parameters:
@@ -455,5 +450,5 @@
 ;--------------------------------------------------------------------
 ; Prints signed or unsigned 16-bit integer.
-; 
+;
 ; Print_IntSW	Prints signed 16-bit word
 ; Print_IntUW	Prints unsigned 16-bit word
@@ -506,6 +501,6 @@
 	PRINT_CHAR					; Print character
 	inc		di					; Increment chars printed
-	test	cx, cx				; Characters left
-	jnz		.PrintLoop			;  If so, loop
+	inc		cx					; Characters left
+	loop	.PrintLoop			;  If so, loop
 	mov		dx, di				; Copy chars printed to DX
 	pop		cx
@@ -518,5 +513,5 @@
 ;--------------------------------------------------------------------
 ; Prints unsigned 32-bit integer.
-; 
+;
 ; Print_IntUDW
 ;	Parameters:
@@ -552,6 +547,6 @@
 	PRINT_CHAR					; Print character
 	inc		di					; Increment chars printed
-	test	cx, cx				; Characters left
-	jnz		.PrintLoop			;  If so, loop
+	inc		cx					; Characters left
+	loop	.PrintLoop			;  If so, loop
 	mov		dx, di				; Copy characters printed to DX
 	pop		cx
@@ -565,5 +560,5 @@
 ;--------------------------------------------------------------------
 ; Prints 8-bit byte as hexadecimal string.
-; 
+;
 ; Print_IntHexB
 ;	Parameters:
@@ -593,5 +588,5 @@
 ;--------------------------------------------------------------------
 ; Prints 16-bit word as hexadecimal string.
-; 
+;
 ; Print_IntHexW
 ;	Parameters:
@@ -621,5 +616,5 @@
 ;--------------------------------------------------------------------
 ; Prints 32-bit dword as hexadecimal string.
-; 
+;
 ; Print_IntHexDW
 ;	Parameters:
@@ -658,5 +653,5 @@
 ;--------------------------------------------------------------------
 ; Prints hexadecimal character for every nybble for WORD.
-; 
+;
 ; Print_HexString
 ;	Parameters:
Index: /trunk/Configurator/Src/MenuPageItem.asm
===================================================================
--- /trunk/Configurator/Src/MenuPageItem.asm	(revision 180)
+++ /trunk/Configurator/Src/MenuPageItem.asm	(revision 181)
@@ -65,7 +65,7 @@
 ALIGN JUMP_ALIGN
 MenuPageItem_DisplayHelpDialog:
+	push	cs
+	pop		es
 	mov		di, [di+MENUPAGEITEM.szHelp]	; ES:DI now points to help string
-	push	cs
-	pop		es
 	mov		bl, WIDTH_DLG					; Dialog width
 	jmp		Menu_ShowMsgDlg
Index: /trunk/Configurator/Src/Menupages/FlashMenu.asm
===================================================================
--- /trunk/Configurator/Src/Menupages/FlashMenu.asm	(revision 180)
+++ /trunk/Configurator/Src/Menupages/FlashMenu.asm	(revision 181)
@@ -371,6 +371,6 @@
 FlashMenu_CalculateCompletionPercentage:
 	cmp		WORD [si+FLASHVARS.wPagesLeft], 0
+	mov		ax, 100
 	je		SHORT .FlashComplete
-	mov		ax, 100
 	mul		WORD [si+FLASHVARS.wPagesLeft]
 	div		WORD [si+FLASHVARS.wTotalPages]		; AX = Percentage left to write
@@ -382,5 +382,4 @@
 ALIGN JUMP_ALIGN
 .FlashComplete:
-	mov		ax, 100
 	stc
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 181)
@@ -5,26 +5,26 @@
 %define ROMVARS_INC
 
-; ROM Variables. There are written to ROM image before flashing.
+; ROM Variables. Written to the ROM image before flashing.
 struc ROMVARS
-	.wRomSign		resb	2	; ROM Signature (AA55h)
-	.bRomSize		resb	1	; ROM size in 512 byte blocks
-	.rgbJump		resb	3	; First instruction to ROM init (jmp)
+	.wRomSign			resb	2	; ROM Signature (AA55h)
+	.bRomSize			resb	1	; ROM size in 512 byte blocks
+	.rgbJump			resb	3	; First instruction to ROM init (jmp)
 
-	.rgbSign		resb	8	; Signature for XTIDE Configurator Program
-	.szTitle		resb	31	; BIOS title string
-	.szVersion		resb	25	; BIOS version string
+	.rgbSign			resb	8	; Signature for XTIDE Configurator Program
+	.szTitle			resb	31	; BIOS title string
+	.szVersion			resb	25	; BIOS version string
 
-	.wFlags			resb	2	; Word for ROM flags
-	.wDisplayMode	resb	2	; Display mode for boot menu
-	.wBootTimeout	resb	2	; Boot Menu selection timeout in system timer ticks
-	.bIdeCnt		resb	1	; Number of available IDE controllers
-	.bBootDrv		resb	1	; Boot Menu default drive
-	.bMinFddCnt		resb	1	; Minimum number of Floppy Drives
-	.bStealSize		resb	1	; Number of 1kB blocks stolen from 640kB base RAM
+	.wFlags				resb	2	; Word for ROM flags
+	.wDisplayMode		resb	2	; Display mode for boot menu
+	.wBootTimeout		resb	2	; Boot Menu selection timeout in system timer ticks
+	.bIdeCnt			resb	1	; Number of available IDE controllers
+	.bBootDrv			resb	1	; Boot Menu default drive
+	.bMinFddCnt			resb	1	; Minimum number of Floppy Drives
+	.bStealSize			resb	1	; Number of 1kB blocks stolen from 640kB base RAM
 
-	.ideVars0		resb	IDEVARS_size
-	.ideVars1		resb	IDEVARS_size
-	.ideVars2		resb	IDEVARS_size
-	.ideVars3		resb	IDEVARS_size
+	.ideVars0			resb	IDEVARS_size
+	.ideVars1			resb	IDEVARS_size
+	.ideVars2			resb	IDEVARS_size
+	.ideVars3			resb	IDEVARS_size
 
 %ifdef MODULE_SERIAL
@@ -34,6 +34,6 @@
 
 ; Bit defines for ROMVARS.wFlags
-FLG_ROMVARS_FULLMODE	EQU	(1<<0)	; Full operating mode (steals base RAM, supports EBIOS etc.)
-FLG_ROMVARS_DRVXLAT		EQU	(1<<2)	; Enable drive number translation
+FLG_ROMVARS_FULLMODE		EQU	(1<<0)	; Full operating mode (steals base RAM, supports EBIOS etc.)
+FLG_ROMVARS_DRVXLAT			EQU	(1<<2)	; Enable drive number translation
 FLG_ROMVARS_MODULE_SERIAL	EQU (1<<3)
 FLG_ROMVARS_MODULE_EBIOS	EQU (1<<4)
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm	(revision 181)
@@ -125,4 +125,4 @@
 	mul		bl							; AX = Offset inside BOOTNFO array
 	add		ax, BOOTVARS.rgBootNfo		; Add offset to BOOTNFO array
-	xchg	bx, ax						; Copy result to BX
+	xchg	bx, ax						; Move result to BX
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm	(revision 181)
@@ -102,5 +102,9 @@
 	CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
 	sub		ah, MENU_SCREEN_BOTTOM_LINES*2	; Leave space for bottom info
-	MIN_U	ah, cl
+	cmp		ah, cl
+	jb		SHORT .Return
+	mov		ah, cl
+ALIGN JUMP_ALIGN, ret
+.Return:
 	ret
 
@@ -148,5 +152,9 @@
 	call	FloppyDrive_GetCountToCX
 	add		cl, 'A'
-	MAX_U	cl, 'C'
+	cmp		cl, 'C'
+	ja		.Return
+	mov		cl, 'C'
+ALIGN JUMP_ALIGN, ret
+.Return:
 	ret
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm	(revision 181)
@@ -85,9 +85,10 @@
 ;		AX, DX
 ;--------------------------------------------------------------------
-PushBusType:
+;PushBusType:
+	cwd					; Clear DX using sign extension
 	xchg	ax, bx		; Store BX to AX
 	eMOVZX	bx, BYTE [cs:si+IDEVARS.bDevice]
 	mov		bx, [cs:bx+rgwBusTypeValues]	; Char to BL, Int to BH
-	eMOVZX	dx, bh
+	mov		dl, bh
 	push	bx			; Push character
 	push	dx			; Push 1, 8, 16 or 32
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 181)
@@ -16,14 +16,16 @@
 ;		AX, BX, CX, DX
 ;--------------------------------------------------------------------
+%ifdef MODULE_SERIAL
 Device_FinalizeDPT:
-%ifdef MODULE_SERIAL
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
 	jnz		SHORT .FinalizeDptForSerialPortDevice
+	jmp		IdeDPT_Finalize
+
+.FinalizeDptForSerialPortDevice:
+	jmp		SerialDPT_Finalize
+%else
+	Device_FinalizeDPT EQU IdeDPT_Finalize
 %endif
-	jmp		IdeDPT_Finalize
-%ifdef MODULE_SERIAL
-.FinalizeDptForSerialPortDevice:
-	jmp		SerialDPT_Finalize		
-%endif
+
 
 ;--------------------------------------------------------------------
@@ -37,10 +39,12 @@
 ;		AL, BX, CX, DX
 ;--------------------------------------------------------------------
+%ifdef MODULE_SERIAL
 Device_ResetMasterAndSlaveController:
-%ifdef MODULE_SERIAL
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
 	jnz		SHORT ReturnSuccessForSerialPort
+	jmp		IdeCommand_ResetMasterAndSlaveController
+%else
+	Device_ResetMasterAndSlaveController EQU IdeCommand_ResetMasterAndSlaveController
 %endif
-	jmp		IdeCommand_ResetMasterAndSlaveController
 
 
@@ -58,14 +62,16 @@
 ;		AL, BL, CX, DX, SI, DI, ES
 ;--------------------------------------------------------------------
+%ifdef MODULE_SERIAL
 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
-%ifdef MODULE_SERIAL
 	cmp		BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
 	je		SHORT .IdentifyDriveFromSerialPort
-%endif
 	jmp		IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
-%ifdef MODULE_SERIAL
+
 .IdentifyDriveFromSerialPort:
 	jmp		SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
+%else
+	Device_IdentifyToBufferInESSIwithDriveSelectByteInBH EQU IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
 %endif
+
 
 ;--------------------------------------------------------------------
@@ -83,16 +89,18 @@
 ;		AL, BX, CX, DX, (ES:SI for data transfer commands)
 ;--------------------------------------------------------------------
+%ifdef MODULE_SERIAL
 ALIGN JUMP_ALIGN
 Device_OutputCommandWithParameters:
-%ifdef MODULE_SERIAL
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
 	jnz		SHORT .OutputCommandToSerialPort
-%endif
 	jmp		IdeCommand_OutputWithParameters
-%ifdef MODULE_SERIAL
+
 ALIGN JUMP_ALIGN
 .OutputCommandToSerialPort:
 	jmp		SerialCommand_OutputWithParameters
+%else
+	Device_OutputCommandWithParameters EQU IdeCommand_OutputWithParameters
 %endif
+
 
 ;--------------------------------------------------------------------
@@ -107,14 +115,16 @@
 ;		AL, BX, CX, DX
 ;--------------------------------------------------------------------
+%ifdef MODULE_SERIAL
 ALIGN JUMP_ALIGN
 Device_SelectDrive:
-%ifdef MODULE_SERIAL
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
 	jnz		SHORT ReturnSuccessForSerialPort
-%endif
 	jmp		IdeCommand_SelectDrive
-%ifdef MODULE_SERIAL
+
 ReturnSuccessForSerialPort:
 	xor		ax, ax
 	ret
+%else
+	Device_SelectDrive EQU IdeCommand_SelectDrive
 %endif
+
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm	(revision 181)
@@ -7,7 +7,9 @@
 ;--------------------------------------------------------------------
 ; IdeIO_OutputALtoIdeRegisterInDL
+; IdeIO_OutputALtoIdeControlBlockRegisterInDL
 ;	Parameters:
 ;		AL:		Byte to output
-;		DL:		IDE Register
+;		DL:		IDE Register				(IdeIO_OutputALtoIdeRegisterInDL)
+;				IDE Control Block Register	(IdeIO_OutputALtoIdeControlBlockRegisterInDL)
 ;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;	Returns:
@@ -18,24 +20,10 @@
 ALIGN JUMP_ALIGN
 IdeIO_OutputALtoIdeRegisterInDL:
-	mov		bx, IDEVARS.wPort
-	call	GetPortToDXandTranslateA0andA3ifNecessary
-	out		dx, al
-	ret
+	mov		bl, IDEVARS.wPort
+	SKIP2B	f	; cmp ax, <next instruction>
+	; Fall to IdeIO_OutputALtoIdeControlBlockRegisterInDL
 
-
-;--------------------------------------------------------------------
-; IdeIO_OutputALtoIdeControlBlockRegisterInDL
-;	Parameters:
-;		AL:		Byte to output
-;		DL:		IDE Control Block Register
-;		DS:DI:	Ptr to DPT (in RAMVARS segment)
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		BX, DX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
 IdeIO_OutputALtoIdeControlBlockRegisterInDL:
-	mov		bx, IDEVARS.wPortCtrl
+	mov		bl, IDEVARS.wPortCtrl
 	call	GetPortToDXandTranslateA0andA3ifNecessary
 	out		dx, al
@@ -55,5 +43,5 @@
 ALIGN JUMP_ALIGN
 IdeIO_InputToALfromIdeRegisterInDL:
-	mov		bx, IDEVARS.wPort
+	mov		bl, IDEVARS.wPort
 	call	GetPortToDXandTranslateA0andA3ifNecessary
 	in		al, dx
@@ -64,5 +52,5 @@
 ; GetPortToDXandTranslateA0andA3ifNecessary
 ;	Parameters:
-;		BX:		Offset to port in IDEVARS (IDEVARS.wPort or IDEVARS.wPortCtrl)
+;		BL:		Offset to port in IDEVARS (IDEVARS.wPort or IDEVARS.wPortCtrl)
 ;		DL:		IDE Register
 ;		DS:DI:	Ptr to DPT (in RAMVARS segment)
@@ -74,4 +62,5 @@
 ALIGN JUMP_ALIGN
 GetPortToDXandTranslateA0andA3ifNecessary:
+	xor		bh, bh
 	xor		dh, dh							; DX now has IDE register offset
 	add		bl, [di+DPT.bIdevarsOffset]		; CS:BX now points port address
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 181)
@@ -230,9 +230,5 @@
 ALIGN JUMP_ALIGN
 DualByteReadForXtide:
-%ifdef USE_186
-	shr		cx, 2		; Smaller but slower on 186/286
-%else
-	times 2	shr	cx, 1	; Loop unrolling
-%endif
+	eSHR_IM	cx, 2		; Loop unrolling
 	mov		bx, 8		; Bit mask for toggling data low/high reg
 ALIGN JUMP_ALIGN
@@ -322,9 +318,5 @@
 	push	ds
 	push	bx
-%ifdef USE_186
-	shr		cx, 2		; Smaller but slower on 186/286
-%else
-	times 2	shr	cx, 1	; Loop unrolling
-%endif
+	eSHR_IM	cx, 2		; Loop unrolling
 	mov		bx, 8		; Bit mask for toggling data low/high reg
 	push	es			; Copy ES...
@@ -372,9 +364,5 @@
 WordWriteForXTIDEmod:
 	push	ds
-%ifdef USE_186
-	shr		cx, 2		; Smaller but slower on 186/286
-%else
-	times 2	shr	cx, 1	; Loop unrolling
-%endif
+	eSHR_IM	cx, 2		; Loop unrolling
 	push	es			; Copy ES...
 	pop		ds			; ...to DS
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm	(revision 181)
@@ -20,5 +20,5 @@
 	jmp		ax
 
-%ifdef MODULE_EBIOS
+
 ;--------------------------------------------------------------------
 ; Idepack_ConvertDapToIdepackAndIssueCommandFromAH
@@ -36,4 +36,5 @@
 ;		AL, BX, CX, DX, SI, ES
 ;--------------------------------------------------------------------
+%ifdef MODULE_EBIOS
 ALIGN JUMP_ALIGN
 Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
@@ -60,4 +61,5 @@
 %endif
 
+
 ;--------------------------------------------------------------------
 ; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
@@ -83,6 +85,10 @@
 Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
 	mov		[bp+IDEPACK.bCommand], ah
-	test	al, al
-	eCSETZ	ah
+
+	xor		ah, ah
+	cmp		ah, al
+	cmc
+	adc		ah, ah
+
 	mov		[bp+IDEPACK.bSectorCount], al
 	mov		[bp+IDEPACK.bSectorCountHighExt], ah
@@ -100,5 +106,5 @@
 	call	AccessDPT_GetDeviceControlByteToAL
 	mov		[bp+IDEPACK.bDeviceControl], al
-	jmp		Device_OutputCommandWithParameters	
+	jmp		Device_OutputCommandWithParameters
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm	(revision 181)
@@ -10,10 +10,10 @@
 ;    http://en.wikibooks.org/wiki/Serial_Programming
 ;
-		
+
 SerialCommand_UART_base							EQU		0
 SerialCommand_UART_transmitByte					EQU		0
 SerialCommand_UART_receiveByte					EQU		0
 SerialCommand_UART_divisorLow					EQU		0
-; Values for UART_divisorLow:	
+; Values for UART_divisorLow:
 ; 60h = 1200, 30h = 2400, 18h = 4800, 0ch = 9600, 6 = 19200, 3 = 38400, 2 = 57600, 1 = 115200
 
@@ -23,5 +23,5 @@
 ; Note: hardware baud multipliers (2x, 4x) will impact the final baud rate and are not known at this level
 
-SerialCommand_UART_interruptEnable				EQU		1				
+SerialCommand_UART_interruptEnable				EQU		1
 SerialCommand_UART_divisorHigh					EQU		1
 ; UART_divisorHigh is zero for all speeds including and above 1200 baud
@@ -31,5 +31,5 @@
 
 SerialCommand_UART_lineControl					EQU		3
-		
+
 SerialCommand_UART_modemControl					EQU		4
 
@@ -40,5 +40,5 @@
 SerialCommand_UART_scratch						EQU		7
 
-SerialCommand_PackedPortAndBaud_StartingPort	EQU		240h    
+SerialCommand_PackedPortAndBaud_StartingPort	EQU		240h
 SerialCommand_PackedPortAndBaud_PortMask		EQU		0fch    ; upper 6 bits - 240h through 438h
 SerialCommand_PackedPortAndBaud_BaudMask		EQU		3       ; lower 2 bits - 4 baud rates
@@ -48,5 +48,5 @@
 SerialCommand_Protocol_Inquire					EQU		0
 SerialCommand_Protocol_Header					EQU		0a0h
-		
+
 ;--------------------------------------------------------------------
 ; SerialCommand_OutputWithParameters
@@ -65,10 +65,9 @@
 ;		AL, BX, CX, DX, (ES:SI for data transfer commands)
 ;--------------------------------------------------------------------
-
 ALIGN JUMP_ALIGN
 SerialCommand_OutputWithParameters:
-		
+
 		mov		ah,(SerialCommand_Protocol_Header | SerialCommand_Protocol_Read)
-		
+
 		mov		al,[bp+IDEPACK.bCommand]
 
@@ -78,15 +77,15 @@
 		cmp		al,30h			; Write Sectors IDE command
 		jz		.readOrWrite
-		
+
 ;  all other commands return success
 ;  including function 0ech which should return drive information, this is handled with the identify functions
 		xor		ah,ah			;  also clears carry
 		ret
-		
-.readOrWrite:	
+
+.readOrWrite:
 		mov		[bp+IDEPACK.bFeatures],ah		; store protocol command
-		
-		mov		dl, byte [ds:di+DPT.bSerialPortAndBaud]
-		
+
+		mov		dl, byte [di+DPT.bSerialPortAndBaud]
+
 ; fall-through
 
@@ -94,5 +93,5 @@
 ; SerialCommand_OutputWithParameters_DeviceInDL
 ;	Parameters:
-;       AH:		Protocol Command 
+;       AH:		Protocol Command
 ;       DL:		Packed I/O port and baud rate
 ;		ES:SI:	Ptr to buffer (for data transfer commands)
@@ -103,7 +102,7 @@
 ;	Corrupts registers:
 ;		AL, BX, CX, DX, (ES:SI for data transfer commands)
-;--------------------------------------------------------------------		
+;--------------------------------------------------------------------
 SerialCommand_OutputWithParameters_DeviceInDL:
-		
+
 		push	si
 		push	di
@@ -111,5 +110,5 @@
 		push	es
 
-; 
+;
 ; Unpack I/O port and baud from DPT
 ;		Port to DX more or less for the remainder of the routine
@@ -117,5 +116,5 @@
 ;
 		mov		cl, dl
-		
+
 		and		cl, SerialCommand_PackedPortAndBaud_BaudMask
 		shl		cl, 1
@@ -125,5 +124,5 @@
 
 		and		dl, SerialCommand_PackedPortAndBaud_PortMask
-		mov		dh, 0		
+		mov		dh, 0
 		shl		dx, 1
 		add		dx, SerialCommand_PackedPortAndBaud_StartingPort
@@ -131,5 +130,5 @@
 ;
 ; Buffer is referenced through ES:DI throughout, since we need to store faster than we read
-; 
+;
 		mov		di,si
 
@@ -138,8 +137,8 @@
 ;
 ; Command byte and sector count live at the top of the stack, pop/push are used to access
-; 
+;
 		push	ax
-		
-		cld
+
+;		cld		; Shouldn't be needed. DF has already been cleared (line 24, Int13h.asm)
 
 ;----------------------------------------------------------------------
@@ -147,9 +146,9 @@
 ; Initialize UART
 ;
-; We do this each time since DOS (at boot) or another program may have 
+; We do this each time since DOS (at boot) or another program may have
 ; decided to reprogram the UART
 ;
 		push	dx
-		
+
 		mov		al,83h
 		add		dl,SerialCommand_UART_lineControl
@@ -167,5 +166,5 @@
 		mov		al,047h
 		inc		dx				;  fifo
-		out		dx,al		
+		out		dx,al
 
 		mov		al,03h
@@ -192,15 +191,15 @@
 		push	es				; save off real buffer location
 		push	di
-		
-		mov		di,bp			; point to IDEREGS for command dispatch; 		
+
+		mov		di,bp			; point to IDEREGS for command dispatch;
 		push	ss
 		pop		es
 
 		xor		si,si			; initialize checksum for write
-		dec		si		
+		dec		si
 		mov		bp,si
 
 		mov		bl,03h		; writing 3 words
-		
+
 		call	SerialCommand_WriteProtocol
 
@@ -213,5 +212,5 @@
 ;
 ; Top of the read/write loop, one iteration per sector
-; 
+;
 .nextSector:
 		xor		si,si			; initialize checksum for read or write
@@ -220,9 +219,9 @@
 
 		mov		bx,0100h
-		
+
 		shr		ah,1			; command byte, are we doing a write?
 		jnc		.readSector
 		call	SerialCommand_WriteProtocol
-		
+
 		xor		bx,bx
 
@@ -230,5 +229,5 @@
 		mov		cx,bx
 		inc		cx
-		
+
 		mov		bl,dl			; setup bl with proper values for read loop (bh comes later)
 
@@ -246,5 +245,5 @@
 		push	cx
 		xor		cx,cx
-.readTimeoutLoop:	
+.readTimeoutLoop:
 		push	dx
 		or		dl,SerialCommand_UART_lineStatus
@@ -257,9 +256,9 @@
 		mov		bh,1
 		call	SerialCommand_WaitAndPoll_Init
-		cli		
+		cli
 .readTimeoutComplete:
 		mov		bh,bl
 		or		bh,SerialCommand_UART_lineStatus
-		
+
 		pop		cx
 		test	dl,1
@@ -271,10 +270,12 @@
 ; Read Block (without interrupts, used when there is a FIFO, high speed)
 ;
-; NOTE: This loop is very time sensitive.  Literally, another instruction 
+; NOTE: This loop is very time sensitive.  Literally, another instruction
 ; cannot be inserted into this loop without us falling behind at high
-; speed (460.8K baud) on a 4.77Mhz 8088, making it hard to receive 
+; speed (460.8K baud) on a 4.77Mhz 8088, making it hard to receive
 ; a full 512 byte block.
 ;
-.readLoop:		
+.readLoop:
+		stosw					; store word in caller's data buffer
+
 		add		bp, ax			; update Fletcher's checksum
 		adc		bp, 0
@@ -282,79 +283,78 @@
 		adc		si, 0
 
-		stosw					; store word in caller's data buffer
-
-		mov		dl,bh			
-		in		al,dx			
+		mov		dl,bh
+		in		al,dx
 		shr		al,1			; data ready (byte 1)?
-		mov		dl,bl			; get ready to read data			
+		mov		dl,bl			; get ready to read data
 		jnc		.readTimeout	; nope not ready, update timeouts
-		
-; 
+
+;
 ; Entry point after initial timeout.  We enter here so that the checksum word
 ; is not stored (and is left in AX after the loop is complete).
-; 
-.readByte1Ready:		
+;
+.readByte1Ready:
 		in		al, dx			; read data byte 1
 
 		mov		ah, al			; store byte in ah for now
-		
-;
-; note the placement of this reset of dl to bh, and that it is 
-; before the return, which is assymetric with where this is done 
-; above for byte 1.  The value of dl is used by the timeout routine 
-; to know which byte to return to (.read_byte1_ready or 
+
+;
+; note the placement of this reset of dl to bh, and that it is
+; before the return, which is assymetric with where this is done
+; above for byte 1.  The value of dl is used by the timeout routine
+; to know which byte to return to (.read_byte1_ready or
 ; .read_byte2_ready)
 ;
-		mov		dl,bh			
-								
+		mov		dl,bh
+
 		in		al,dx
 		shr		al,1			; data ready (byte 2)?
 		jnc		.readTimeout
-.readByte2Ready:						
-		mov		dl,bl		
+.readByte2Ready:
+		mov		dl,bl
 		in		al, dx			; read data byte 2
 
 		xchg	al, ah			; ah was holding byte 1, reverse byte order
-		
+
 		loop	.readLoop
 
+		sti						; interrupts back on ASAP, if we turned them off
+
 ;
 ; Compare checksums
-; 
+;
 		xor		bp,si
 		cmp		ax,bp
 		jnz		SerialCommand_OutputWithParameters_Error
 
-		sti					; interrupts back on ASAP, if we turned them off
-		
+
 ;----------------------------------------------------------------------
-; 
+;
 ; Clear read buffer
 ;
 ; In case there are extra characters or an error in the FIFO, clear it out.
-; In theory the initialization of the UART registers above should have 
+; In theory the initialization of the UART registers above should have
 ; taken care of this, but I have seen cases where this is not true.
 ;
 .clearBuffer:
-		mov		dl,bh		
+		mov		dl,bh
 		in		al,dx
-		mov		dl,bl				
+		mov		dl,bl
 		test	al,08fh
 		jz		.clearBufferComplete
 		shr		al,1
-		in		al,dx		
+		in		al,dx
 		jc		.clearBuffer	; note CF from shr above
 		jmp		SerialCommand_OutputWithParameters_Error
-		
-.clearBufferComplete:	
+
+.clearBufferComplete:
 		pop		ax				; sector count and command byte
 		dec		al				; decrememnt sector count
 		push	ax				; save
 		jz		SerialCommand_OutputWithParameters_ReturnCodeInALCF    ; CF clear from .clearBuffer test above
-				
+
 		cli						; interrupts back off for ACK byte to host
 								; (host could start sending data immediately)
 		out		dx,al			; ACK with next sector number
-		
+
 		jmp		.nextSector		; all is well, time for next sector
 
@@ -363,19 +363,19 @@
 ; Cleanup, error reporting, and exit
 ;
-		
-; 
+
+;
 ; Used in situations where a call is underway, such as with SerialCommand_WaitAndPoll
-; 
+;
 SerialCommand_OutputWithParameters_ErrorAndPop2Words:
 		pop		ax
 		pop		ax
 
-SerialCommand_OutputWithParameters_Error:		
+SerialCommand_OutputWithParameters_Error:
+		stc
 		mov		al,1
-		stc
-
-SerialCommand_OutputWithParameters_ReturnCodeInALCF:	
+
+SerialCommand_OutputWithParameters_ReturnCodeInALCF:
+		sti
 		mov		ah,al
-		sti
 
 		pop		bp				;  recover ax from stack, throw away
@@ -398,5 +398,5 @@
 ;       Returns when desired UART_LineStatus bit is cleared
 ;       Jumps directly to error exit if timeout elapses (and cleans up stack)
-;	Corrupts registers: 
+;	Corrupts registers:
 ;       CX, flags
 ;--------------------------------------------------------------------
@@ -404,10 +404,10 @@
 SerialCommand_WaitAndPoll_SoftDelayTicks   EQU   20
 
-ALIGN JUMP_ALIGN				
+ALIGN JUMP_ALIGN
 SerialCommand_WaitAndPoll_Init:
 		mov		cl,SerialCommand_WaitAndPoll_SoftDelayTicks
 		call	Timer_InitializeTimeoutWithTicksInCL
 ; fall-through
-		
+
 SerialCommand_WaitAndPoll:
 		call	Timer_SetCFifTimeout
@@ -422,6 +422,6 @@
 		jz		SerialCommand_WaitAndPoll
 ; fall-through
-		
-SerialCommand_WaitAndPoll_Done:	
+
+SerialCommand_WaitAndPoll_Done:
 		ret
 
@@ -442,13 +442,13 @@
 SerialCommand_WriteProtocol:
 		mov		bh,20h
-		
+
 .writeLoop:
 		test	bh,1
 		jnz		SerialCommand_WaitAndPoll_Done
-		
+
 		mov		ax,[es:di]		; fetch next word
 		inc		di
 		inc		di
-		
+
 		add		bp,ax			; update checksum
 		adc		bp,0
@@ -458,9 +458,9 @@
 .writeLoopChecksum:
 		call	SerialCommand_WaitAndPoll_Init
-		
+
 		out		dx,al			; output first byte
 
 		call	SerialCommand_WaitAndPoll
-		
+
 		mov		al,ah			; output second byte
 		out		dx,al
@@ -468,10 +468,10 @@
 		dec		bl
 		jnz		.writeLoop
-		
+
 		inc		bh
-		
+
 		mov		ax,bp			; merge checksum for possible write (last loop)
-		xor		ax,si		
-		
+		xor		ax,si
+
 		jmp		.writeLoopChecksum
 
@@ -501,9 +501,9 @@
 		mov		dx,[cs:bp+IDEVARS.wPortCtrl]
 		inc		dx
-		dec		dx		
+		dec		dx
 		jz		SerialCommand_AutoSerial
 
 ; fall-through
-SerialCommand_IdentifyDeviceInDL_DriveInBH:		
+SerialCommand_IdentifyDeviceInDL_DriveInBH:
 
 		push	bp				; setup fake IDEREGS_AND_INTPACK
@@ -516,5 +516,5 @@
 		mov		bl,0a0h			; protocol command to ah and onto stack with bh
 		mov		ah,bl
-		
+
 		push	bx
 
@@ -524,12 +524,12 @@
 
 		pop		bx
-		
-		pop		cx				
+
+		pop		cx
 		pop		dx
 
 		pop		bp
 
-; place packed port/baud in vendor area of packet, read by FinalizeDPT 
-		mov		byte [es:si+SerialCommand_IdentifyDevice_PackedPortAndBaud], dl	
+; place packed port/baud in vendor area of packet, read by FinalizeDPT
+		mov		byte [es:si+SerialCommand_IdentifyDevice_PackedPortAndBaud], dl
 
 		ret
@@ -540,27 +540,26 @@
 ;
 ; When the SerialAuto IDEVARS entry is used, scans the COM ports on the machine for a possible serial connection.
-; 
-		
+;
+
 SerialCommand_ScanPortAddresses:  db  0b8h, 0f8h, 0bch, 0bah, 0fah, 0beh, 0feh, 0
 ; Corresponds to I/O port:             3f8,  2f8,  3e8,  2e8,  2f0,  3e0,  2e0,  260,  368,  268,  360,  270
 ; COM Assignments:                       1,    2,    3,    4,    5,    6,    7,    8,    9,   10,   11,   12
 
-ALIGN JUMP_ALIGN						
-SerialCommand_AutoSerial:		
+ALIGN JUMP_ALIGN
+SerialCommand_AutoSerial:
 		mov		di,SerialCommand_ScanPortAddresses-1
-		
+
 .nextPort:
 		inc		di				; load next port address
 		mov		dl,[cs:di]
-		
+
 		mov		dh,0			; shift from one byte to two
-		shl		dx,1
-		shl		dx,1		
+		eSHL_IM	dx, 2
 		jz		.exitNotFound
 
 ;
 ; Test for COM port presence, write to and read from registers
-; 
-		push	dx		
+;
+		push	dx
 		add		dl,SerialCommand_UART_lineControl
 		mov		al, 09ah
@@ -569,5 +568,5 @@
 		pop		dx
 		cmp		al, 09ah
-		jnz		.nextPort		
+		jnz		.nextPort
 
 		mov		al, 0ch
@@ -579,27 +578,27 @@
 ;
 ; Pack into dl, baud rate starts at 0
-; 
+;
 		add		dx,-(SerialCommand_PackedPortAndBaud_StartingPort)
 		shr		dx,1
-		
+
 		jmp		.testFirstBaud
 
 ;
 ; Walk through 4 possible baud rates
-; 
-.nextBaud:		
+;
+.nextBaud:
 		inc		dx
 		test	dl,3
 		jz		.nextPort
-		
-.testFirstBaud:		
+
+.testFirstBaud:
 		call	SerialCommand_IdentifyDeviceInDL_DriveInBH
 		jc		.nextBaud
 
 		ret
-				
+
 .exitNotFound:
+		stc
 		mov		ah,1
-		stc
 
 		ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm	(revision 181)
@@ -18,6 +18,5 @@
 		or		byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
 		mov		al, byte [es:si+SerialCommand_IdentifyDevice_PackedPortAndBaud]
-		mov		byte [ds:di+DPT.bSerialPortAndBaud], al
+		mov		byte [di+DPT.bSerialPortAndBaud], al
 		ret
 
-
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/Timer.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/Timer.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/Timer.asm	(revision 181)
@@ -59,5 +59,5 @@
 %ifndef USE_AT
 	mov		ax, 2
-	; Fall to Delay_TimerTicksFromAX
+	; Fall to Timer_DelayTimerTicksFromAX
 %else
 	push	dx
@@ -68,5 +68,5 @@
 	mov		ah, EVENT_WAIT
 	int		BIOS_SYSTEM_INTERRUPT_15h
-	sti									; XT BIOSes return with interrupt disabled
+	sti									; XT BIOSes return with interrupts disabled. TODO: Maybe we can remove this since it's in an AT-only block?
 
 	pop		cx
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 181)
@@ -53,6 +53,6 @@
 	cmp		ah, 48h
 	ja		SHORT Int13h_UnsupportedFunction
-	sub		bx, 41h<<1					; BX = Offset to eINT 13h jump table
-	jl		SHORT Int13h_UnsupportedFunction
+	sub		bl, 41h<<1					; BX = Offset to eINT 13h jump table
+	jb		SHORT Int13h_UnsupportedFunction
 	jmp		[cs:bx+g_rgwEbiosFunctionJumpTable]
 %endif
@@ -169,6 +169,6 @@
 	mov		di, [RAMVARS.fpOldI13h+2]
 	xchg	di, [es:BIOS_DISK_INTERRUPT_13h*4+2]
+	sti
 	mov		[RAMVARS.fpOldI13h+2], di
-	sti
 	pop		es
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 181)
@@ -60,10 +60,7 @@
 	call	Idepack_StoreNonExtParametersAndIssueCommandFromAL
 	pop		bx
-	jc		SHORT .DisableBlockMode
-
-	; Store new block size to DPT and return
-	mov		[di+DPT_ATA.bSetBlock], bl				; Store new block size
+	jnc		.StoreBlockSize
+	mov		bl, 1	; Disable block mode
+.StoreBlockSize:	; Store new block size to DPT and return
+	mov		[di+DPT_ATA.bSetBlock], bl
 	ret
-.DisableBlockMode:
-	mov		BYTE [di+DPT_ATA.bSetBlock], 1			; Disable block mode
-	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/CommandLookup.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/CommandLookup.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/CommandLookup.asm	(revision 181)
@@ -5,5 +5,4 @@
 SECTION .text
 
-%ifdef MODULE_EBIOS
 ;--------------------------------------------------------------------
 ; CommandLookup_GetEbiosIndexToBX
@@ -16,4 +15,5 @@
 ;		AX, DX
 ;--------------------------------------------------------------------
+%ifdef MODULE_EBIOS
 ALIGN JUMP_ALIGN
 CommandLookup_GetEbiosIndexToBX:
@@ -29,5 +29,5 @@
 	ret
 %endif
-		
+
 ;--------------------------------------------------------------------
 ; CommandLookup_GetOldInt13hIndexToBX
@@ -63,3 +63,4 @@
 	db		COMMAND_VERIFY_SECTORS_EXT
 	db		COMMAND_VERIFY_SECTORS
-	db		COMMAND_VERIFY_SECTORS_EXT		
+	db		COMMAND_VERIFY_SECTORS_EXT
+
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 181)
@@ -121,5 +121,7 @@
 ;--------------------------------------------------------------------
 AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI:
-	call	Registers_ExchangeDSSIwithESDI	; ATA info now in DSDI
+	mov		bx, Registers_ExchangeDSSIwithESDI
+	call	bx	; ATA info now in DS:DI
+	push	bx	; We will return via Registers_ExchangeDSSIwithESDI
 	xor		bx, bx
 	test	BYTE [di+ATA1.wCaps+1], A1_wCaps_LBA>>8
@@ -133,5 +135,5 @@
 ;	Parameters:
 ;		BX:		Zero
-;		DS:SI:	Ptr to 512-byte ATA information read from the drive
+;		DS:DI:	Ptr to 512-byte ATA information read from the drive
 ;	Returns:
 ;		BX:DX:AX:	48-bit sector count
@@ -145,10 +147,10 @@
 	mov		dx, [di+ATA6.qwLBACnt+2]
 	mov		bx, [di+ATA6.qwLBACnt+4]
-	jmp		SHORT .ExchangePtrAndReturn
+	ret
 
 .GetLba28SectorCount:
 	mov		ax, [di+ATA1.dwLBACnt]
 	mov		dx, [di+ATA1.dwLBACnt+2]
-	jmp		SHORT .ExchangePtrAndReturn
+	ret
 
 .GetChsSectorCount:
@@ -156,4 +158,3 @@
 	mul		BYTE [di+ATA1.wHeadCnt]	; AX=Sectors per track * number of heads
 	mul		WORD [di+ATA1.wCylCnt]	; DX:AX=Sectors per track * number of heads * number of cylinders
-.ExchangePtrAndReturn:
-	jmp		Registers_ExchangeDSSIwithESDI
+	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm	(revision 181)
@@ -55,5 +55,5 @@
 ;		DL:		Translated drive number
 ;	Corrupts registers:
-;		Nothing
+;		AL
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -62,13 +62,11 @@
 	je		SHORT .SwapToXXhInAL
 	cmp		al, dl				; Swap DL from xxh to 00h/80h?
-	je		SHORT .SwapTo00hOr80hInAH
-	ret
-ALIGN JUMP_ALIGN
-.SwapTo00hOr80hInAH:
-	mov		dl, ah
-	ret
+	jne		SHORT .Return
+	mov		al, ah
 ALIGN JUMP_ALIGN
 .SwapToXXhInAL:
 	mov		dl, al
+ALIGN JUMP_ALIGN, ret
+.Return:
 	ret
 
@@ -83,5 +81,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX
+;		Nothing
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm	(revision 181)
@@ -136,7 +136,8 @@
 	call	GetCountFromBDA
 %endif
-	MAX_U	cl, [cs:ROMVARS.bMinFddCnt]
+	mov		ch, [cs:ROMVARS.bMinFddCnt]
+	MAX_U	cl, ch
+	pop		es
 	xor		ch, ch
-	pop		es
 	ret
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 181)
@@ -29,8 +29,10 @@
 ;--------------------------------------------------------------------
 .InitializeInt13hAnd40h:
+	mov		ax, [es:BIOS_DISK_INTERRUPT_13h*4+2]; Load old INT 13h segment
+	mov		[RAMVARS.fpOldI13h+2], ax			; Store old INT 13h segment
+	xchg	dx, ax
 	mov		ax, [es:BIOS_DISK_INTERRUPT_13h*4]	; Load old INT 13h offset
-	mov		dx, [es:BIOS_DISK_INTERRUPT_13h*4+2]; Load old INT 13h segment
 	mov		[RAMVARS.fpOldI13h], ax				; Store old INT 13h offset
-	mov		[RAMVARS.fpOldI13h+2], dx			; Store old INT 13h segment
+
 	mov		bx, BIOS_DISK_INTERRUPT_13h			; INT 13h interrupt vector offset
 	mov		si, Int13h_DiskFunctionsHandler		; Interrupt handler offset
Index: /trunk/XTIDE_Universal_BIOS/Src/Main.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/Main.asm	(revision 181)
@@ -3,4 +3,7 @@
 ;				:	aitotat@gmail.com
 ;				:
+;				:	Greg Lindhorst
+;				:	gregli@hotmail.com
+;				;
 ;				:	Krister Nordvall
 ;				:	krille_n_@hotmail.com
@@ -13,20 +16,20 @@
 
 
-; Included .inc files
-%include "AssemblyLibrary.inc"	; Assembly Library. Must be included first!
-%include "IntController.inc"	; For Interrupt Controller equates
-%include "ATA_ID.inc"			; For ATA Drive Information structs
-%include "IdeRegisters.inc"		; For ATA Registers, flags and commands
-%include "Int13h.inc"			; Equates for INT 13h functions
+	; Included .inc files
+	%include "AssemblyLibrary.inc"	; Assembly Library. Must be included first!
+	%include "IntController.inc"	; For Interrupt Controller equates
+	%include "ATA_ID.inc"			; For ATA Drive Information structs
+	%include "IdeRegisters.inc"		; For ATA Registers, flags and commands
+	%include "Int13h.inc"			; Equates for INT 13h functions
 %ifdef MODULE_EBIOS
-%include "EBIOS.inc"			; Equates for EBIOS functions
-%endif
-%include "CustomDPT.inc"		; For Disk Parameter Table
-%include "RomVars.inc"			; For ROMVARS and IDEVARS structs
-%include "RamVars.inc"			; For RAMVARS struct
-%include "BootVars.inc"			; For BOOTVARS and BOOTNFO structs
-%include "BootMenu.inc"			; For Boot Menu
-%include "IDE_8bit.inc"			; For IDE 8-bit data port macros
-%include "DeviceIDE.inc"		; For IDE device equates
+	%include "EBIOS.inc"			; Equates for EBIOS functions
+%endif
+	%include "CustomDPT.inc"		; For Disk Parameter Table
+	%include "RomVars.inc"			; For ROMVARS and IDEVARS structs
+	%include "RamVars.inc"			; For RAMVARS struct
+	%include "BootVars.inc"			; For BOOTVARS and BOOTNFO structs
+	%include "BootMenu.inc"			; For Boot Menu
+	%include "IDE_8bit.inc"			; For IDE 8-bit data port macros
+	%include "DeviceIDE.inc"		; For IDE device equates
 
 
@@ -39,5 +42,5 @@
 	at	ROMVARS.wRomSign,	dw	0AA55h			; PC ROM signature
 	at	ROMVARS.bRomSize,	db	CNT_ROM_BLOCKS	; ROM size in 512B blocks
-	at	ROMVARS.rgbJump, 	jmp	Initialize_FromMainBiosRomSearch
+	at	ROMVARS.rgbJump,	jmp	Initialize_FromMainBiosRomSearch
 	at	ROMVARS.rgbSign,	db	"XTIDE120"		; Signature for flash program
 	at	ROMVARS.szTitle
@@ -53,15 +56,15 @@
 
 ;;; For OR'ing into wFlags below
-;;; 
+;;;
 %ifdef MODULE_SERIAL
-MAIN_FLG_MODULE_SERIAL  equ   FLG_ROMVARS_MODULE_SERIAL
-%else
-MAIN_FLG_MODULE_SERIAL  equ   0
+	MAIN_FLG_MODULE_SERIAL	equ	FLG_ROMVARS_MODULE_SERIAL
+%else
+	MAIN_FLG_MODULE_SERIAL	equ	0
 %endif
 
 %ifdef MODULE_EBIOS
-MAIN_FLG_MODULE_EBIOS   equ   FLG_ROMVARS_MODULE_EBIOS
-%else
-MAIN_FLG_MODULE_EBIOS   equ   0
+	MAIN_FLG_MODULE_EBIOS	equ	FLG_ROMVARS_MODULE_EBIOS
+%else
+	MAIN_FLG_MODULE_EBIOS	equ	0
 %endif
 
@@ -109,6 +112,6 @@
 	at	ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice,		db	DEVICE_SERIAL_PORT
 	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
-	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE		
-%endif			
+	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
+%endif
 %else
 ;-----------------------------------;
@@ -142,88 +145,87 @@
 	at	ROMVARS.ideVarsSerialAuto+IDEVARS.bDevice,		db	DEVICE_SERIAL_PORT
 	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
-	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE		
-%endif	
+	at	ROMVARS.ideVarsSerialAuto+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags,	db	FLG_DRVPARAMS_BLOCKMODE
+%endif
 %endif
 iend
 
 
-; Libraries and data
-%include "AssemblyLibrary.asm"
-%include "Strings.asm"			; For BIOS message strings
-
-; Initialization and drive detection
-%include "Initialize.asm"		; For BIOS initialization
-%include "Interrupts.asm"		; For Interrupt initialization
-%include "RamVars.asm"			; For RAMVARS initialization and access
-%include "CreateDPT.asm"		; For creating DPTs
-%include "FindDPT.asm"			; For finding DPTs
-%include "AccessDPT.asm"		; For accessing DPTs
-%include "BootInfo.asm"			; For creating BOOTNFO structs
-%include "AtaID.asm"			; For ATA Identify Device information
-%include "DetectDrives.asm"		; For detecting IDE drives
-%include "DetectPrint.asm"		; For printing drive detection strings
-
-; Boot menu
-%include "BootMenu.asm"			; For Boot Menu operations
-%include "BootMenuEvent.asm"	; For menu library event handling
-%include "FloppyDrive.asm"		; Floppy Drive related functions
-%include "BootSector.asm"		; For loading boot sector
-%include "BootPrint.asm"		; For printing boot information
-%include "BootMenuPrint.asm"	; For printing Boot Menu strings
-%include "BootMenuPrintCfg.asm"	; For printing hard disk configuration
-
-; Boot loader
+	; Libraries and data
+	%include "AssemblyLibrary.asm"
+	%include "Strings.asm"			; For BIOS message strings
+
+	; Initialization and drive detection
+	%include "Initialize.asm"		; For BIOS initialization
+	%include "Interrupts.asm"		; For Interrupt initialization
+	%include "RamVars.asm"			; For RAMVARS initialization and access
+	%include "CreateDPT.asm"		; For creating DPTs
+	%include "FindDPT.asm"			; For finding DPTs
+	%include "AccessDPT.asm"		; For accessing DPTs
+	%include "BootInfo.asm"			; For creating BOOTNFO structs
+	%include "AtaID.asm"			; For ATA Identify Device information
+	%include "DetectDrives.asm"		; For detecting IDE drives
+	%include "DetectPrint.asm"		; For printing drive detection strings
+
+	; Boot menu
+	%include "BootMenu.asm"			; For Boot Menu operations
+	%include "BootMenuEvent.asm"	; For menu library event handling
+	%include "FloppyDrive.asm"		; Floppy Drive related functions
+	%include "BootSector.asm"		; For loading boot sector
+	%include "BootPrint.asm"		; For printing boot information
+	%include "BootMenuPrint.asm"	; For printing Boot Menu strings
+	%include "BootMenuPrintCfg.asm"	; For printing hard disk configuration
+
+	; Boot loader
 %ifndef USE_AT
-	%include "Int19hLate.asm"	; For late initialization
-%endif
-%include "Int19hMenu.asm"		; For Int 19h, Boot Loader for Boot Menu
-
-; For all device types
-%include "Device.asm"
-%include "Idepack.asm"
-%include "Timer.asm"			; For timeout and delay
-
-; IDE Device support
-%include "IdeCommand.asm"
-%include "IdeTransfer.asm"		; Must be included after IdeCommand.asm
-%include "IdeDPT.asm"
-%include "IdeIO.asm"
-%include "IdeIrq.asm"
-%include "IdeWait.asm"
-%include "IdeError.asm"			; Must be included after IdeWait.asm
-
-%ifdef MODULE_SERIAL		
-; Serial Port Device support
-%include "SerialCommand.asm"
-%include "SerialDPT.asm"
-%endif
-
-; INT 13h Hard Disk BIOS functions
-%include "DriveXlate.asm"		; For swapping drive numbers
-%include "Address.asm"			; For sector address translations
-%include "CommandLookup.asm"	; For getting correct transfer command
-%include "Int13h.asm"			; For Int 13h, Disk functions
-%include "AH0h_HReset.asm"		; Required by Int13h_Jump.asm
-%include "AH1h_HStatus.asm"		; Required by Int13h_Jump.asm
-%include "AH2h_HRead.asm"		; Required by Int13h_Jump.asm
-%include "AH3h_HWrite.asm"		; Required by Int13h_Jump.asm
-%include "AH4h_HVerify.asm"		; Required by Int13h_Jump.asm
-%include "AH8h_HParams.asm"		; Required by Int13h_Jump.asm
-%include "AH9h_HInit.asm"		; Required by Int13h_Jump.asm
-%include "AHCh_HSeek.asm"		; Required by Int13h_Jump.asm
-%include "AHDh_HReset.asm"		; Required by Int13h_Jump.asm
-%include "AH10h_HReady.asm"		; Required by Int13h_Jump.asm
-%include "AH11h_HRecal.asm"		; Required by Int13h_Jump.asm
-%include "AH15h_HSize.asm"		; Required by Int13h_Jump.asm
-%include "AH23h_HFeatures.asm"	; Required by Int13h_Jump.asm
-%include "AH24h_HSetBlocks.asm"	; Required by Int13h_Jump.asm
-%include "AH25h_HDrvID.asm"		; Required by Int13h_Jump.asm
+	%include "Int19hLate.asm"		; For late initialization
+%endif
+	%include "Int19hMenu.asm"		; For Int 19h, Boot Loader for Boot Menu
+
+	; For all device types
+	%include "Device.asm"
+	%include "Idepack.asm"
+	%include "Timer.asm"			; For timeout and delay
+
+	; IDE Device support
+	%include "IdeCommand.asm"
+	%include "IdeTransfer.asm"		; Must be included after IdeCommand.asm
+	%include "IdeDPT.asm"
+	%include "IdeIO.asm"
+	%include "IdeIrq.asm"
+	%include "IdeWait.asm"
+	%include "IdeError.asm"			; Must be included after IdeWait.asm
+
+%ifdef MODULE_SERIAL				; Serial Port Device support
+	%include "SerialCommand.asm"
+	%include "SerialDPT.asm"
+%endif
+
+	; INT 13h Hard Disk BIOS functions
+	%include "DriveXlate.asm"		; For swapping drive numbers
+	%include "Address.asm"			; For sector address translations
+	%include "CommandLookup.asm"	; For getting correct transfer command
+	%include "Int13h.asm"			; For Int 13h, Disk functions
+	%include "AH0h_HReset.asm"		; Required by Int13h_Jump.asm
+	%include "AH1h_HStatus.asm"		; Required by Int13h_Jump.asm
+	%include "AH2h_HRead.asm"		; Required by Int13h_Jump.asm
+	%include "AH3h_HWrite.asm"		; Required by Int13h_Jump.asm
+	%include "AH4h_HVerify.asm"		; Required by Int13h_Jump.asm
+	%include "AH8h_HParams.asm"		; Required by Int13h_Jump.asm
+	%include "AH9h_HInit.asm"		; Required by Int13h_Jump.asm
+	%include "AHCh_HSeek.asm"		; Required by Int13h_Jump.asm
+	%include "AHDh_HReset.asm"		; Required by Int13h_Jump.asm
+	%include "AH10h_HReady.asm"		; Required by Int13h_Jump.asm
+	%include "AH11h_HRecal.asm"		; Required by Int13h_Jump.asm
+	%include "AH15h_HSize.asm"		; Required by Int13h_Jump.asm
+	%include "AH23h_HFeatures.asm"	; Required by Int13h_Jump.asm
+	%include "AH24h_HSetBlocks.asm"	; Required by Int13h_Jump.asm
+	%include "AH25h_HDrvID.asm"		; Required by Int13h_Jump.asm
 %ifdef MODULE_EBIOS
-%include "AH41h_CheckIfExtensionsPresent.asm"
-%include "AH42h_ExtendedReadSectors.asm"
-%include "AH43h_ExtendedWriteSectors.asm"
-%include "AH44h_ExtendedVerifySectors.asm"
-%include "AH47h_ExtendedSeek.asm"
-%include "AH48h_GetExtendedDriveParameters.asm"
+	%include "AH41h_CheckIfExtensionsPresent.asm"
+	%include "AH42h_ExtendedReadSectors.asm"
+	%include "AH43h_ExtendedWriteSectors.asm"
+	%include "AH44h_ExtendedVerifySectors.asm"
+	%include "AH47h_ExtendedSeek.asm"
+	%include "AH48h_GetExtendedDriveParameters.asm"
 %endif
 
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 181)
@@ -78,15 +78,17 @@
 	; Only need to limit sectors for LBA assist
 	test	BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA
-	jnz		SHORT .ReturnLbaAssistedLCHS
+	jz		SHORT AccessDPT_ShiftPCHinBXDXtoLCH
 
-	; P-CHS to L-CHS translation when necessary
-	jmp		SHORT AccessDPT_ShiftPCHinBXDXtoLCH
+	cmp		WORD [di+DPT.dwCylinders+2], BYTE 0
+	jnz		SHORT .Return_MAX_LCHS_CYLINDERS
 
-.ReturnLbaAssistedLCHS:
-	cmp		WORD [di+DPT.dwCylinders+2], BYTE 0
-	jz		SHORT .LimitCylindersTo1024
+	; Limit cylinders to 1024
+	cmp		bx, MAX_LCHS_CYLINDERS
+	jb		SHORT .Return
+ALIGN JUMP_ALIGN
+.Return_MAX_LCHS_CYLINDERS:
 	mov		bx, MAX_LCHS_CYLINDERS
-.LimitCylindersTo1024:
-	MIN_U	bx, MAX_LCHS_CYLINDERS
+ALIGN JUMP_ALIGN, ret
+.Return:
 	ret
 
@@ -114,5 +116,5 @@
 	jmp		SHORT .ShiftLoop
 .LimitHeadsTo255:						; DOS does not support drives with 256 heads
-	sub		dl, dh						; BH set only when 256 logical heads
+	sub		dl, dh						; DH set only when 256 logical heads
 	xor		dh, dh
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 181)
@@ -66,9 +66,7 @@
 %ifdef MODULE_SERIAL
 	cmp		byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
-	jnz		.around
+	jnz		.StoreAddressing
 	or		byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
-.around:				
-%endif		
-
+%endif
 	; Fall to .StoreAddressing
 
@@ -117,13 +115,12 @@
 
 	; We need to get number of bits to shift for translation
-	push	bx
 	push	ax
 	eMOVZX	dx, bl						; Heads now in DX
-	xchg	bx, ax						; Sectors now in BX
-	call	AccessDPT_ShiftPCHinBXDXtoLCH
+	xchg	bx, ax						; Cylinders now in BX
+	call	AccessDPT_ShiftPCHinBXDXtoLCH	; Leaves AX untouched
+	xchg	bx, ax						; Restore HeadsAndSectors to BX
 	or		cl, ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION
 	or		[di+DPT.bFlagsLow], cl		; Store bits to shift
 	pop		ax
-	pop		bx
 	; Fall to .StoreChsFromAXBX
 
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm	(revision 181)
@@ -167,4 +167,5 @@
 ;		CF:			Set if wanted DPT found
 ;					Cleared if DPT not found
+;					Unchanged if no drives
 ;	Corrupts registers:
 ;		Nothing unless corrupted by callback function
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm	(revision 181)
@@ -93,6 +93,11 @@
 	test	BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
 	jnz		SHORT .GetStolenSegmentToDS
+%ifndef USE_186
 	mov		di, LITE_MODE_RAMVARS_SEGMENT
 	mov		ds, di
+%else
+	push	LITE_MODE_RAMVARS_SEGMENT
+	pop		ds
+%endif
 	ret
 
@@ -183,6 +188,6 @@
 	LOAD_BDA_SEGMENT_TO	es, cx, !		; Zero CX
 	call	RamVars_GetCountOfKnownDrivesToDL
-	MAX_U	dl, [es:BDA.bHDCount]
-	mov		cl, dl
+	mov		cl, [es:BDA.bHDCount]
+	MAX_U	cl, dl
 
 	pop		dx
Index: /trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- /trunk/XTIDE_Universal_BIOS/makefile	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS/makefile	(revision 181)
@@ -65,5 +65,5 @@
 # Assembler preprocessor defines.                               #
 #################################################################
-DEFINES = INCLUDE_MENU_LIBRARY EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS MODULE_EBIOS
+DEFINES = INCLUDE_MENU_LIBRARY EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS MODULE_EBIOS MODULE_SERIAL
 DEFINES_XT = ELIMINATE_CGA_SNOW
 DEFINES_XTPLUS = ELIMINATE_CGA_SNOW USE_186
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm	(revision 181)
@@ -92,11 +92,7 @@
 	call	Registers_ExchangeDSSIwithESDI
 	call	FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
-	jnc		SHORT .StoreFileNameToCfgvarsFromESDI
-
-	pop		es
-	ret
-
-ALIGN JUMP_ALIGN
-.StoreFileNameToCfgvarsFromESDI:
+	jc		SHORT .ReturnError
+
+	; Store filename to Cfgvars from ESDI
 	push	cx
 
@@ -107,8 +103,10 @@
 	cld
 	call	String_CopyDSSItoESDIandGetLengthToCX
+	clc
 
 	pop		cx
+ALIGN JUMP_ALIGN
+.ReturnError:
 	pop		es
-	clc
 	ret
 
@@ -157,5 +155,5 @@
 	xor		dx, dx
 	shl		cx, 1
-	rcl		dx, 1			; WORDs to BYTEs	
+	rcl		dx, 1			; WORDs to BYTEs
 
 	mov		al, FILE_ACCESS.WriteOnly
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm	(revision 181)
@@ -159,12 +159,5 @@
 ALIGN JUMP_ALIGN
 Dialogs_DisplayProgressDialogForFlashingWithDialogIoInDSSIandFlashvarsInDSBX:
-	call	.InitializeProgressDialogIoInDSSIwithFlashvarsInDSBX
-	mov		dx, ds
-	mov		ax, bx
-	CALL_MENU_LIBRARY StartProgressTaskWithIoInDSSIandParamInDXAX
-	ret
-
-ALIGN JUMP_ALIGN
-.InitializeProgressDialogIoInDSSIwithFlashvarsInDSBX:
+	; Initialize progress dialog I/O in DS:SI with flashvars in DS:BX
 	call	InitializeDialogInputFromDSSI
 	mov		WORD [si+DIALOG_INPUT.fszTitle], g_szFlashTitle
@@ -177,4 +170,9 @@
 	mov		WORD [si+PROGRESS_DIALOG_IO.fnTaskWithParamInDSSI], Flash_EepromWithFlashvarsInDSSI
 	mov		[si+PROGRESS_DIALOG_IO.fnTaskWithParamInDSSI+2], cs
+	; Init done
+
+	mov		dx, ds
+	mov		ax, bx
+	CALL_MENU_LIBRARY StartProgressTaskWithIoInDSSIandParamInDXAX
 	ret
 
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm	(revision 181)
@@ -169,5 +169,5 @@
 	call	Buffers_IsXtideUniversalBiosSignatureInESDI
 	je		SHORT .RomFound
-	add		bx, 200h				; Increment by 8kB
+	add		bh, 2					; Increment by 8kB
 	jnc		SHORT .SegmentLoop		; Loop until segment overflows
 	clc
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Flash.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Flash.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Flash.asm	(revision 181)
@@ -1,7 +1,3 @@
-; File name		:	Flash.asm
 ; Project name	:	XTIDE Universal BIOS Configurator v2
-; Created date	:	1.12.2010
-; Last update	:	3.12.2010
-; Author		:	Tomi Tilli
 ; Description	:	Functions for flashing the EEPROM.
 
@@ -37,5 +33,9 @@
 
 	loop	.FlashNextPage
+%if FLASH_RESULT.success = 0	; Just in case this should ever change
+	mov		[bp+FLASHVARS.flashResult], cl
+%else
 	mov		BYTE [bp+FLASHVARS.flashResult], FLASH_RESULT.success
+%endif
 	ret
 
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm	(revision 181)
@@ -135,9 +135,8 @@
 .KeyStrokeInAX:
 	cmp		ah, KEY_DISPLAY_ITEM_HELP
-	je		SHORT .DisplayHelp
-	jmp		SHORT .EventNotHandled
-
-ALIGN JUMP_ALIGN
-.DisplayHelp:
+	jne		SHORT .EventNotHandled
+
+;ALIGN JUMP_ALIGN
+;.DisplayHelp:
 	call	Menupage_GetActiveMenupageToDSDI
 	CALL_MENU_LIBRARY GetHighlightedItemToAX
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm	(revision 181)
@@ -150,6 +150,4 @@
 	add		di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
 	jmp		[cs:bx+.rgfnJumpToStoreValueBasedOnItemType]
-.InvalidItemType:
-	ret
 
 ALIGN WORD_ALIGN
@@ -242,4 +240,5 @@
 	CALL_MENU_LIBRARY GetHighlightedItemToAX
 	CALL_MENU_LIBRARY RefreshItemFromAX
+.InvalidItemType:
 	ret
 
@@ -268,13 +267,4 @@
 ALIGN JUMP_ALIGN
 Menuitem_GetValueToAXfromMenuitemInDSSI:
-	call	.GetMenuitemValueToAX
-	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
-	jnz		SHORT .ConvertWordToByteValue
-	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
-	jnz		SHORT .ConvertWordToFlagValue
-	ret
-
-ALIGN JUMP_ALIGN
-.GetMenuitemValueToAX:
 	push	es
 	push	di
@@ -284,20 +274,19 @@
 	pop		di
 	pop		es
-	ret
-
+
+	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
+	jnz		SHORT .ConvertWordToByteValue
+	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
+	jz		SHORT .Return
+
+	test	ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
+	mov		ax, TRUE<<1		; Shift for lookup
+	jnz		SHORT .Return
+	xor		ax, ax
 ALIGN JUMP_ALIGN
 .ConvertWordToByteValue:
 	xor		ah, ah
-	ret
-
-ALIGN JUMP_ALIGN
-.ConvertWordToFlagValue:
-	test	ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
-	jnz		SHORT .ReturnTrue
-	xor		ax, ax
-	ret
-ALIGN JUMP_ALIGN
-.ReturnTrue:
-	mov		ax, TRUE<<1		; Shift for lookup
+ALIGN JUMP_ALIGN, ret
+.Return:
 	ret
 
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm	(revision 181)
@@ -168,5 +168,5 @@
 	call	.GetIdeControllerCountToCX
 	dec		cx			; Primary always enabled
-	jcxz	.PrimaryControllerAlreadyEnabled
+	jz		.PrimaryControllerAlreadyEnabled
 	mov		bx, g_MenuitemConfigurationSecondaryIdeController
 ALIGN JUMP_ALIGN
@@ -191,13 +191,13 @@
 	call	Buffers_GetRomvarsFlagsToAX
 	test	ax, FLG_ROMVARS_FULLMODE
+	mov		al, 1	; Assume lite mode
 	jz		SHORT .AllowOnlyOneIdeControllerInLiteMode
 
 	mov		bx, ROMVARS.bIdeCnt
 	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
-	eMOVZX	cx, al
-	ret
 ALIGN JUMP_ALIGN
 .AllowOnlyOneIdeControllerInLiteMode:
-	mov		cx, 1
+	cbw		; A maximum of 127 controllers should be sufficient
+	xchg	cx, ax
 	ret
 
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm	(revision 181)
@@ -390,5 +390,5 @@
 	mov		al, 0FEh				; System reset (AT+ keyboard controller)
 	out		64h, al					; Reset computer (AT+)
-	mov		ax, 10
+	mov		al, 10
 	call	Delay_MicrosecondsFromAX
 .ResetXT:
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/makefile
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/makefile	(revision 180)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/makefile	(revision 181)
@@ -58,5 +58,5 @@
 # Assembler preprocessor defines.                               #
 #################################################################
-DEFINES =
+DEFINES = EXCLUDE_FROM_XTIDECFG
 DEFINES_XT = ELIMINATE_CGA_SNOW
 DEFINES_XTPLUS = USE_186 ELIMINATE_CGA_SNOW
