Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 369)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 370)
@@ -102,6 +102,10 @@
 	; Return number of successfully read sectors
 ReturnWithTransferErrorInAH:
+%ifdef USE_386
+	movzx	cx, [bp+PIOVARS.bSectorsDone]
+%else
 	mov		cl, [bp+PIOVARS.bSectorsDone]
 	mov		ch, 0								; Preserve CF
+%endif
 	ret
 
@@ -180,5 +184,5 @@
 	; Store sizes
 	mov		[bp+PIOVARS.bSectorsLeft], ah
-	eMOVZX	ax, BYTE [di+DPT_ATA.bBlockSize]
+	eMOVZX	ax, [di+DPT_ATA.bBlockSize]
 	mov		[bp+PIOVARS.wSectorsInBlock], ax
 	mov		[bp+PIOVARS.bSectorsDone], ah		; Zero
@@ -218,5 +222,5 @@
 ReadBlockFromXtideRev1:
 	UNROLL_SECTORS_IN_CX_TO_QWORDS
-	mov		bx, 8		; Bit mask for toggling data low/high reg
+	mov		bl, 8		; Bit mask for toggling data low/high reg
 ALIGN JUMP_ALIGN
 .InswLoop:
@@ -287,5 +291,5 @@
 	push	bx
 	UNROLL_SECTORS_IN_CX_TO_QWORDS
-	mov		bx, 8		; Bit mask for toggling data low/high reg
+	mov		bl, 8		; Bit mask for toggling data low/high reg
 	push	es			; Copy ES...
 	pop		ds			; ...to DS
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 369)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 370)
@@ -227,5 +227,5 @@
 ;				Set if error flag was set
 ;	Corrupts registers:
-;		BX, ES
+;		Nothing
 ;--------------------------------------------------------------------
 SetErrorFlagFromALwithErrorCodeInAH:
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 369)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 370)
@@ -52,5 +52,5 @@
 
 	; Initialize Master and Slave drives
-	eMOVZX	ax, BYTE [di+DPT.bIdevarsOffset]	; (AL) pointer to controller we are looking to reset
+	eMOVZX	ax, [di+DPT.bIdevarsOffset]			; (AL) pointer to controller we are looking to reset
 												; (AH) initialize error code, assume success
 
@@ -85,54 +85,29 @@
 IterateAndResetDrives:
 	cmp		al, [di+DPT.bIdevarsOffset]			; The right controller?
-	jne		.done
+	jne		.Done
+	push	cx
 	push	ax
-	push	cx
 	call	AH9h_InitializeDriveForUse			; Reset Master and Slave (Master will come first in DPT list)
 
 %ifdef MODULE_ADVANCED_ATA
 	jc		SHORT .SkipControllerInitSinceError
-	call	InitializeAdvancedIdeControllers	; Done after drive init so drives are first set to advanced PIO mode, then the controller
+	; Here we initialize the more advanced controllers (VLB and PCI) to get better performance for systems with 32-bit bus.
+	; This step is optional since the controllers use slowest possible settings by default if they are not initialized.
+
+	pop		ax
+	push	ax
+	cmp		al, [di+LARGEST_DPT_SIZE+DPT.bIdevarsOffset]	; We check if next DPT is for the same IDE controller.
+	je		SHORT .SkipInitializationUntilNextDrive			; If it is, we skip the initialization.
+	call	AdvAtaInit_InitializeControllerForDPTinDSDI		; Done after drive init so drives are first set to advanced PIO mode, then the controller
+.SkipInitializationUntilNextDrive:
 .SkipControllerInitSinceError:
-%endif
+%endif	; MODULE_ADVANCED_ATA
 
+	pop		ax
 	pop		cx
-	pop		ax
-	jnc		.done
+	jnc		.Done
 	or		ah, (RET_HD_RESETFAIL << 1) | 1		; OR in Reset Failed error code and CF, will SHR into position later
-.done:
+.Done:
 	stc											; From IterateAllDPTs perspective, the DPT is never found (continue iteration)
 	ret
 
-
-%ifdef MODULE_ADVANCED_ATA
-;--------------------------------------------------------------------
-; Here we initialize the more advanced controllers (VLB and PCI)
-; to get better performance for systems with 32-bit bus.
-;
-; This step is optional since the controllers use slowest possible
-; settings by default if they are not initialized.
-;
-; InitializeAdvancedIdeController
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;	Returns:
-;		CF:		Cleared if success or no controller to initialize
-;				Set if error
-;	Corrupts registers:
-;		AX, BX, CX, DX
-;--------------------------------------------------------------------
-InitializeAdvancedIdeControllers:
-	; We want to initialize the advanced controller only after both
-	; Master and Slave drive are initialized to correct PIO mode.
-	; We check if next DPT is for the same IDE controller. If it is,
-	; we skip the initialization.
-	mov		al, [di+DPT.bIdevarsOffset]
-	cmp		al, [di++LARGEST_DPT_SIZE+DPT.bIdevarsOffset]
-	je		SHORT .SkipInitializationUntilNextDrive	; CF cleared
-
-	jmp		AdvAtaInit_InitializeControllerForDPTinDSDI
-.SkipInitializationUntilNextDrive:
-	clc
-	ret
-
-%endif	; MODULE_ADVANCED_ATA
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvAtaInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvAtaInit.asm	(revision 369)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvAtaInit.asm	(revision 370)
@@ -114,5 +114,5 @@
 ;--------------------------------------------------------------------
 AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI:
-	eMOVZX	bx, BYTE [di+DPT_ADVANCED_ATA.bPioMode]
+	eMOVZX	bx, [di+DPT_ADVANCED_ATA.bPioMode]
 	mov		cx, [di+DPT_ADVANCED_ATA.wMinPioCycleTime]
 	test	si, si
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 369)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 370)
@@ -89,8 +89,7 @@
 	; Get PIO mode and cycle time for PIO 0...2
 	mov		bx, [es:si+ATA1.bPioMode]
+	mov		ax, bx					; AH = 0, AL = PIO mode 0, 1 or 2
 	shl		bx, 1					; Shift for WORD lookup
 	mov		cx, [cs:bx+.rgwPio0to2CycleTimeInNanosecs]
-	shr		bx, 1
-	xchg	ax, bx					; AH = 0, AL = PIO mode 0, 1 or 2
 
 	; Check if IORDY is supported
@@ -105,8 +104,8 @@
 	; Get Advanced PIO mode
 	; (Hard Disks supports up to 4 but CF cards can support 5 and 6)
-	mov		bx, [es:si+ATA2.bPIOSupp]
+	mov		bl, [es:si+ATA2.bPIOSupp]
 .CheckNextFlag:
 	inc		ax
-	shr		bx, 1
+	shr		bl, 1
 	jnz		SHORT .CheckNextFlag
 	MIN_U	al, 6						; Make sure not above lookup tables
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/Vision.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/Vision.asm	(revision 369)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/Vision.asm	(revision 370)
@@ -45,11 +45,12 @@
 IsConfigRegisterWithIDinAL:
 	mov		ah, al
-	and		ah, MASK_QDCONFIG_CONTROLLER_ID
-	cmp		ah, ID_QD6500 << 4
+	and		al, MASK_QDCONFIG_CONTROLLER_ID
+	cmp		al, ID_QD6500 << 4
 	je		SHORT VisionControllerDetected
-	cmp		ah, ID_QD6580 << 4
+	cmp		al, ID_QD6580 << 4
 	je		SHORT VisionControllerDetected
-	cmp		ah, ID_QD6580_ALTERNATE << 4
+	cmp		al, ID_QD6580_ALTERNATE << 4
 VisionControllerDetected:
+	xchg	ah, al
 	ret
 
@@ -175,5 +176,5 @@
 	mov		bp, QD6500_MAX_ACTIVE_TIME_CLOCKS | (QD6500_MIN_ACTIVE_TIME_CLOCKS << 8)
 
-	; We need the PIO Cycle Time in CX to calculate Active and Recovery Times. 
+	; We need the PIO Cycle Time in CX to calculate Active and Recovery Times.
 .CalculateTimingsForQD65xx:
 	call	AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI
