Index: /trunk/Assembly_Library/Inc/Delay.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Delay.inc	(revision 567)
+++ /trunk/Assembly_Library/Inc/Delay.inc	(revision 568)
@@ -5,6 +5,6 @@
 
 ;--------------------------------------------------------------------
-; Clears prefetch queue by jumping to next instruction.
-; This delays much more than nop instruction of fast systems.
+; Clears prefetch queue by jumping to the next instruction.
+; This delays much more than the nop instruction on fast systems.
 ;
 ; JMP_DELAY
Index: /trunk/Assembly_Library/Inc/Emulate.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Emulate.inc	(revision 567)
+++ /trunk/Assembly_Library/Inc/Emulate.inc	(revision 568)
@@ -74,5 +74,6 @@
 ;--------------------------------------------------------------------
 %macro eSALC 0
-	db		0D6h
+;	db		0D6h
+	salc
 %endmacro
 
Index: /trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 567)
+++ /trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 568)
@@ -623,15 +623,6 @@
 	mov		cx, STRING_DIALOG_IO_size
 	call	Memory_ReserveCXbytesFromStackToDSSI
-	call	.InitializeStringDialogIoInDSSIforInputtingFileName
-
-	CALL_MENU_LIBRARY GetStringWithIoInDSSI
-	mov		al, [si+STRING_DIALOG_IO.bUserCancellation]
-	add		sp, BYTE STRING_DIALOG_IO_size
-	test	al, al		; User cancellation?
-	jnz		SHORT ReturnWithoutHandlingKeystroke
-	jmp		CloseFileDialogAfterSuccessfulSelection
-
-ALIGN JUMP_ALIGN
-.InitializeStringDialogIoInDSSIforInputtingFileName:
+
+;;;	InitializeStringDialogIoInDSSIforInputtingFileName
 	call	InitializeNullStringsToDialogInputInDSSI
 	mov		WORD [si+DIALOG_INPUT.fszTitle], g_szEnterNewFileOrDirectory
@@ -642,5 +633,12 @@
 	mov		[si+STRING_DIALOG_IO.fpReturnBuffer], ax
 	mov		[si+STRING_DIALOG_IO.fpReturnBuffer+2], es
-	ret
+;;;
+
+	CALL_MENU_LIBRARY GetStringWithIoInDSSI
+	mov		al, [si+STRING_DIALOG_IO.bUserCancellation]
+	add		sp, BYTE STRING_DIALOG_IO_size
+	test	al, al		; User cancellation?
+	jnz		SHORT ReturnWithoutHandlingKeystroke
+	jmp		CloseFileDialogAfterSuccessfulSelection
 
 
Index: /trunk/Assembly_Library/Src/Menu/Dialog/DialogString.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Dialog/DialogString.asm	(revision 567)
+++ /trunk/Assembly_Library/Src/Menu/Dialog/DialogString.asm	(revision 568)
@@ -99,6 +99,10 @@
 	mov		cx, [si+STRING_DIALOG_IO.wBufferSize]
 	les		di, [si+STRING_DIALOG_IO.fpReturnBuffer]
-	call	.GetCharacterFilterFunctionToDX
+	mov		dx, [si+STRING_DIALOG_IO.fnCharFilter]
+	test	dx, dx
+	jnz		SHORT .CharacterFilterFunctionInDX
+	mov		dx, Char_CharIsValid
 
+.CharacterFilterFunctionInDX:
 	call	Keyboard_ReadUserInputtedStringToESDIWhilePrinting
 	jz		SHORT .UserCancellation
@@ -108,22 +112,2 @@
 .UserCancellation:
 	ret
-
-;--------------------------------------------------------------------
-; .GetCharacterFilterFunctionToDX
-;	Parameters
-;		DS:SI:	Ptr to STRING_DIALOG_IO
-;		SS:BP:	Ptr to DIALOG
-;	Returns:
-;		CS:DX:	Ptr to character filter function
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.GetCharacterFilterFunctionToDX:
-	mov		dx, [si+STRING_DIALOG_IO.fnCharFilter]
-	test	dx, dx
-	jnz		SHORT .ReturnFilterFunctionInDX
-	mov		dx, Char_CharIsValid
-ALIGN JUMP_ALIGN, ret
-.ReturnFilterFunctionInDX:
-	ret
Index: /trunk/Assembly_Library/Src/Menu/Dialog/DialogWord.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/Dialog/DialogWord.asm	(revision 567)
+++ /trunk/Assembly_Library/Src/Menu/Dialog/DialogWord.asm	(revision 568)
@@ -93,5 +93,5 @@
 ;		Nothing (User input stored to WORD_DIALOG_IO)
 ;	Corrupts registers:
-;		AX, BX, DX, SI, DI
+;		AX, BX, CX, DX, SI, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -100,5 +100,5 @@
 	eMOVZX	bx, [si+WORD_DIALOG_IO.bNumericBase]
 ALIGN JUMP_ALIGN
-.GetUserInputIntilValidOrCancelled:
+.GetUserInputUntilValidOrCancelled:
 	call	Keyboard_ReadUserInputtedWordWhilePrinting
 	jz		SHORT .UserCancellation
@@ -116,18 +116,5 @@
 .InputtedWordNotInRange:
 	call	Keyboard_PlayBellForUnwantedKeystroke
-	call	.ClearInputtedWordFromDialog
-	jmp		SHORT .GetUserInputIntilValidOrCancelled
-
-;--------------------------------------------------------------------
-; .ClearInputtedWordFromDialog
-;	Parameters
-;		SS:BP:	Ptr to DIALOG
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, CX, DX, DI
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.ClearInputtedWordFromDialog:
+	; Clear inputted word from dialog
 	CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
 	xchg	dx, ax
@@ -138,4 +125,4 @@
 
 	xchg	ax, dx
-	JMP_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
-
+	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
+	jmp		SHORT .GetUserInputUntilValidOrCancelled
Index: /trunk/Assembly_Library/Src/Menu/MenuBorders.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuBorders.asm	(revision 567)
+++ /trunk/Assembly_Library/Src/Menu/MenuBorders.asm	(revision 568)
@@ -56,5 +56,5 @@
 	push	RefreshTitleBorders
 	push	MenuBorders_GetNumberOfMiddleCharactersToDX
-	jmp		MenuBorders_AdjustDisplayContextForDrawingBorders
+	jmp		SHORT MenuBorders_AdjustDisplayContextForDrawingBorders
 %endif
 
@@ -120,5 +120,5 @@
 	CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
 
-	mov		si, ATTRIBUTE_CHARS.cBordersAndBackground
+	xor		si, si		; SI = ATTRIBUTE_CHARS.cBordersAndBackground
 	jmp		MenuAttribute_SetToDisplayContextFromTypeInSI
 
@@ -141,37 +141,7 @@
 
 ;--------------------------------------------------------------------
+; RefreshItemBorders
 ; RefreshTitleBorders
-;	Parameters
-;		DX:		Number of times to repeat middle character
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX, CX, SI, DI
-;--------------------------------------------------------------------
-ALIGN MENU_JUMP_ALIGN
-RefreshTitleBorders:
-	call	DrawTopBorderLine
-	eMOVZX	cx, [bp+MENUINIT.bTitleLines]
-	jmp		SHORT DrawTextBorderLinesByCXtimes
-
-;--------------------------------------------------------------------
 ; RefreshInformationBorders
-;	Parameters
-;		DX:		Number of times to repeat middle character
-;		SS:BP:	Ptr to MENU
-;	Returns:
-;		Nothing
-;	Corrupts registers:
-;		AX, BX, CX, SI, DI
-;--------------------------------------------------------------------
-ALIGN MENU_JUMP_ALIGN
-RefreshInformationBorders:
-	call	DrawSeparationBorderLine
-	eMOVZX	cx, [bp+MENUINIT.bInfoLines]
-	jmp		SHORT DrawTextBorderLinesByCXtimes
-
-;--------------------------------------------------------------------
-; RefreshItemBorders
 ;	Parameters
 ;		DX:		Number of times to repeat middle character
@@ -186,10 +156,23 @@
 	call	DrawSeparationBorderLine
 	call	MenuScrollbars_GetMaxVisibleItemsOnPageToCX
-	; Fall to DrawTextBorderLinesByCXtimes
-
-;--------------------------------------------------------------------
+	jmp		SHORT DrawTextBorderLinesByCXtimes
+
+ALIGN MENU_JUMP_ALIGN
+RefreshTitleBorders:
+	call	DrawTopBorderLine
+	mov		cl, [bp+MENUINIT.bTitleLines]
+	jmp		SHORT DrawTextBorderLinesByCLtimes
+
+ALIGN MENU_JUMP_ALIGN
+RefreshInformationBorders:
+	call	DrawSeparationBorderLine
+	mov		cl, [bp+MENUINIT.bInfoLines]
+	; Fall to DrawTextBorderLinesByCLtimes
+
+;--------------------------------------------------------------------
+; DrawTextBorderLinesByCLtimes
 ; DrawTextBorderLinesByCXtimes
 ;	Parameters
-;		CX:		Number of border lines to draw
+;		CL/CX:	Number of border lines to draw
 ;		DX:		Number of times to repeat middle character
 ;		SS:BP:	Ptr to MENU
@@ -199,4 +182,6 @@
 ;		AX, CX, SI, DI
 ;--------------------------------------------------------------------
+DrawTextBorderLinesByCLtimes:
+	xor		ch, ch
 DrawTextBorderLinesByCXtimes:
 	jcxz	.NoBorderLinesToDraw
@@ -213,5 +198,4 @@
 ; DrawSeparationBorderLine
 ; DrawBottomBorderLine
-; DrawTimeoutCounterOverBottomBorderLine
 ; DrawBottomShadowLine
 ; DrawTextBorderLine
@@ -242,8 +226,9 @@
 
 	call	DrawTimeoutCounterString
+	push	dx
 	sub		dx, BYTE MENU_TIMEOUT_STRING_CHARACTERS
 	mov		si, g_BottomBorderWithTimeoutCharacters
 	call	PrintBorderCharactersFromCSSIandShadowCharacter
-	add		dx, BYTE MENU_TIMEOUT_STRING_CHARACTERS
+	pop		dx
 	ret
 
@@ -403,5 +388,7 @@
 	mov		si, ATTRIBUTE_CHARS.cNormalTimeout
 	cmp		di, BYTE MENU_TIMEOUT_SECONDS_FOR_HURRY
-	eCMOVB	si, ATTRIBUTE_CHARS.cHurryTimeout
+	jnb		SHORT .NormalTimeout
+	dec		si			; SI = ATTRIBUTE_CHARS.cHurryTimeout
+.NormalTimeout:
 	call	MenuAttribute_GetToAXfromTypeInSI
 
Index: /trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm
===================================================================
--- /trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm	(revision 567)
+++ /trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm	(revision 568)
@@ -116,21 +116,7 @@
 ALIGN MENU_JUMP_ALIGN
 MenuScrollbars_MoveHighlightedItemByAX:
-	mov		cx, [bp+MENUINIT.wHighlightedItem]
-	add		cx, ax
-	; 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
+	add		ax, [bp+MENUINIT.wHighlightedItem]
+	xchg	cx, ax
 	js		SHORT .RotateNegativeItemInCX
 	sub		cx, dx
Index: /trunk/Assembly_Library/Src/Serial/SerialServer.asm
===================================================================
--- /trunk/Assembly_Library/Src/Serial/SerialServer.asm	(revision 567)
+++ /trunk/Assembly_Library/Src/Serial/SerialServer.asm	(revision 568)
@@ -83,7 +83,7 @@
 
 %ifdef USE_UNDOC_INTEL
-		eSALC	; Clear AL using CF
+		salc	; Clear AL using CF
 %else
-		xor		ax,ax
+		xor		al, al
 %endif
 		inc		dx				; divisor high
@@ -108,7 +108,7 @@
 		pop		dx				; base, interrupts disabled
 %ifdef USE_UNDOC_INTEL
-		eSALC	; Clear AL using CF
+		salc	; Clear AL using CF
 %else
-		xor		ax,ax
+		xor		al, al
 %endif
 		out		dx,al
Index: /trunk/Serial_Server/win32/Win32Serial.h
===================================================================
--- /trunk/Serial_Server/win32/Win32Serial.h	(revision 567)
+++ /trunk/Serial_Server/win32/Win32Serial.h	(revision 568)
@@ -55,5 +55,5 @@
 			log( 0, "Opening named pipe %s (simulating %s baud)", name, baudRate->display );
 
-			pipe = CreateNamedPipeA( name, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE|PIPE_REJECT_REMOTE_CLIENTS, 2, 1024, 1024, 0, NULL );
+			pipe = CreateNamedPipeA( name, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE, 2, 1024, 1024, 0, NULL );
 			if( pipe == INVALID_HANDLE_VALUE )
 				log( -1, "Could not CreateNamedPipe " PIPENAME );
Index: /trunk/Tools/StringsCompress.pl
===================================================================
--- /trunk/Tools/StringsCompress.pl	(revision 567)
+++ /trunk/Tools/StringsCompress.pl	(revision 568)
@@ -217,5 +217,5 @@
 for( $g = 0; $translate_index[$g]; $g++ )
 {
-	print "        db     ".$translate_index[$g]."  ; ".$g."\n";
+	print "\t\tdb     ".$translate_index[$g]."\t; ".$g."\n";
 }
 
@@ -231,5 +231,5 @@
 for( $t = $format_begin; $format_index[$t]; $t++ )
 {
-	print "        db     (DisplayFormatCompressed_BaseFormatOffset - ".$format_index[$t].")    ; ".$t."\n";
+	print "\t\tdb     (DisplayFormatCompressed_BaseFormatOffset - ".$format_index[$t].")\t; ".$t."\n";
 }
 
Index: /trunk/Tools/checksum.pl
===================================================================
--- /trunk/Tools/checksum.pl	(revision 567)
+++ /trunk/Tools/checksum.pl	(revision 568)
@@ -57,4 +57,23 @@
 
 $fixzero = chr(0);
+
+#
+# Compatibility fix for 3Com 3C503 cards. They use 8 KB ROMs and return 8080h as the last word of the ROM.
+#
+if( $desiredSize == 8192 ) {
+	if( $bytes < $desiredSize - 3 ) {
+		while( $bytes < $desiredSize - 3 ) {
+			print FILE $fixzero;
+			$bytes++;
+		}
+		$fixl = ($cs == 0 ? 0 : 256 - $cs);
+		$fix = chr($fixl).chr($cs);
+		print FILE $fix;
+		$bytes += 2;
+	} else {
+		print "Warning! ".$ARGV[0]." cannot be used on a 3Com 3C503 card!\n";
+	}
+}
+
 while( $bytes < $desiredSize - 1 )
 {
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm	(revision 568)
@@ -47,9 +47,15 @@
 %ifdef MODULE_SERIAL	; IDE + Serial
 Device_FinalizeDPT:
-	; needs to check IDEVARS vs. checking the DPT as the serial bit in the DPT is set in the Finalize routine
-	CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF	DEVICE_SERIAL_PORT, .FinalizeDptForSerialPortDevice
+	; Needs to check IDEVARS vs. checking the DPT as the serial bit in the DPT is set in the Finalize routine
+	cmp		BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
+%ifdef USE_386
+	jne		IdeDPT_Finalize
+	jmp		SerialDPT_Finalize
+%else
+	je		SHORT .FinalizeDptForSerialPortDevice
 	jmp		IdeDPT_Finalize
 .FinalizeDptForSerialPortDevice:
 	jmp		SerialDPT_Finalize
+%endif
 
 %else					; IDE
@@ -94,8 +100,14 @@
 %ifdef MODULE_SERIAL	; IDE + Serial
 Device_IdentifyToBufferInESSIwithDriveSelectByteInBH:
-	CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF	DEVICE_SERIAL_PORT, .IdentifyDriveFromSerialPort
+	cmp		BYTE [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT
+%ifdef USE_386
+	jne		IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
+	jmp		SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
+%else
+	je		SHORT .IdentifyDriveFromSerialPort
 	jmp		IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
 .IdentifyDriveFromSerialPort:
 	jmp		SerialCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH
+%endif
 
 %else					; IDE
@@ -122,5 +134,10 @@
 ALIGN JUMP_ALIGN
 Device_OutputCommandWithParameters:
-	TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE .OutputCommandToSerialPort
+	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
+%ifdef USE_386
+	jz		IdeCommand_OutputWithParameters
+	jmp		SerialCommand_OutputWithParameters
+%else
+	jnz		SHORT .OutputCommandToSerialPort
 	jmp		IdeCommand_OutputWithParameters
 
@@ -128,4 +145,5 @@
 .OutputCommandToSerialPort:
 	jmp		SerialCommand_OutputWithParameters
+%endif
 
 %else					; IDE
@@ -147,6 +165,12 @@
 %ifdef MODULE_SERIAL	; IDE + Serial
 Device_SelectDrive:
-	TEST_USING_DPT_AND_JUMP_IF_SERIAL_DEVICE	ReturnSuccessForSerialPort
+	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
+%ifndef USE_386
+	jnz		SHORT ReturnSuccessForSerialPort
 	jmp		IdeCommand_SelectDrive
+%else
+	jz		IdeCommand_SelectDrive
+	; Fall to ReturnSuccessForSerialPort
+%endif
 
 %else					; IDE
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 568)
@@ -189,11 +189,6 @@
 	mov		cl, [bp+PIOVARS.bSectorsLeft]		; CH is already zero
 	push	cx
-%ifdef USE_186
-	push	CheckErrorsAfterTransferringLastBlock
-	jmp		[bp+PIOVARS.fnXfer]					; Transfer possibly partial block
-%else
 	call	[bp+PIOVARS.fnXfer]					; Transfer possibly partial block
 	jmp		SHORT CheckErrorsAfterTransferringLastBlock
-%endif
 
 
@@ -241,5 +236,15 @@
 
 	; Convert ES:SI to physical address
-%ifdef USE_186
+%ifdef USE_386
+
+	mov		dx, es
+	xor		ax, ax
+	shld	ax, dx, 4
+	shl		dx, 4
+	add		si, dx
+	adc		al, ah
+	mov		es, ax
+
+%elifdef USE_186
 						; Bytes	EU Cycles(286)
 	mov		ax, es		; 2		2
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 568)
@@ -322,4 +322,5 @@
 
 ;--------------------------------------------------------------------
+; Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber
 ; Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH
 ; Int13h_SetErrorCodeToIntpackInSSBPfromAH
@@ -330,5 +331,5 @@
 ;		SS:BP:	Ptr to IDEPACK with error condition set
 ;	Corrupts registers:
-;		DS, DI
+;		DS, BX, DI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 568)
@@ -38,5 +38,5 @@
 ;	Returns with INTPACK in SS:BP:
 ;		AH:		Int 13h/40h floppy return status
-;		AL:		Number of sectors actually verified (only valid if CF set for someBIOSes)
+;		AL:		Number of sectors actually verified (only valid if CF set for some BIOSes)
 ;		CF:		0 if successful, 1 if error
 ;--------------------------------------------------------------------
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH43h_ExtendedWriteSectors.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH43h_ExtendedWriteSectors.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH43h_ExtendedWriteSectors.asm	(revision 568)
@@ -48,9 +48,4 @@
 	mov		ah, [cs:bx+g_rgbWriteCommandLookup]
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
-%ifdef USE_186
-	push	AH42h_ReturnFromInt13hAfterStoringErrorCodeFromAHandTransferredSectorsFromCX
-	jmp		Idepack_ConvertDapToIdepackAndIssueCommandFromAH
-%else
 	call	Idepack_ConvertDapToIdepackAndIssueCommandFromAH
 	jmp		SHORT AH42h_ReturnFromInt13hAfterStoringErrorCodeFromAHandTransferredSectorsFromCX
-%endif
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH44h_ExtendedVerifySectors.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH44h_ExtendedVerifySectors.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH44h_ExtendedVerifySectors.asm	(revision 568)
@@ -43,9 +43,4 @@
 	mov		ah, [cs:bx+g_rgbVerifyCommandLookup]
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
-%ifdef USE_186
-	push	AH42h_ReturnFromInt13hAfterStoringErrorCodeFromAHandTransferredSectorsFromCX
-	jmp		Idepack_ConvertDapToIdepackAndIssueCommandFromAH
-%else
 	call	Idepack_ConvertDapToIdepackAndIssueCommandFromAH
 	jmp		SHORT AH42h_ReturnFromInt13hAfterStoringErrorCodeFromAHandTransferredSectorsFromCX
-%endif
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 568)
@@ -147,5 +147,5 @@
 	; from previously scanned drive.
 .DoNotSetChsFlag:
-	eMOVZX	dx, BYTE [es:si+DPT.bPchsHeads]
+	eMOVZX	dx, [es:si+DPT.bPchsHeads]
 	mov		[di+EDRIVE_INFO.dwHeads], dx
 	mov		[di+EDRIVE_INFO.dwHeads+2], cx
@@ -159,6 +159,4 @@
 	mov		[di+EDRIVE_INFO.dwCylinders+2], cx
 
-.ReturnWithSuccess:
-	xor		ax, ax
-.ReturnWithError:
+	xor		ax, ax		; Success
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 568)
@@ -37,6 +37,6 @@
 ALIGN JUMP_ALIGN
 Address_ExtractLCHSparametersFromOldInt13hAddress:
-	mov		bl, cl				; Copy sector number...
-	and		bl, 3Fh				; ...and limit to 1...63
+	mov		bl, 3Fh				; Load sector number mask
+	and		bl, cl				; Sector number now in BL
 	sub		cl, bl				; Remove from cylinder number high
 	eROL_IM	cl, 2				; High bits to beginning
@@ -75,6 +75,6 @@
 	; (LCylinder << n) + (LHead / PHeadCount)
 	mov		dx, cx					; Copy L-CHS Cylinder number to DX
-	mov		cl, [di+DPT.bFlagsLow]	; Load shift count
-	and		cl, MASKL_DPT_CHS_SHIFT_COUNT
+	mov		cl, MASKL_DPT_CHS_SHIFT_COUNT	; Load shift count mask
+	and		cl, [di+DPT.bFlagsLow]	; Shift count now in CL
 	shl		dx, cl					; DX = LCylinder << n
 	add		ax, dx					; AX = P-CHS Cylinder number
@@ -83,4 +83,8 @@
 	ret
 
+; *FIXME* The above function description doesn't match the code.
+; If CX has a maximum value of 1023 on entry then there is no way CX can be 16382 on return.
+; 1023 SHL 3 (MASKL_DPT_CHS_SHIFT_COUNT) is 8184. With the addition of AX (at most 255?)
+; the result is 8439.
 
 ;--------------------------------------------------------------------
@@ -102,16 +106,17 @@
 ALIGN JUMP_ALIGN
 Address_OldInt13hAddressToIdeAddress:
-		call	Address_ExtractLCHSparametersFromOldInt13hAddress
-		ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
+	call	Address_ExtractLCHSparametersFromOldInt13hAddress
+	mov		al, [di+DPT.bFlagsLow]
+	and		al, MASKL_DPT_TRANSLATEMODE
 
 ;;; 0: ADDRESSING_MODE_NORMAL
-		jz		SHORT DoNotConvertLCHS
+	jz		SHORT DoNotConvertLCHS
 
 ;;; 1: ADDRESSING_MODE_LARGE
-		test	al, FLGL_DPT_ASSISTED_LBA
-		jz		SHORT ConvertLargeModeLCHStoPCHS
+	test	al, FLGL_DPT_ASSISTED_LBA
+	jz		SHORT ConvertLargeModeLCHStoPCHS
 
 ;;; 2: ADDRESSING_MODE_ASSISTED_LBA
-		; Fall through to ConvertAssistedLBAModeLCHStoLBARegisterValues
+	; Fall to ConvertAssistedLBAModeLCHStoLBARegisterValues
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm	(revision 568)
@@ -46,5 +46,5 @@
 	; Make sure that sector count is valid
 %ifdef USE_UNDOC_INTEL
-	eSALC	; Clear AL using CF (CF is cleared since JB above fell through)
+	salc	; Clear AL using CF (CF is cleared since JB above fell through)
 	or		al, [es:si+DAP.wSectorCount]
 %else
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm	(revision 568)
@@ -42,4 +42,5 @@
 	; display error code every time user intends to boot from hard disk
 	; when A then C boot order is used.
+	test	dl, dl
 	js		SHORT .PrintFailedToLoadErrorCode	; Hard Drive
 	cmp		ah, RET_HD_TIMEOUT
@@ -48,11 +49,6 @@
 	je		SHORT .ReturnWithCFclearSinceFailedToLoadBootSector
 .PrintFailedToLoadErrorCode:
-%ifdef USE_186
-	push	.ReturnWithCFclearSinceFailedToLoadBootSector
-	jmp		DetectPrint_FailedToLoadFirstSector
-%else
 	call	DetectPrint_FailedToLoadFirstSector
-	jmp		.ReturnWithCFclearSinceFailedToLoadBootSector
-%endif
+	jmp		SHORT .ReturnWithCFclearSinceFailedToLoadBootSector
 
 
@@ -63,5 +59,5 @@
 	jne		SHORT .FirstHardDiskSectorNotBootable
 .AlwaysBootFromFloppyDriveForBooterGames:
-	stc		; Boot Sector loaded succesfully
+	stc		; Boot Sector loaded successfully
 	jmp		SHORT Int19_JumpToBootSectorOrRomBoot
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm	(revision 568)
@@ -136,7 +136,7 @@
 	mov		cx, [di+DPT_ADVANCED_ATA.wMinPioCycleTime]
 	test	si, si
-	jz		SHORT .PioTimingsLoadedToAXandCX
+	jz		SHORT .PioTimingsLoadedToBXandCX
 	MIN_U	bl, [si+DPT_ADVANCED_ATA.bPioMode]
 	MAX_U	cx, [si+DPT_ADVANCED_ATA.wMinPioCycleTime]
-.PioTimingsLoadedToAXandCX:
+.PioTimingsLoadedToBXandCX:
 	ret
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 568)
@@ -107,11 +107,15 @@
 	call	AccessDPT_GetPointerToDRVPARAMStoCSBX
 	push	ds
+
+	push	cs
+	pop		ds
+
+	; Load User Defined CHS or LBA to CX:AX
+	mov		dx, [bx+DRVPARAMS.wFlags]
+	mov		ax, [bx+DRVPARAMS.wCylinders]		; Or .dwMaximumLBA
+	mov		cx, [bx+DRVPARAMS.wHeadsAndSectors]	; Or .dwMaximumLBA+2
+
 	push	es
 	pop		ds		; DS:SI now points to ATA information
-
-	; Load User Defined CHS or LBA to CX:AX
-	mov		dx, [cs:bx+DRVPARAMS.wFlags]
-	mov		ax, [cs:bx+DRVPARAMS.wCylinders]		; Or .dwMaximumLBA
-	mov		cx, [cs:bx+DRVPARAMS.wHeadsAndSectors]	; Or .dwMaximumLBA+2
 
 	; * User defined CHS *
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 568)
@@ -72,7 +72,7 @@
 %endif
 
-	mov		al,[cs:ROMVARS.wFlags]			; Configurator set to always scan?
-	or		al,[es:BDA.bKBFlgs1]			; Or, did the user hold down the ALT key?
-	and		al,8							; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
+	mov		al, [cs:ROMVARS.wFlags]			; Configurator set to always scan?
+	or		al, [es:BDA.bKBFlgs1]			; Or, did the user hold down the ALT key?
+	and		al, 8							; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
 	jnz		.DriveDetectLoop
 %endif
@@ -89,8 +89,6 @@
 ;
 	mov		cx, [RAMVARS.wDrvCntAndFlopCnt]		; Our count of hard disks
-
 	mov		al, [es:BDA.bHDCount]
-	add		cl, al						; Add our drives to the system count
-	mov		[es:BDA.bHDCount], cl
+	add		[es:BDA.bHDCount], cl		; Add our drives to the system count
 	or		al, 80h						; Or in hard disk flag
 	mov		[RAMVARS.bFirstDrv], al		; Store first drive number
@@ -118,10 +116,10 @@
 	inc		ax								; low order bit, indicating floppy drive exists
 
-	mov		ah, [es:BDA.wEquipment]			; Load Equipment WORD low byte
-	and		ah, 03eh						; Mask off drive number and drives present bit
+	mov		ah, 3Eh							; AND mask to AH (all bits set except floppy drive count/present)
+	and		ah, [es:BDA.wEquipment]			; Load Equipment WORD low byte and mask off drive number and drives present bit
 	or		al, ah							; Or in new values
 	mov		[es:BDA.wEquipment], al			; and store
 
-	mov		al, 1eh							; BDA pointer to Floppy DPT
+	mov		al, 1Eh							; BDA pointer to Floppy DPT
 	mov		si, AH8h_FloppyDPT
 	call	Interrupts_InstallHandlerToVectorInALFromCSSI
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 568)
@@ -181,5 +181,5 @@
 	push	ax
 	push	di							; BIOS segment
-	add		al, ROMVARS.szVersion - ROMVARS.szTitle
+	mov		al, ROMVARS.szVersion & 0FFh
 	push	ax
 %else
Index: /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm	(revision 568)
@@ -56,5 +56,6 @@
 ;--------------------------------------------------------------------
 .PushAddressingMode:
-	ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
+	mov		al, [di+DPT.bFlagsLow]
+	and		ax, BYTE MASKL_DPT_TRANSLATEMODE
 	;;
 	;; This multiply both shifts the addressing mode bits down to low order bits, and
@@ -107,5 +108,5 @@
 	eCMOVZ	ah, [di+DPT_ATA.bDevice]	; DPT_ATA contains up to date device information for IDE drives
 %ifdef USE_UNDOC_INTEL
-	eSALC	; Clear AL using CF (from TEST above)
+	salc	; Clear AL using CF (from TEST above)
 	eAAD	g_szDeviceTypeValues_Displacement
 %else
Index: /trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm	(revision 568)
@@ -69,6 +69,6 @@
 .PrintFloppyDriveHotkeys:
 	call	FloppyDrive_GetCountToAX
-	test	ax, ax		; Any Floppy Drives?
-	jz		SHORT .SkipFloppyDriveHotkeys
+	xchg	cx, ax		; Any Floppy Drives?
+	jcxz	.SkipFloppyDriveHotkeys
 
 	mov		ax, (ANGLE_QUOTE_RIGHT << 8) | DEFAULT_FLOPPY_DRIVE_LETTER
Index: /trunk/XTIDE_Universal_BIOS/Src/StringsCompressed.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/StringsCompressed.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/StringsCompressed.asm	(revision 568)
@@ -491,35 +491,35 @@
 
 StringsCompressed_TranslatesAndFormats:
-        db     32  ; 0
-        db     172  ; 1
-        db     171  ; 2
-        db     179  ; 3
-        db     175  ; 4
-        db     33  ; 5
-        db     34  ; 6
-        db     44  ; 7
-        db     45  ; 8
-        db     46  ; 9
-        db     47  ; 10
-        db     49  ; 11
-        db     50  ; 12
-        db     51  ; 13
-        db     53  ; 14
-        db     54  ; 15
-        db     56  ; 16
-        db     200  ; 17
-        db     181  ; 18
-        db     48  ; 19
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_2_I)    ; 20
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_u)    ; 21
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_5_u)    ; 22
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_x)    ; 23
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_5_x)    ; 24
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_nl)    ; 25
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_2_u)    ; 26
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_A)    ; 27
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_c)    ; 28
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_s)    ; 29
-        db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_z)    ; 30
+		db     32	; 0
+		db     172	; 1
+		db     171	; 2
+		db     179	; 3
+		db     175	; 4
+		db     33	; 5
+		db     34	; 6
+		db     44	; 7
+		db     45	; 8
+		db     46	; 9
+		db     47	; 10
+		db     49	; 11
+		db     50	; 12
+		db     51	; 13
+		db     53	; 14
+		db     54	; 15
+		db     56	; 16
+		db     200	; 17
+		db     181	; 18
+		db     48	; 19
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_2_I)	; 20
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_u)	; 21
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_5_u)	; 22
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_x)	; 23
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_5_x)	; 24
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_nl)	; 25
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_2_u)	; 26
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_A)	; 27
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_c)	; 28
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_s)	; 29
+		db     (DisplayFormatCompressed_BaseFormatOffset - DisplayFormatCompressed_Format_z)	; 30
 
 %ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
@@ -560,38 +560,38 @@
 
 ;; translated usage stats
-;; 33:1
-;; 32:35
-;; 181:1
-;; 53:2
-;; 48:2
-;; 200:1
-;; 46:3
-;; 179:8
+;; 54:1
+;; 47:2
+;; 175:1
+;; 49:1
 ;; 44:1
 ;; 50:2
+;; 200:1
+;; 181:1
+;; 172:2
+;; 45:2
+;; 56:8
+;; 33:1
+;; 53:2
+;; 179:8
+;; 171:2
 ;; 51:3
-;; 47:2
-;; 172:2
 ;; 34:3
-;; 49:1
-;; 56:8
-;; 45:2
-;; 175:1
-;; 171:2
-;; 54:1
+;; 48:2
+;; 46:3
+;; 32:35
 ;; total translated: 20
 
 ;; format usage stats
+;; nl:12
+;; x:5
 ;; A:4
+;; 5-x:1
 ;; 2-u:1
+;; z:2
 ;; 5-u:2
-;; x:5
 ;; s:14
-;; 5-x:1
-;; nl:12
 ;; 2-I:1
 ;; u:6
 ;; c:13
-;; z:2
 ;; total format: 11
 
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 568)
@@ -58,5 +58,5 @@
 
 %ifdef USE_UNDOC_INTEL
-	eSALC	; Clears AL using CF while preserving flags
+	salc	; Clears AL using CF while preserving flags
 %endif
 
@@ -163,25 +163,5 @@
 ;--------------------------------------------------------------------
 AccessDPT_GetIdevarsToCSBX:
-	eMOVZX	bx, BYTE [di+DPT.bIdevarsOffset]
+	eMOVZX	bx, [di+DPT.bIdevarsOffset]
 	ret
 
-
-;--------------------------------------------------------------------
-; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
-;	Parameters:
-;		DS:DI:	Ptr to Disk Parameter Table
-;	Returns:
-;		AX:		Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA)
-;				unshifted (still shifted where it is in bFlagsLow)
-;		ZF:		Set based on value in AL
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-;
-; Converted to a macro since only called in two places, and the call/ret overhead
-; is not worth it for these two instructions (4 bytes total)
-;
-%macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0
-	mov		al, [di+DPT.bFlagsLow]
-	and		ax, BYTE MASKL_DPT_TRANSLATEMODE
-%endmacro
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 568)
@@ -142,5 +142,4 @@
 ; GetSectorCountToDXAXfromCHSinAXBLBH
 ;	Parameters:
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
 ;		AX:		Number of cylinders (1...16383)
 ;		BL:		Number of heads (1...255)
@@ -328,7 +327,7 @@
 	cmp		ax, cx
 	jbe		SHORT .NumberOfHeadsNowInCX
-	eSHL_IM	cl, 1						; Double number of heads
-	jnz		SHORT .CompareNextValidNumberOfHeads	; Reached 256 heads?
-	dec		cl							;  If so, limit heads to 255
+	eSHL_IM	cx, 1						; Double number of heads
+	jpo		SHORT .CompareNextValidNumberOfHeads	; Reached 256 heads?
+	dec		cx							;  If so, limit heads to 255
 .NumberOfHeadsNowInCX:
 	mov		bx, cx						; Number of heads are returned in BL
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm	(revision 568)
@@ -114,18 +114,18 @@
 ;--------------------------------------------------------------------
 FillTranslatedDPTtoESDIfromDPTinDSSI:
-	xor		dx, dx						; Clear for checksum
+	cwd									; Clear for checksum
 	call	StoswThenAddALandAHtoDL		; Bytes 0 and 1 (Logical number of cylinders)
 
-	mov		al, BYTE [si+DPT.bLchsHeads]
+	mov		al, [si+DPT.bLchsHeads]
 	mov		ah, TRANSLATED_DPT_SIGNATURE
 	call	StoswThenAddALandAHtoDL		; Bytes 2 (Logical number of heads) and 3 (Axh signature to indicate Translated DPT)
 
-	eMOVZX	ax, BYTE [si+DPT.bPchsSectorsPerTrack]
+	eMOVZX	ax, [si+DPT.bPchsSectorsPerTrack]
 	call	StoswThenAddALandAHtoDL		; Bytes 4 (Physical sectors per track) and 5 (Write Precompensation Cylinder low)
 
-	mov		al, ah
-	call	StoswThenAddALandAHtoDL		; Bytes 6 (Write Precompensation Cylinder high) and 7
-
-	xchg	ax, cx						; Device Control byte to AL
+	mov		al, ah						; Zero AX
+	stosw								; Bytes 6 (Write Precompensation Cylinder high) and 7
+
+	xchg	cx, ax						; Device Control byte to AL, zero to CX
 	mov		ah, [si+DPT.wPchsCylinders]
 	call	StoswThenAddALandAHtoDL		; Bytes 8 (Drive Control Byte) and 9 (Physical number of cylinders low)
@@ -135,6 +135,6 @@
 	call	StoswThenAddALandAHtoDL		; Bytes 10 (Physical number of cylinders high) and 11 (Physical number of heads)
 
-	xor		ax, ax
-	call	StoswThenAddALandAHtoDL		; Bytes 12 and 13 (Landing Zone Cylinder)
+	xchg	cx, ax						; Zero to AX
+	stosw								; Bytes 12 and 13 (Landing Zone Cylinder)
 
 	mov		al, [si+DPT.bLchsSectorsPerTrack]
@@ -158,5 +158,5 @@
 ;		DI:		Incremented by 2
 ;	Corrupts registers:
-;		Nothing
+;		AH
 ;--------------------------------------------------------------------
 StoswALandChecksumFromDL:
@@ -182,12 +182,24 @@
 FillStandardDPTtoESDIfromDPTinDSSI:
 	stosw				; Bytes 0 and 1 (Physical number of cylinders)
-	eMOVZX	ax, BYTE [si+DPT.bLchsHeads]
+	eMOVZX	ax, [si+DPT.bLchsHeads]
 	stosw				; Bytes 2 (Physical number of heads) and 3
+%ifdef USE_UNDOC_INTEL
+%ifdef USE_386
+	xor		al, al		; Zero AX and clear CF
+%else
+	salc				; Zero AX (CF cleared by eMOVZX above)
+%endif
+%else
 	mov		al, ah		; Zero AX
+%endif
 	stosw				; Bytes 4 and 5 (Write Precompensation Cylinder low)
 	stosw				; Bytes 6 (Write Precompensation Cylinder high) and 7
 	mov		al, cl		; Device control byte to AL
 	stosw				; Bytes 8 (Drive Control Byte) and 9
+%ifdef USE_UNDOC_INTEL
+	salc				; Zero AX (CF cleared above)
+%else
 	mov		al, ah		; Zero AX
+%endif
 	stosw				; Bytes 10 and 11
 	stosw				; Bytes 12 and 13 (Landing Zone Cylinder)
@@ -208,8 +220,8 @@
 ;		ES:BX:	Ptr to Device Parameter Table Extension (DPTE)
 ;	Corrupts registers:
-;		AX, CX, DX, DI
+;		AX, CX, DL, DI
 ;--------------------------------------------------------------------
 CompatibleDPT_CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI:
-	call	GetTemporaryBufferForDPTEtoESDI	; valid until next AH=48h call
+	call	GetTemporaryBufferForDPTEtoESDI	; Valid until next AH=48h call
 
 	; Set 32-bit flag for 32-bit controllers
@@ -218,4 +230,6 @@
 	eCMOVE	cl, FLG_LBA_TRANSLATION_ENABLED | FLG_32BIT_XFER_MODE
 
+	xor		dl, dl							; Clear DL for checksum
+
 	; DPTE.wBasePort
 	mov		ax, [si+DPT.wBasePort]
@@ -223,5 +237,5 @@
 
 	; DPTE.wControlBlockPort
-	eMOVZX	bx, BYTE [si+DPT.bIdevarsOffset]
+	eMOVZX	bx, [si+DPT.bIdevarsOffset]
 	mov		ax, [cs:bx+IDEVARS.wControlBlockPort]
 	call	StoswThenAddALandAHtoDL			; Bytes 2 and 3
@@ -244,13 +258,14 @@
 	; DPTE.bDmaChannelAndType and DPTE.bPioMode
 	xor		ax, ax
-%ifdef MODULE_ADVANCED_ATA
+%ifndef MODULE_ADVANCED_ATA
+	stosw									; Bytes 8 and 9
+%else
 	or		ah, [si+DPT_ADVANCED_ATA.bPioMode]
 	jz		SHORT .DoNotSetFastPioFlag
-	cmp		WORD [si+DPT_ADVANCED_ATA.wControllerID], BYTE 0
-	je		SHORT .DoNotSetFastPioFlag
-	inc		cx		; FLG_FAST_PIO_ENABLED
+	cmp		WORD [si+DPT_ADVANCED_ATA.wControllerID], BYTE 1
+	sbb		cl, -1	; FLG_FAST_PIO_ENABLED (if .wControllerID > 0)
 .DoNotSetFastPioFlag:
-%endif
 	call	StoswThenAddALandAHtoDL			; Bytes 8 and 9
+%endif
 
 	; Set CHS translation flags and store DPTE.wFlags
@@ -261,5 +276,5 @@
 	test	al, FLGL_DPT_ASSISTED_LBA
 	jz		SHORT .NoChsTranslationOrBitShiftTranslationSet
-	or		cx, LBA_ASSISTED_TRANSLATION << TRANSLATION_TYPE_FIELD_POSITION
+	or		ch, LBA_ASSISTED_TRANSLATION << (TRANSLATION_TYPE_FIELD_POSITION - 8)
 .NoChsTranslationOrBitShiftTranslationSet:
 	xchg	ax, cx
@@ -268,11 +283,10 @@
 	; DPTE.wReserved (must be zero)
 	xor		ax, ax
-	call	StoswThenAddALandAHtoDL			; Bytes 12 and 13
+	stosw									; Bytes 12 and 13
 
 	; DPTE.bRevision and DPTE.bChecksum
 	mov		al, DPTE_REVISION
-	call	StoswALandChecksumFromDL		; Bytes 14 and 15
-	lea		bx, [di-DPTE_size]
-	ret
+	lea		bx, [di+2-DPTE_size]			; The +2 compensates for the last WORD yet to be stored
+	jmp		StoswALandChecksumFromDL		; Bytes 14 and 15
 %endif ; MODULE_EBIOS
 
Index: /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 568)
@@ -116,11 +116,9 @@
 	jnz		SHORT .NothingToChange
 
-.LimitHeadsForLargeAddressingMode:
 	; We cannot have 16 P-Heads heads in Revised ECHS mode (8193 or more cylinders)
 	; but 16 heads are allowed when there are 8192 or less cylinders (ECHS).
 	; Both of these are LARGE modes so do not confuse with NORMAL mode.
 	call	AtaGeometry_IsDriveSmallEnoughForECHS
-	jc		SHORT .NothingToChange
-	dec		bx						; Adjust 16 P-Heads to 15
+	adc		bx, -1					; Adjust 16 P-Heads to 15 if needed
 
 .NothingToChange:
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm	(revision 568)
@@ -159,5 +159,5 @@
 	call	Buffers_IsXtideUniversalBiosSignatureInESDI
 	je		SHORT .RomFound
-	add		bh, 2					; Increment by 8kB
+	add		bx, 80h					; Increment by 2kB (minimum possible distance from the beginning of one option ROM to the next)
 	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 567)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Flash.asm	(revision 568)
@@ -83,5 +83,5 @@
 
 	push	cx
-	call	.GetSdpCommandFunctionToDXwithFlashvarsInSSBP
+	call	.GetSdpCommandFunctionToAXwithFlashvarsInSSBP
 	mov		cx, [bp+FLASHVARS.wEepromPageSize]
 	mov		si, [bp+FLASHVARS.fpNextSourcePage]
@@ -94,18 +94,18 @@
 
 ;--------------------------------------------------------------------
-; .GetSdpCommandFunctionToDXwithFlashvarsInSSBP
-;	Parameters:
-;		SS:BP:	Ptr to FLASHVARS
-;	Returns:
-;		DX:		Ptr to SDP Command function
+; .GetSdpCommandFunctionToAXwithFlashvarsInSSBP
+;	Parameters:
+;		SS:BP:	Ptr to FLASHVARS
+;	Returns:
+;		AX:		Ptr to SDP Command function
 ;	Corrupts registers:
 ;		BX, SI
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
-.GetSdpCommandFunctionToDXwithFlashvarsInSSBP:
+.GetSdpCommandFunctionToAXwithFlashvarsInSSBP:
 	eMOVZX	bx, [bp+FLASHVARS.bEepromSdpCommand]
 	mov		si, [cs:bx+.rgpSdpCommandToEepromTypeLookupTable]
 	mov		bl, [bp+FLASHVARS.bEepromType]
-	mov		dx, [cs:bx+si]
+	mov		ax, [cs:bx+si]
 	ret
 
@@ -182,13 +182,15 @@
 ;		Nothing
 ;	Corrupts registers:
-;		Nothing
+;		AX
 ;--------------------------------------------------------------------
 %macro DISABLE_SDP 2
-	mov		BYTE [%1], 0AAh
-	mov		BYTE [%2], 55h
-	mov		BYTE [%1], 80h
-	mov		BYTE [%1], 0AAh
-	mov		BYTE [%2], 55h
-	mov		BYTE [%1], 20h
+	mov		ax, 80AAh
+%%Again:
+	mov		[%1], al		; 0AAh
+	shr		al, 1
+	mov		[%2], al		; 55h
+	mov		[%1], ah		; 80h/20h
+	xor		ax, 0A0FFh
+	jns		SHORT %%Again
 %endmacro
 
@@ -215,10 +217,10 @@
 WriteSdpEnableCommandFor2864mod:
 	ENABLE_SDP 155Ch, 0AA3h
-	jmp		ReturnFromSdpCommand
+	jmp		SHORT ReturnFromSdpCommand
 
 ALIGN JUMP_ALIGN
 WriteSdpEnableCommandFor28256or28512:
 	ENABLE_SDP 5555h, 2AAAh
-	jmp		ReturnFromSdpCommand
+	jmp		SHORT ReturnFromSdpCommand
 
 
@@ -241,14 +243,15 @@
 WriteSdpDisableCommandFor28256or28512:
 	DISABLE_SDP 5555h, 2AAAh
-DoNotWriteAnySdpCommand:
-	jmp		SHORT ReturnFromSdpCommand
-
-
-;--------------------------------------------------------------------
-; WriteNextChangedByteFromPageToEeprom
-;	Parameters:
+	jmp		SHORT ReturnFromSdpCommand
+
+DoNotWriteAnySdpCommand EQU ReturnFromSdpCommand
+
+
+;--------------------------------------------------------------------
+; WriteAllChangedBytesFromPageToEeprom
+;	Parameters:
+;		AX:		Offset to SDP command function
+;		BX:		Offset to next destination byte
 ;		CX:		Number of bytes left to write
-;		DX:		Offset to SDP command function
-;		BX:		Offset to next destination byte
 ;		SI:		Offset to next source byte
 ;		ES:DI:	Ptr to next comparison byte
@@ -258,15 +261,15 @@
 ;				Cleared if page written successfully
 ;	Corrupts registers:
-;		AX, BX, CX, SI, DI, DS, ES
+;		AX, BX, CX, DX, SI, DI, DS, ES
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 WriteAllChangedBytesFromPageToEeprom:
-	mov		ax, [bp+FLASHVARS.fpNextSourcePage+2]		; AX = Source segment
+	mov		dx, [bp+FLASHVARS.fpNextSourcePage+2]		; DX = Source segment
 	mov		ds, [bp+FLASHVARS.fpNextDestinationPage+2]	; DS = EEPROM segment
 	cli						; Disable interrupts
-	jmp		dx				; Write SDP command (once to the beginning of page)
+	jmp		ax				; Write SDP command (once to the beginning of page)
 ALIGN JUMP_ALIGN
 ReturnFromSdpCommand:
-	mov		ds, ax			; DS:SI now points to source byte
+	mov		ds, dx			; DS:SI now points to source byte
 
 ALIGN JUMP_ALIGN
@@ -278,5 +281,5 @@
 	mov		ds, [bp+FLASHVARS.fpNextDestinationPage+2]	; DS:BX now points to EEPROM
 	mov		[bx], al		; Write byte to EEPROM
-	mov		ds, [bp+FLASHVARS.fpNextSourcePage+2]		; Restore DS
+	mov		ds, dx			; Restore DS
 	mov		[bp+FLASHVARS.wLastOffsetWritten], bx
 	mov		[bp+FLASHVARS.bLastByteWritten], al
Index: /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm	(revision 567)
+++ /trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm	(revision 568)
@@ -185,6 +185,6 @@
 	pop		ds
 
-	cmp		word [cs:g_cfgVars+CFGVARS.wEepromSegment], 0
-	jnz		.alreadySet
+	cmp		WORD [cs:g_cfgVars+CFGVARS.wEepromSegment], 0
+	jne		.alreadySet
 
 	push	es
@@ -198,5 +198,5 @@
 	mov		ax, DEFAULT_EEPROM_SEGMENT
 .storeEepromSegment:
-	mov		word [cs:g_cfgVars+CFGVARS.wEepromSegment], ax
+	mov		WORD [cs:g_cfgVars+CFGVARS.wEepromSegment], ax
 
 .alreadySet:
