Index: /trunk/Assembly_Library/Inc/Macros.inc
===================================================================
--- /trunk/Assembly_Library/Inc/Macros.inc	(revision 565)
+++ /trunk/Assembly_Library/Inc/Macros.inc	(revision 566)
@@ -1,5 +1,5 @@
 ; Project name	:	Assembly Library
 ; Description	:	This is the place to put various generic macros.
-;					Should be included immediately after emulate.inc
+;					Should be included immediately after Emulate.inc
 %ifndef MACROS_INC
 %define MACROS_INC
Index: /trunk/Assembly_Library/Src/Serial/SerialServer.asm
===================================================================
--- /trunk/Assembly_Library/Src/Serial/SerialServer.asm	(revision 565)
+++ /trunk/Assembly_Library/Src/Serial/SerialServer.asm	(revision 566)
@@ -92,16 +92,16 @@
 
 		mov		al,047h
-		inc		dx				;  fifo
+		inc		dx				; fifo
 		out		dx,al
 
 		mov		al,03h
-		inc		dx				;  linecontrol
+		inc		dx				; linecontrol
 		out		dx,al
 
 		mov		al,0bh
-		inc		dx				;  modemcontrol
-		out		dx,al
-
-		inc		dx				;  linestatus (no output now, just setting up BH for later use)
+		inc		dx				; modemcontrol
+		out		dx,al
+
+		inc		dx				; linestatus (no output now, just setting up BH for later use)
 		mov		bh,dl
 
@@ -158,5 +158,5 @@
 		mov		cx,0101h		; writing 256 words (plus 1)
 
-		shr		ah,1			; command byte, are we doing a write?
+		sahf					; command byte, are we doing a write?
 		jnc		.readEntry
 
@@ -285,5 +285,5 @@
 ; taken care of this, but I have seen cases where this is not true.
 ;
-		xor		cx,cx					; timeout this clearing routine, in case the UART isn't there
+		xor		cx,cx			; timeout this clearing routine, in case the UART isn't there
 .clearBuffer:
 		mov		dl,bh
@@ -294,18 +294,18 @@
 		test	al,1
 		in		al,dx
-		loopnz	.clearBuffer			; note ZF from test above
+		loopnz	.clearBuffer	; note ZF from test above
 
 .clearBufferComplete:
-		mov		al, 3			;  error return code and CF (low order bit)
+		mov		al, 1			; error return code
 
 ALIGN JUMP_ALIGN
 SerialServer_OutputWithParameters_ReturnCodeInAL:
 %if 0
-		sti						;  all paths here will already have interrupts turned back on
-%endif
-		mov		ah, al			;  for success, AL will already be zero
-
-		pop		bx				;  recover "ax" (command and count) from stack
-		pop		cx				;  recover saved sector count
+		sti						; all paths here will already have interrupts turned back on
+%endif
+		mov		ah, al			; for success, AL will already be zero
+
+		pop		bx				; recover "ax" (command and count) from stack
+		pop		cx				; recover saved sector count
 		xor		ch, ch
 		sub		cl, bl			; subtract off the number of sectors that remained
@@ -315,5 +315,5 @@
 		pop		si
 
-		shr		ah, 1			; shift down return code and CF
+		sahf					; error return code to CF
 
 		ret
@@ -440,6 +440,6 @@
 ;
 		sti
+%ifndef SERIALSERVER_TIMER_LOCATION
 		mov		cl,SerialServer_WaitAndPoll_SoftDelayTicks
-%ifndef SERIALSERVER_TIMER_LOCATION
 		call	Timer_InitializeTimeoutWithTicksInCL
 %else
Index: /trunk/BIOS_Drive_Information_Tool/Src/Bios.asm
===================================================================
--- /trunk/BIOS_Drive_Information_Tool/Src/Bios.asm	(revision 565)
+++ /trunk/BIOS_Drive_Information_Tool/Src/Bios.asm	(revision 566)
@@ -26,5 +26,5 @@
 ;		Nothing
 ;	Returns: (if no errors)
-;       DX:		Number of hard drives in system
+;		DX:		Number of hard drives in system
 ;		CF:		Set if no hard drives found
 ;	Corrupts registers:
@@ -44,5 +44,5 @@
 ;		DL:		BIOS drive number
 ;	Returns: (if no errors)
-;       BL:     Drive Type (for floppies only)
+;		BL:		Drive Type (for floppies only)
 ;		AX:		Sectors per track (1...63)
 ;		DX:		Number of heads (1...255)
@@ -67,5 +67,5 @@
 ;		DH:		Maximum head number (0...254)
 ;	Returns:
-;       BL:     Drive Type (for floppies only)
+;		BL:		Drive Type (for floppies only)
 ;		AX:		Sectors per track (1...63)
 ;		DX:		Number of heads (1...255)
@@ -93,6 +93,6 @@
 ;		DL:		BIOS drive number
 ;	Returns: (if no errors)
-;       CX:DX:	Total number of sectors
-;       AH:		BIOS Error code
+;		CX:DX:	Total number of sectors
+;		AH:		BIOS Error code
 ;		CF:		Cleared = no errors
 ;				Set = BIOS error code stored in AH
@@ -113,6 +113,6 @@
 ;		DL:		BIOS drive number
 ;	Returns: (if no errors)
-;      	DS:BX:	Ptr to ATA information
-;       AH:		BIOS Error code
+;		DS:BX:	Ptr to ATA information
+;		AH:		BIOS Error code
 ;		CF:		Cleared = no errors
 ;				Set = BIOS error code stored in AH
@@ -135,5 +135,5 @@
 ;	Returns:
 ;		AH:		BIOS error code
-;       BX:		Version of extensions
+;		BX:		Version of extensions
 ;		CX:		Interface support bit map
 ;		CF:		Cleared = no errors
@@ -163,6 +163,6 @@
 ;		DL:		BIOS drive number
 ;	Returns: (if no errors)
-;      	DS:SI:	Ptr to EDRIVE_INFO
-;       AH:		BIOS Error code
+;		DS:SI:	Ptr to EDRIVE_INFO
+;		AH:		BIOS Error code
 ;		CF:		Cleared = no errors
 ;				Set = BIOS error code stored in AH
@@ -184,5 +184,5 @@
 ;		Nothing
 ;	Returns: (if no errors)
-;       AH:		BIOS Error code
+;		AH:		BIOS Error code
 ;		CF:		Set
 ;	Corrupts registers:
Index: /trunk/XTIDE_Universal_BIOS/Inc/Controllers/Vision.inc
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Inc/Controllers/Vision.inc	(revision 565)
+++ /trunk/XTIDE_Universal_BIOS/Inc/Controllers/Vision.inc	(revision 566)
@@ -50,5 +50,5 @@
 MASK_QD6580IDE_RECOVERY_TIME			EQU	MASK_QD6500IDE_RECOVERY_TIME
 													; 0000b = 15 clocks, 1101b = 2 clocks
-POSITON_QD65XXIDE_RECOVERY_TIME			EQU	4
+POSITION_QD65XXIDE_RECOVERY_TIME		EQU	4
 
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeError.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeError.asm	(revision 565)
+++ /trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeError.asm	(revision 566)
@@ -55,17 +55,13 @@
 ALIGN JUMP_ALIGN
 GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX:
-	test	al, FLG_STATUS_BSY
-	jz		SHORT .CheckErrorBitsFromStatusRegisterInAL
-	mov		ah, RET_HD_TIMEOUT
-	jmp		SHORT .ReturnBiosErrorCodeInAH
+	test	al, FLG_STATUS_BSY | FLG_STATUS_DF | FLG_STATUS_CORR | FLG_STATUS_ERR	; Clears CF
+	jnz		SHORT .CheckErrorBitsFromStatusRegisterInAL
+	; The MSB of AL (FLG_STATUS_BSY) is cleared at this point.
+	cbw								; No errors, zero AH (CF already cleared)
+	ret
 
 ALIGN JUMP_ALIGN
 .CheckErrorBitsFromStatusRegisterInAL:
-	test	al, FLG_STATUS_DF | FLG_STATUS_CORR | FLG_STATUS_ERR
-	jnz		SHORT .ProcessErrorFromStatusRegisterInAL
-	xor		ah, ah					; No errors, zero AH and CF
-	ret
-
-.ProcessErrorFromStatusRegisterInAL:
+	js		SHORT .Flg_Status_Bsy	; Jump if FLG_STATUS_BSY
 	test	al, FLG_STATUS_ERR		; Error specified in Error register?
 	jnz		SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH
@@ -74,19 +70,21 @@
 	jnz		SHORT .ReturnBiosErrorCodeInAH
 	mov		ah, RET_HD_CONTROLLER	; Must be Device Fault
-	jmp		SHORT .ReturnBiosErrorCodeInAH
+	SKIP2B	bx
+.Flg_Status_Bsy:
+	mov		ah, RET_HD_TIMEOUT
+.ReturnBiosErrorCodeInAH:
+	stc
+	ret
 
 .ConvertBiosErrorToAHfromErrorRegisterInAH:
-	xor		bx, bx					; Clear CF
+	stc								; Needed in case Error register (AH) is zero
+	mov		bx, .rgbRetCodeLookup-1
 .ErrorBitLoop:
-	rcr		ah, 1					; Set CF if error bit set
-	jc		SHORT .LookupErrorCode
 	inc		bx
-	test	ah, ah					; Clear CF
-	jnz		SHORT .ErrorBitLoop
-.LookupErrorCode:
-	mov		ah, [cs:bx+.rgbRetCodeLookup]
-.ReturnBiosErrorCodeInAH:
-	stc								; Set CF since error
+	rcr		ah, 1
+	jnc		SHORT .ErrorBitLoop		; CF will be set eventually
+	mov		ah, [cs:bx]
 	ret
+
 
 .rgbRetCodeLookup:
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 565)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 566)
@@ -106,7 +106,7 @@
 	jc		.ReturnWithErrorCodeInAH
 %else
-	jnc		SHORT .ContinueInitializationSinceDriveSelectedSuccesfully
+	jnc		SHORT .ContinueInitializationSinceDriveSelectedSuccessfully
 	jmp		.ReturnWithErrorCodeInAH
-.ContinueInitializationSinceDriveSelectedSuccesfully:
+.ContinueInitializationSinceDriveSelectedSuccessfully:
 %endif
 
Index: /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13hBiosInit.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13hBiosInit.asm	(revision 565)
+++ /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13hBiosInit.asm	(revision 566)
@@ -28,5 +28,5 @@
 ; Int 13h software interrupt handler.
 ; This handler captures boot sector read from foreign drive when our
-; INT 19h is not called. This way we can for XTIDE Universal BIOS
+; INT 19h is not called. This way we can force XTIDE Universal BIOS
 ; initialization even without INT 19h being called.
 ;
Index: /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm
===================================================================
--- /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm	(revision 565)
+++ /trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/Vision.asm	(revision 566)
@@ -179,6 +179,6 @@
 	test	al, FLG_QDCONTROL_HDONLY_in
 	eCMOVNZ	ah, FLG_QDCONTROL_NONATAPI				; Enable Read-Ahead and Post-Write Buffers
-	or		ah, MASK_QDCONTROL_FLAGS_TO_SET
 	mov		al, ah
+	or		al, MASK_QDCONTROL_FLAGS_TO_SET
 	out		dx, al
 	sub		dx, BYTE QD6580_CONTROL_REGISTER
@@ -187,6 +187,5 @@
 	; QD6500 has only one channel that can be Primary at 1F0h or Secondary at 170h.
 	; QD6580 always has Primary channel at 1F0h. Secondary channel at 170h can be Enabled or Disabled.
-	mov		bx, [di+DPT.wBasePort]
-	cmp		bx, DEVICE_ATA_PRIMARY_PORT
+	cmp		WORD [di+DPT.wBasePort], DEVICE_ATA_PRIMARY_PORT
 	je		SHORT .CalculateTimingTicksForQD6580	; Primary Channel so no need to modify DX
 	times 2 inc dx									; Secondary Channel IDE Timing Register
@@ -216,5 +215,5 @@
 
 	; Merge the values to a single byte to output
-	eSHIFT_IM	al, POSITON_QD65XXIDE_RECOVERY_TIME, shl
+	eSHL_IM	al, POSITION_QD65XXIDE_RECOVERY_TIME
 	or		al, bl
 	out		dx, al
