Index: trunk/XTIDE_Universal_BIOS/Inc/Controllers/Vision.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/Controllers/Vision.inc	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Inc/Controllers/Vision.inc	(revision 558)
@@ -28,5 +28,5 @@
 QD65XX_BASE_PORT					EQU		30h
 QD65XX_ALTERNATIVE_BASE_PORT		EQU		0B0h	; This is the default setting but Intel PIIX4 South Bridge
-													; (and likely other PCI chisets as well) mirror PIC registers here
+													; (and likely other PCI chipsets as well) mirror PIC registers here
 
 ; Vision Register offsets from QD chip base port
Index: trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Inc/Controllers/XTCF.inc	(revision 558)
@@ -26,7 +26,6 @@
 %define XTCF_INC
 
-; XT-CF requires that block must be less than 128 sectors (64 kiB) for DMA
-; transfers.
-; 
+; XT-CF requires that block must be less than 128 sectors (64 kiB) for DMA transfers.
+;
 ; Note: XT-CFv3 DMA will not interfere with PC & PC/XT memory refresh,
 ; since the XT-CFv3 detaches itself from the bus every 16 bytes transferred.
@@ -59,5 +58,5 @@
 ; XT-CFv3 cannot be distinguised by software, so user must decide and set
 ; the mode via a call to Int 13h function 1Eh accordingly (see AH1E_XTCF.asm).
-;;
+;
 XTCF_8BIT_PIO_MODE					EQU		00h
 XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD	EQU		01h
@@ -80,10 +79,8 @@
 ; SET_XTCF_TRANSFER_MODE
 ;	Parameters:
-;		DH:		Mode to select,
-;                               i.e. XTCF_8BIT_PIO_MODE
-;				Note there's no way to know if an
-;				XT-CF adapter supports DMA, so the
-;				user should enable DMA only if a
-;				DMA-enabled XT-CFv3 is fitted.
+;		DH:		Mode to select, i.e. XTCF_8BIT_PIO_MODE
+;				Note there's no way to know if an XT-CF adapter
+;				supports DMA, so the user should enable DMA
+;				only if a DMA-enabled XT-CFv3 is fitted.
 ;		DL:		Drive Number
 ;--------------------------------------------------------------------
@@ -95,8 +92,7 @@
 ;		DL:		Drive Number
 ;	Returns:
-;		DL:		Block mode sectors per block
-;				configured
 ;		DH:		One of the mode values listed above,
-;                               i.e. XTCF_8BIT_PIO_MODE
+;				i.e. XTCF_8BIT_PIO_MODE
+;		DL:		Block mode sectors per block configured
 ;--------------------------------------------------------------------
 GET_XTCF_TRANSFER_MODE				EQU		2
Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 558)
@@ -121,5 +121,5 @@
 STANDARD_CONTROL_BLOCK_OFFSET			EQU		200h
 XTIDE_CONTROL_BLOCK_OFFSET				EQU		8h		; for XTIDE, A3 is used to control selected register (CS0 vs CS1)...
-XTCF_CONTROL_BLOCK_OFFSET				EQU		10h		; ...and for XT-CF (all varients), it's A4
+XTCF_CONTROL_BLOCK_OFFSET				EQU		10h		; ...and for XT-CF (all variants), it's A4
 ADP50L_CONTROL_BLOCK_OFFSET				EQU		10h
 
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDmaBlock.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDmaBlock.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDmaBlock.asm	(revision 558)
@@ -1,7 +1,8 @@
 ; Project name	:	XTIDE Universal BIOS
-; Description	:	IDE Read/Write functions for transferring
-;			block using DMA.
-;			These functions should only be called from IdeTransfer.asm.
+; Description	:	IDE Read/Write functions for transferring block using DMA.
+;					These functions should only be called from IdeTransfer.asm.
+
 ; Modified JJP 05-Jun-13
+
 ;
 ; XTIDE Universal BIOS and Associated Tools
@@ -84,5 +85,5 @@
 	shl		cx, 9									; CX = Block size in BYTEs
 %else
-	xchg		cl, ch
+	xchg	cl, ch
 	shl		cx, 1
 %endif
@@ -92,17 +93,17 @@
 	neg		ax			; 2s compliment
 
-	; if DI was zero carry flag will be cleared (and set otherwise)
+	; If DI was zero carry flag will be cleared (and set otherwise)
 	; When DI is zero only one transfer is required since we've limited the
 	; XT-CFv3 block size to 32k
-	jnc	.TransferLastDmaPageWithSizeInCX
+	jnc		SHORT .TransferLastDmaPageWithSizeInCX
 
 	; CF was set, so DI != 0 and we might need one or two transfers
 	cmp		cx, ax									; if we won't cross a physical page boundary...
-	jbe	SHORT .TransferLastDmaPageWithSizeInCX	; ...perform the transfer in one operation
+	jbe		SHORT .TransferLastDmaPageWithSizeInCX	; ...perform the transfer in one operation
 
 	; Calculate how much we can transfer on first and second rounds
-	xchg		cx, ax			; CX = BYTEs for first page
-	sub		ax, cx			; AX = BYTEs for second page
-	push		ax			; Save bytes for second transfer on stack
+	xchg	cx, ax		; CX = BYTEs for first page
+	sub		ax, cx		; AX = BYTEs for second page
+	push	ax			; Save bytes for second transfer on stack
 
 	; Transfer first DMA page
@@ -126,5 +127,5 @@
 ;		ES:DI updated (CX is added)
 ;	Corrupts registers:
-;		AX
+;		AX, CX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -161,4 +162,12 @@
 	sti															; Enable interrupts
 
+	; Update physical address in ES:DI - since IO might need several calls through this function either from here
+	; if crossing a physical page boundary, or from IdeTransfer.asm if requested sectors was > PIOVARS.wSectorsInBlock
+	; We update the pointer here (before the actual transfer) to avoid having to save the byte count on the stack
+	mov		ax, es						; copy physical page address to ax
+	add		di, cx						; add requested bytes to di
+	adc		al, 0						; and increment physical page address, if required
+	mov		es, ax						; and save it back in es
+
 	; XT-CF transfers 16 bytes at a time. We need to manually start transfer for every block by writing (anything)
 	; to the XT-CFv3 Control Register, which raises DRQ thereby passing system control to the 8237 DMA controller.
@@ -169,16 +178,13 @@
 
 %if 0	; Slow DMA code - works by checking 8237 status register after each 16-byte transfer, until it reports TC has been raised.
-;ALIGN JUMP_ALIGN
-;.TransferNextBlock:
-;	cli									; We want no ISR to read DMA Status Register before we do
-;	out		dx, al						; Transfer up to 16 bytes to/from XT-CF card
-;	in		al, STATUS_REGISTER_DMA8_in
-;	sti
-;	test	al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT
-;	jz		SHORT .TransferNextBlock	; All bytes transferred?
-%endif ; Slow DMA code
-
-%if 1	; Fast DMA code - perform computed number of transfers, then check DMA status register to be sure
-	push	cx							; need byte count to update pointer at the end
+ALIGN JUMP_ALIGN
+.TransferNextBlock:
+	cli									; We want no ISR to read DMA Status Register before we do
+	out		dx, al						; Transfer up to 16 bytes to/from XT-CF card
+	in		al, STATUS_REGISTER_DMA8_in
+	sti
+	test	al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT
+	jz		SHORT .TransferNextBlock	; All bytes transferred?
+%else	; Fast DMA code - perform computed number of transfers, then check DMA status register to be sure
 	add		cx, BYTE 15					; We'll divide transfers in 16-byte atomic transfers,
 	eSHR_IM	cx, 4						; so include any partial block, which will be terminated
@@ -191,13 +197,5 @@
 	test	al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT	; ... for channel 3 terminal count
 	jz		SHORT .TransferNextDmaBlock	; If not set, get more bytes
-	pop		cx							; get back requested bytes
-%endif ; Fast DMA code
-
-	; Update physical address in ES:DI - since IO might need several calls through this function either from here
-	; if crossing a physical page boundary, and from IdeTransfer.asm if requested sectors was > PIOVARS.wSectorsInBlock
-	mov		ax, es						; copy physical page address to ax
-	add		di, cx						; add requested bytes to di
-	adc		al, 0						; and increment physical page address, if required
-	mov		es, ax						; and save it back in es
+%endif
 
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm	(revision 558)
@@ -67,5 +67,5 @@
 	je		SHORT .InputToALfromMemoryMappedRegisterInBX
 	mov		bl, dl
-	mov		bh,	ADP50L_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET >> 8
+	mov		bh, ADP50L_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET >> 8
 
 .InputToALfromMemoryMappedRegisterInBX:
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdePioBlock.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdePioBlock.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdePioBlock.asm	(revision 558)
@@ -1,5 +1,4 @@
 ; Project name	:	XTIDE Universal BIOS
-; Description	:	IDE Read/Write functions for transferring
-;					block using PIO modes.
+; Description	:	IDE Read/Write functions for transferring block using PIO modes.
 ;					These functions should only be called from IdeTransfer.asm.
 
@@ -65,6 +64,6 @@
 ;
 ;	Parameters:
-;		CX:	Block size in 512 byte sectors
-;		DX:	IDE Data port address
+;		CX:		Block size in 512 byte sectors
+;		DX:		IDE Data port address
 ;		ES:DI:	Normalized ptr to buffer to receive data
 ;	Returns:
@@ -100,6 +99,6 @@
 ;
 ;	Parameters:
-;		CX:	Block size in 512 byte sectors
-;		DX:	IDE Data port address
+;		CX:		Block size in 512 byte sectors
+;		DX:		IDE Data port address
 ;		ES:DI:	Normalized ptr to buffer to receive data
 ;	Returns:
@@ -111,5 +110,5 @@
 IdePioBlock_ReadFrom16bitDataPort:
 %ifdef USE_186
-	xchg		cl, ch	; Sectors to WORDs
+	xchg	cl, ch	; Sectors to WORDs
 	rep insw
 	ret
@@ -120,6 +119,6 @@
 .ReadNextOword:
 	%rep 8	; WORDs
-		in		ax, dx	; Read BYTE
-		stosw			; Store BYTE to [ES:DI]
+		in		ax, dx	; Read WORD
+		stosw			; Store WORD to [ES:DI]
 	%endrep
 	loop	.ReadNextOword
@@ -152,6 +151,6 @@
 ; IdePioBlock_WriteToXtideRev1
 ;	Parameters:
-;		CX:	Block size in 512-byte sectors
-;		DX:	IDE Data port address
+;		CX:		Block size in 512-byte sectors
+;		DX:		IDE Data port address
 ;		ES:SI:	Normalized ptr to buffer containing data
 ;	Returns:
@@ -180,6 +179,6 @@
 ; IdePioBlock_WriteToXtideRev2	or rev 1 with swapped A0 and A3 (chuck-mod)
 ;	Parameters:
-;		CX:	Block size in 512-byte sectors
-;		DX:	IDE Data port address
+;		CX:		Block size in 512-byte sectors
+;		DX:		IDE Data port address
 ;		ES:SI:	Normalized ptr to buffer containing data
 ;	Returns:
@@ -191,7 +190,7 @@
 IdePioBlock_WriteToXtideRev2:
 	UNROLL_SECTORS_IN_CX_TO_QWORDS
-	push		ds
-	push		es		; Copy ES...
-	pop			ds		; ...to DS
+	push	ds
+	push	es		; Copy ES...
+	pop		ds		; ...to DS
 ALIGN JUMP_ALIGN
 .WriteNextQword:
@@ -207,6 +206,6 @@
 ; IdePioBlock_WriteTo8bitDataPort
 ;	Parameters:
-;		CX:	Block size in 512-byte sectors
-;		DX:	IDE Data port address
+;		CX:		Block size in 512-byte sectors
+;		DX:		IDE Data port address
 ;		ES:SI:	Normalized ptr to buffer containing data
 ;	Returns:
@@ -225,9 +224,9 @@
 %else ; If 8088/8086
 	UNROLL_SECTORS_IN_CX_TO_QWORDS
-	push		ds
-	;mov		ax, es
-	;mov		ds, ax	; move es to ds via ax (does this run faster on 8088?)
-	push		es
-	pop			ds
+	push	ds
+	;mov	ax, es
+	;mov	ds, ax	; move es to ds via ax (does this run faster on 8088?)
+	push	es
+	pop		ds
 ALIGN JUMP_ALIGN
 .WriteNextQword:
@@ -248,6 +247,6 @@
 ; IdePioBlock_WriteTo32bitDataPort		VLB/PCI 32-bit IDE
 ;	Parameters:
-;		CX:	Block size in 512-byte sectors
-;		DX:	IDE Data port address
+;		CX:		Block size in 512-byte sectors
+;		DX:		IDE Data port address
 ;		ES:SI:	Normalized ptr to buffer containing data
 ;	Returns:
@@ -274,6 +273,6 @@
 .WriteNextQword:
 	%rep 4	; WORDs
-		lodsw			; Load BYTE from [DS:SI]
-		out	dx, ax		; Write BYTE
+		lodsw			; Load WORD from [DS:SI]
+		out	dx, ax		; Write WORD
 	%endrep
 	loop	.WriteNextQword
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 558)
@@ -209,5 +209,5 @@
 ;		ES:SI:	Normalized pointer
 ;		AH:		INT 13h Error Code (only when CF set)
-;		CF:		Set of failed to normalize pointer (segment overflow)
+;		CF:		Set if failed to normalize pointer (segment overflow)
 ;				Cleared if success
 ;	Corrupts registers:
@@ -295,5 +295,5 @@
 	ret
 %endif ; MODULE_8BIT_IDE_ADVANCED
-	; Fall to IdeTransfer_NormalizePointerInESSI if no MODULE_8BIT_IDE
+	; Fall to IdeTransfer_NormalizePointerInESSI if no MODULE_8BIT_IDE_ADVANCED
 
 
@@ -305,6 +305,6 @@
 ;	Returns:
 ;		ES:SI:	Normalized pointer (SI = 0...15)
-;		AH:		INT 13h Error Code (only when CF set)
-;		CF:		Set of failed to normalize pointer (segment overflow)
+;		AH:		INT 13h Error Code (when USE_AT defined and normalization was attempted)
+;		CF:		Set if failed to normalize pointer (segment overflow)
 ;				Cleared if success
 ;	Corrupts registers:
@@ -319,5 +319,5 @@
 %ifdef USE_AT
 	xor		dl, dl
-	shl		dx, 1
+	eSHL_IM	dx, 1
 	dec		dx		; Prevents normalization when bytes + offset will be zero
 	add		dx, si
@@ -329,8 +329,7 @@
 	NORMALIZE_FAR_POINTER	es, si, ax, dx
 %ifdef USE_AT		; CF is always clear for XT builds
-	jc		SHORT .SegmentOverflow
-	ret
-.SegmentOverflow:
-	mov		ah, RET_HD_INVALID
+	; AH = RET_HD_INVALID (01) if CF set, RET_HD_SUCCESS (00) if not. CF unchanged.
+	sbb		ah, ah
+	neg		ah
 %endif
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm	(revision 558)
@@ -67,8 +67,9 @@
 		call	IdeTransfer_NormalizePointerInESSI
 %ifdef USE_AT
-		jnc		SHORT .PointerNormalizationWasSuccessfull
+		jnc		SHORT .PointerNormalizationWasSuccessful
 		xor		cx, cx			; Nothing transferred
-		jmp		SerialCommand_ReturnError
-.PointerNormalizationWasSuccessfull:
+		stc
+		ret
+.PointerNormalizationWasSuccessful:
 %endif
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 558)
@@ -169,5 +169,5 @@
 	mov		[RAMVARS.xlateVars+XLATEVARS.bXlatedDrv], dl
 	push	WORD [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap]
-	mov		WORD [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], 8000h	; No translation
+	call	DriveXlate_Reset			; No translation
 %endif
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm	(revision 558)
@@ -40,4 +40,5 @@
 ;		AH:		Int 13h return status
 ;		CF:		0 if successful, 1 if error
+;		DX:		Command return values (see XTCF.inc)
 ;--------------------------------------------------------------------
 AH1Eh_HandlerForXTCFfeatures:
@@ -46,5 +47,5 @@
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %else
-	push		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
+	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 	; Fall to ProcessXTCFsubcommandFromAL
 %endif
@@ -60,5 +61,4 @@
 ;		AH:		Int 13h return status
 ;		CF:		0 if successful, 1 if error
-;		DX		Command return values (see XTCF.inc)
 ;	Corrupts registers:
 ;		AL, BX, CX, DX, SI
@@ -68,5 +68,5 @@
 	call	AccessDPT_IsThisDeviceXTCF
 	jne		SHORT .XTCFnotFound
-	and		ax, BYTE 7Fh				; Subcommand now in AX (clears AH and CF)
+	and		ax, 0FFh					; Subcommand now in AX (clears AH and CF)
 	jz		SHORT .XTCFfound			; Sub-function IS_THIS_DRIVE_XTCF (=0)
 
@@ -75,23 +75,23 @@
 
 	dec		ax							; Test subcommand for value 2 (GET_XTCF_TRANSFER_MODE)
-	jnz		SHORT .XTCFnotFound			; Invalid subcommand
+	jnz		SHORT .AH1Eh_LoadInvalidCommandToAHandSetCF
 
 	; GET_XTCF_TRANSFER_MODE
 	call	AH1Eh_GetCurrentXTCFmodeToAX
+	mov		dh, al
 	mov		dl, [di+DPT_ATA.bBlockSize]
-	mov		[bp+IDEPACK.intpack+INTPACK.dh], al	; return mode value...
-	mov		[bp+IDEPACK.intpack+INTPACK.dl], dl	; ...and block size, via INTPACK...
+	mov		[bp+IDEPACK.intpack+INTPACK.dx], dx	; Return mode value (DH) and block size (DL) via INTPACK
 .XTCFfound:
-	ret											; ...with AH and CF cleared
+	ret		; With AH and CF cleared
 
 .XTCFnotFound:
 .AH1Eh_LoadInvalidCommandToAHandSetCF:
-	stc					; set carry flag since XT-CF not found
+	stc		; Set carry flag since XT-CF not found or invalid subcommand
 	mov		ah, RET_HD_INVALID
-	ret					; and return
+	ret
 
 .SetXTCFtransferMode:
-	mov		al, [bp+IDEPACK.intpack+INTPACK.dh]	; get specified mode (eg XTCF_DMA_MODE) 
-	; and fall to AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
+	mov		al, [bp+IDEPACK.intpack+INTPACK.dh]	; Get specified mode (eg XTCF_DMA_MODE)
+	; Fall to AH1Eh_ChangeXTCFmodeBasedOnModeInAL
 
 
@@ -102,5 +102,5 @@
 ;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;		SS:BP:	Ptr to IDEPACK
-;	Returns:	
+;	Returns:
 ;		AH:		Int 13h return status
 ;		CF:		0 if successful, 1 if error
@@ -110,13 +110,10 @@
 AH1Eh_ChangeXTCFmodeBasedOnModeInAL:
 	; Note: Control register (as of XT-CFv3) is now a write-only register,
-	;       whos purpose is *only* to raise DRQ.  The register cannot be read.
+	;       whose purpose is *only* to raise DRQ.  The register cannot be read.
 	;       Selected transfer mode is stored in BIOS variable (DPT_ATA.bDevice).
 
-	; We always need to enable 8-bit mode since 16-bit mode is restored
-	; when controller is reset (AH=00h or 0Dh)
-	; 
 	; Note that when selecting 'DEVICE_8BIT_PIO_MODE_WITH_BIU_OFFLOAD' mode,
 	; the ATA device (i.e. CompactFlash card) will operate in 8-bit mode, but
-	; data will be transferred from it's data register using 16-bit CPU instructions
+	; data will be transferred from its data register using 16-bit CPU instructions
 	; like REP INSW.  This works because XT-CF adapters are 8-bit cards, and
 	; the BIU in the machine splits each WORD requested by the CPU into two 8-bit
@@ -125,33 +122,37 @@
 	; the data for presentation to the CPU.
 	;
-	; Also note though that some machines, noteably AT&T PC6300, have hardware
-	; errors in the BIU logic, resulting in reversed byte ordering.  Therefore,
-	; mode DEVICE_8BIT_PIO is the default transfer mode for best system
-	; compatibility.
+	; Also note that some machines, noteably the Olivetti M24 (also known as
+	; the AT&T PC6300 and Xerox 6060), have hardware errors in the BIU logic,
+	; resulting in reversed byte ordering.  Therefore, mode DEVICE_8BIT_PIO is
+	; the default transfer mode for best system compatibility.
 
+	; We always need to enable 8-bit mode since 16-bit mode is restored
+	; when controller is reset (AH=00h or 0Dh)
 	ePUSH_T	bx, AH23h_Enable8bitPioMode
 
 	; Convert mode to device type (see XTCF.inc for full details)
 	and		ax, 3
-	jz	SHORT .Set8bitPioMode	; XTCF_8BIT_PIO_MODE = 0
-	dec		ax					; XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD = 1
-	jz	SHORT .Set8bitPioModeWithBIUOffload
+	jz		SHORT .Set8bitPioMode	; XTCF_8BIT_PIO_MODE = 0
+	dec		ax						; XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD = 1
+	jz		SHORT .Set8bitPioModeWithBIUOffload
 
 	; XTCF_DMA_MODE = 2 (allow 3 as well for more optimized code)
 	mov		BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
 
-	; DMA transfers have limited block sizee
+	; DMA transfers have limited block size
 	mov		al, [di+DPT_ATA.bBlockSize]
-	MIN_U	al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
-	jmp		AH24h_SetBlockSize
-	; exit via ret in AH24_SetBlockSize then through AH23h_Enable8bitPioMode
+	cmp		al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
+	jbe		SHORT AH24h_SetBlockSize
+	mov		al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
+	jmp		SHORT AH24h_SetBlockSize
 
 .Set8bitPioMode:
-	mov		BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8
-	ret		; through AH23h_Enable8bitPioMode
+	mov		al, DEVICE_8BIT_XTCF_PIO8
+	SKIP2B	bx
 
 .Set8bitPioModeWithBIUOffload:
-	mov		BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
-	ret		; through AH23h_Enable8bitPioMode
+	mov		al, DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
+	mov		[di+DPT_ATA.bDevice], al
+	ret
 
 
@@ -160,5 +161,5 @@
 ;	Parameters:
 ;		DS:DI:	Ptr to DPT (in RAMVARS segment)
-;	Returns:	
+;	Returns:
 ;		AX:		XT-CF mode (XTCF_8BIT_PIO_MODE, XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD or XTCF_DMA_MODE)
 ;		CF:		Clear
@@ -167,6 +168,7 @@
 ;--------------------------------------------------------------------
 AH1Eh_GetCurrentXTCFmodeToAX:
-	eMOVZX	ax, BYTE [di+DPT_ATA.bDevice]	; get current mode from DPT
-	sub		al, DEVICE_8BIT_XTCF_PIO8
-	shr		ax, 1							; Device type to XT-CF mode
+	mov		al, [di+DPT_ATA.bDevice]
+	shr		al, 1
+	cbw
+	sub		al, DEVICE_8BIT_XTCF_PIO8 >> 1
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm	(revision 558)
@@ -84,7 +84,11 @@
 	pop		bx			; Pop block size to BL
 	jc		SHORT .DisableBlockMode
-	mov		bh, bl		; BL and BH both have block size we tried to set
-	dec		bh
-	jz		SHORT .DisableBlockMode
+
+	; All valid block sizes are powers of 2 which means BL have just one bit set (parity odd).
+	; Incrementing BX will cause all block sizes except 1 to have two bits set (parity even).
+	; Note that PF reflects only the lowest 8 bits of any register being modified.
+	inc		bx						; 1 -> 2 ?
+	jpo		SHORT .DisableBlockMode	; Jump if BL = 2
+	dec		bx						; Restore block size (was larger than 1)
 
 	; Enable block mode and store block size
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 558)
@@ -112,10 +112,9 @@
 
 
+%ifdef MODULE_8BIT_IDE_ADVANCED
 ;;; Set XT-CF mode
-%ifdef MODULE_8BIT_IDE_ADVANCED
 	call	AH1Eh_GetCurrentXTCFmodeToAX
 	call	AH9h_SetModeFromALtoXTCF
 	STORE_ERROR_FLAG_TO_DPT		FLG_INITERROR_FAILED_TO_SET_XTCF_MODE
-.DoNotSetXTCFmode:
 %endif	; MODULE_8BIT_IDE_ADVANCED
 
@@ -124,5 +123,4 @@
 	call	AH9h_Enable8bitModeForDevice8bitAta
 	STORE_ERROR_FLAG_TO_DPT		FLG_INITERROR_FAILED_TO_SET_8BIT_MODE
-.DoNotSet8bitMode:
 %endif ; MODULE_8BIT_IDE
 
@@ -138,5 +136,4 @@
 	call	Idepack_StoreNonExtParametersAndIssueCommandFromAL
 	STORE_ERROR_FLAG_TO_DPT		FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS
-.SkipInitializeDeviceParameters:
 
 
@@ -302,3 +299,3 @@
 	jne		SHORT IgnoreInvalidCommandError
 	jmp		AH23h_Enable8bitPioMode
-%endif
+%endif ; MODULE_8BIT_IDE
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm	(revision 558)
@@ -45,6 +45,11 @@
 
 	; Make sure that sector count is valid
+%ifdef USE_UNDOC_INTEL
+	eSALC	; Clear AL using CF (CF is cleared since JB above fell through)
+	or		al, [es:si+DAP.wSectorCount]
+%else
 	mov		al, [es:si+DAP.wSectorCount]
 	test	al, al
+%endif
 	jz		SHORT ZeroSectorsRequestedSoNoErrors
 	js		SHORT InvalidNumberOfSectorsRequested
@@ -62,5 +67,5 @@
 	call	Prepare_GetOldInt13hCommandIndexToBX
 	mov		al, [di+DPT.bFlagsLow]
-	shl		al, 1					; Set CF if LBA48 supported
+	eSHL_IM	al, 1					; Set CF if LBA48 supported
 	adc		bl, bh					; LBA48 EXT commands
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 558)
@@ -135,4 +135,7 @@
 %endif
 
+%ifdef MODULE_8BIT_IDE_ADVANCED
+NoSlaveDriveAvailable:
+%endif
 	ret
 
@@ -153,21 +156,24 @@
 ;		ES:		Zero (BDA segment)
 ;	Returns:
-;       None
+;       Nothing
 ;	Corrupts registers:
 ;		AX, BL, CX, DX, SI, DI
 ;--------------------------------------------------------------------
 StartDetectionWithDriveSelectByteInBHandStringInCX:
-%ifdef MODULE_8BIT_IDE
-	call	DetectDrives_DoesIdevarsInCSBPbelongToXTCF
-	jne		SHORT .ShouldNotSkipSlaveDriveDetection
+%ifdef MODULE_8BIT_IDE_ADVANCED
+	mov		al, [cs:bp+IDEVARS.bDevice]
+	cmp		al, DEVICE_8BIT_XTCF_PIO8
+	jb		SHORT .DoNotSkipSlaveDriveDetection
+	cmp		al, DEVICE_8BIT_XTCF_DMA
+	ja		SHORT .DoNotSkipSlaveDriveDetection
 
 	; XT-CF do not support slave drives so skip detection
 	test	bh, FLG_DRVNHEAD_DRV
 	jnz		SHORT NoSlaveDriveAvailable
-.ShouldNotSkipSlaveDriveDetection:
-%endif ; MODULE_8BIT_IDE
+.DoNotSkipSlaveDriveDetection:
+%endif ; MODULE_8BIT_IDE_ADVANCED
 
 	call	DetectPrint_StartDetectWithMasterOrSlaveStringInCXandIdeVarsInCSBP
-.DriveDetectionStringPrintedOnScreen:
+
 %ifdef MODULE_HOTKEYS
 	call	HotkeyBar_UpdateDuringDriveDetection
@@ -247,30 +253,2 @@
 	call	DriveDetectInfo_CreateForHardDisk
 	jmp		SHORT DetectPrint_DriveNameFromDrvDetectInfoInESBX
-
-
-%ifdef MODULE_8BIT_IDE
-;--------------------------------------------------------------------
-; DetectDrives_DoesIdevarsInCSBPbelongToXTCF
-;	Parameters:
-;		CS:BP:	Ptr to IDEVARS for the drive
-;	Returns:
-;		ZF:		Set if IDEVARS belongs to XT-CF device
-;				Cleared if some other device
-;	Corrupts registers:
-;		AL
-;--------------------------------------------------------------------
-DetectDrives_DoesIdevarsInCSBPbelongToXTCF:
-	mov		al, [cs:bp+IDEVARS.bDevice]
-	cmp		al, DEVICE_8BIT_XTCF_PIO8
-	je		SHORT .Done
-	cmp		al, DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
-
-%ifdef MODULE_8BIT_IDE_ADVANCED
-	je		SHORT .Done
-	cmp		al, DEVICE_8BIT_XTCF_DMA
-%endif ; MODULE_8BIT_IDE_ADVANCED
-
-.Done:		; return state via ZF, set from the cmp instructions
-NoSlaveDriveAvailable:
-	ret
-%endif ; MODULE_8BIT_IDE
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm	(revision 558)
@@ -35,4 +35,5 @@
 Initialize_FromMainBiosRomSearch:		; unused entrypoint ok
 	pushf								; To store IF
+	sti									; Enable interrupts for keystrokes
 	push	ds
 
@@ -45,5 +46,4 @@
 %endif
 
-	sti									; Enable interrupts for keystrokes
 	test	BYTE [BDA.bKBFlgs1], (1<<2)	; Clears ZF if CTRL is held down
 	jnz		SHORT .SkipRomInitialization
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm	(revision 558)
@@ -97,5 +97,5 @@
 .InitializeHardwareIrqHandlers:
 	call	RamVars_GetIdeControllerCountToCX
-	mov		di, ROMVARS.ideVars0+IDEVARS.bIRQ	; CS:SI points to first IDEVARS
+	mov		di, ROMVARS.ideVars0+IDEVARS.bIRQ
 .IdeControllerLoop:
 	mov		al, [cs:di]
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm	(revision 558)
@@ -139,11 +139,31 @@
 
 	mov		al, [si+DPT.bLchsSectorsPerTrack]
-%ifdef USE_186
+%ifndef USE_186
+	call	StoswALandChecksumFromDL	; Bytes 14 (Logical sectors per track) and 15 (Checksum)
+	jmp		SHORT FillStandardDPTtoESDIfromDPTinDSSI.RestoreOffsetsAndReturn
+%else
 	push	FillStandardDPTtoESDIfromDPTinDSSI.RestoreOffsetsAndReturn
-	jmp		StoswALandChecksumFromDL	; Bytes 14 (Logical sectors per track) and 15 (Checksum)
-%else
-	call	StoswALandChecksumFromDL
-	jmp		SHORT FillStandardDPTtoESDIfromDPTinDSSI.RestoreOffsetsAndReturn
-%endif
+	; Fall to StoswALandChecksumFromDL
+%endif
+
+
+;--------------------------------------------------------------------
+; StoswALandChecksumFromDL
+;	Parameters:
+;		AL:		Last byte to store before checksum byte
+;		DL:		Sum of bytes so far
+;		ES:DI:	Ptr to where to store AL and Checksum byte
+;	Returns:
+;		DL:		Sum of bytes so far
+;		DI:		Incremented by 2
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+StoswALandChecksumFromDL:
+	mov		ah, al
+	add		ah, dl
+	neg		ah
+	stosw
+	ret
 
 
@@ -226,9 +246,9 @@
 %ifdef MODULE_ADVANCED_ATA
 	or		ah, [si+DPT_ADVANCED_ATA.bPioMode]
-	jz		SHORT .NoDotSetFastPioFlag
+	jz		SHORT .DoNotSetFastPioFlag
 	cmp		WORD [si+DPT_ADVANCED_ATA.wControllerID], BYTE 0
-	je		SHORT .NoDotSetFastPioFlag
+	je		SHORT .DoNotSetFastPioFlag
 	inc		cx		; FLG_FAST_PIO_ENABLED
-.NoDotSetFastPioFlag:
+.DoNotSetFastPioFlag:
 %endif
 	call	StoswThenAddALandAHtoDL			; Bytes 8 and 9
@@ -276,21 +296,2 @@
 	ret
 
-
-;--------------------------------------------------------------------
-; StoswALandChecksumFromDL
-;	Parameters:
-;		AL:		Last byte to store before checksum byte
-;		DL:		Sum of bytes so far
-;		ES:DI:	Ptr to where to store AL and Checksum byte
-;	Returns:
-;		DL:		Sum of bytes so far
-;		DI:		Incremented by 2
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-StoswALandChecksumFromDL:
-	mov		ah, al
-	add		ah, dl
-	neg		ah
-	stosw
-	ret
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 558)
@@ -34,7 +34,6 @@
 ;		ES:		BDA Segment
 ;	Returns:
-;		DS:DI:	Ptr to Disk Parameter Table (if successful)
-;		CF:		Cleared if DPT created successfully
-;				Set if any error
+;		DS:DI:	Ptr to Disk Parameter Table
+;		CF:		Cleared
 ;	Corrupts registers:
 ;		AX, BX, CX, DX
@@ -167,5 +166,5 @@
 	xor		bx, bx
 	jmp		SHORT .StoreTotalSectorsFromBXDXAX
-	; Fall to .StoreNumberOfLbaSectors
+
 
 ;--------------------------------------------------------------------
@@ -209,5 +208,6 @@
 ; Update drive counts (hard and floppy)
 ;----------------------------------------------------------------------
-
+%ifdef MODULE_SERIAL
+; Device_FinalizeDPT returns with CF set only when a floppy was found which can't happen without MODULE_SERIAL
 %ifdef MODULE_SERIAL_FLOPPY
 ;
@@ -224,5 +224,5 @@
 	adc		byte [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt], 0
 	jnz		.AllDone
-%else
+%else ; ~MODULE_SERIAL_FLOPPY
 ;
 ; Even without floppy support enabled, we shouldn't try to mount a floppy image as a hard disk, which
@@ -231,10 +231,14 @@
 ;
 	jc		.AllDone
-%endif
+%endif ; MODULE_SERIAL_FLOPPY
+%endif ; MODULE_SERIAL
 
 	inc		BYTE [RAMVARS.bDrvCnt]		; Increment drive count to RAMVARS
 
+%ifdef MODULE_SERIAL
 .AllDone:
 	clc
+%endif
+
 	ret
 
Index: trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- trunk/XTIDE_Universal_BIOS/makefile	(revision 557)
+++ trunk/XTIDE_Universal_BIOS/makefile	(revision 558)
@@ -189,5 +189,5 @@
 at_large:
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT_LARGE) -l"$(TARGET)_atl.lst" -o"$(TARGET)_atl.bin"
-	@echo *Large AT version "$(TARGET)_atl.bin" built.
+	@echo * Large AT version "$(TARGET)_atl.bin" built.
 
 xtplus:
@@ -197,5 +197,5 @@
 xtplus_large:
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XTPLUS_LARGE) -l"$(TARGET)_xtpl.lst" -o"$(TARGET)_xtpl.bin"
-	@echo *Large XT Plus version "$(TARGET)_xtpl.bin" built.
+	@echo * Large XT Plus version "$(TARGET)_xtpl.bin" built.
 
 xt:
@@ -205,5 +205,5 @@
 xt_large:
 	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT_LARGE) -l"$(TARGET)_xtl.lst" -o"$(TARGET)_xtl.bin"
-	@echo *Large XT version "$(TARGET)_xtl.bin" built.
+	@echo * Large XT version "$(TARGET)_xtl.bin" built.
 
 xt_tiny:
