Index: trunk/XTIDE_Universal_BIOS/Inc/IDE_8bit.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/IDE_8bit.inc	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Inc/IDE_8bit.inc	(revision 445)
@@ -4,5 +4,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -11,9 +11,9 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ;
@@ -25,8 +25,9 @@
 ; UNROLL_SECTORS_IN_CX_TO_DWORDS
 ; UNROLL_SECTORS_IN_CX_TO_QWORDS
+; UNROLL_SECTORS_IN_CX_TO_OWORDS
 ;	Parameters:
 ;		CX:		Number of sectors in block
 ;	Returns:
-;		CX:		Number of DWORDs or QWORDs in block
+;		CX:		Number of DWORDs, QWORDs or OWORDs in block
 ;	Corrupts registers:
 ;		Nothing
@@ -46,4 +47,13 @@
 %else
 	UNROLL_SECTORS_IN_CX_TO_DWORDS
+	shr		cx, 1
+%endif
+%endmacro
+
+%macro UNROLL_SECTORS_IN_CX_TO_OWORDS 0
+%ifdef USE_186
+	shl		cx, 5
+%else
+	UNROLL_SECTORS_IN_CX_TO_QWORDS
 	shr		cx, 1
 %endif
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm	(revision 445)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ; GNU General Public License for more details.
-; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html				
-;		
+; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+;
 
 ; Section containing code
@@ -79,5 +79,5 @@
 	test	bh, FLG_DRVNHEAD_DRV			; Wait already done for Master
 	jnz		SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster
-	call	AHDh_WaitUnilDriveMotorHasReachedFullSpeed
+	call	AHDh_WaitUntilDriveMotorHasReachedFullSpeed
 .SkipLongWaitSinceDriveIsNotPrimaryMaster:
 
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 445)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 ; Structure containing variables for PIO transfer functions.
@@ -119,5 +119,5 @@
 	jc		SHORT ReturnWithTransferErrorInAH
 
-	; All sectors succesfully transferred
+	; All sectors successfully transferred
 	add		cx, [bp+PIOVARS.bSectorsDone]		; Never sets CF
 	ret
@@ -244,12 +244,11 @@
 	ALIGN JUMP_ALIGN
 	ReadBlockFromXtideRev1:
-		UNROLL_SECTORS_IN_CX_TO_QWORDS
+		UNROLL_SECTORS_IN_CX_TO_OWORDS
 		mov		bl, 8		; Bit mask for toggling data low/high reg
 	ALIGN JUMP_ALIGN
 	.InswLoop:
+	%rep 8	; WORDs
 		XTIDE_INSW
-		XTIDE_INSW
-		XTIDE_INSW
-		XTIDE_INSW
+	%endrep
 		loop	.InswLoop
 		ret
@@ -259,16 +258,12 @@
 		ALIGN JUMP_ALIGN
 		ReadBlockFromXtideRev2:
-			UNROLL_SECTORS_IN_CX_TO_QWORDS
-		ALIGN JUMP_ALIGN
-		.ReadNextQword:
-			in		ax, dx		; Read 1st WORD
-			stosw				; Store 1st WORD to [ES:DI]
-			in		ax, dx
-			stosw				; 2nd
-			in		ax, dx
-			stosw				; 3rd
-			in		ax, dx
-			stosw				; 4th
-			loop	.ReadNextQword
+			UNROLL_SECTORS_IN_CX_TO_OWORDS
+		ALIGN JUMP_ALIGN
+		.ReadNextOword:
+		%rep 8	; WORDs
+			in		ax, dx		; Read WORD
+			stosw				; Store WORD to [ES:DI]
+		%endrep
+			loop	.ReadNextOword
 			ret
 	%endif
@@ -283,19 +278,14 @@
 
 	%else ; If 8088/8086
-			ALIGN JUMP_ALIGN
+		ALIGN JUMP_ALIGN
 		ReadBlockFrom8bitDataPort:
-			UNROLL_SECTORS_IN_CX_TO_DWORDS
-		ALIGN JUMP_ALIGN
-		.ReadNextDword:
-			in		al, dx		; Read 1st BYTE
-			stosb				; Store 1st BYTE to [ES:DI]
-			in		al, dx
-			stosb
-
-			in		al, dx
-			stosb
-			in		al, dx
-			stosb
-			loop	.ReadNextDword
+			UNROLL_SECTORS_IN_CX_TO_OWORDS
+		ALIGN JUMP_ALIGN
+		.ReadNextOword:
+		%rep 16	; BYTEs
+			in		al, dx		; Read BYTE
+			stosb				; Store BYTE to [ES:DI]
+		%endrep
+			loop	.ReadNextOword
 			ret
 	%endif
@@ -349,8 +339,7 @@
 	ALIGN JUMP_ALIGN
 	.OutswLoop:
+	%rep 4	; WORDs
 		XTIDE_OUTSW
-		XTIDE_OUTSW
-		XTIDE_OUTSW
-		XTIDE_OUTSW
+	%endrep
 		loop	.OutswLoop
 		pop		ds
@@ -366,8 +355,7 @@
 	ALIGN JUMP_ALIGN
 	.WriteNextQword:
+	%rep 4	; WORDs
 		XTIDE_MOD_OUTSW
-		XTIDE_MOD_OUTSW
-		XTIDE_MOD_OUTSW
-		XTIDE_MOD_OUTSW
+	%endrep
 		loop	.WriteNextQword
 		pop		ds
@@ -392,13 +380,8 @@
 		ALIGN JUMP_ALIGN
 		.WriteNextDword:
-			lodsb				; Load 1st BYTE from [DS:SI]
-			out		dx, al		; Write 1st BYTE
-			lodsb
-			out		dx, al
-
-			lodsb
-			out		dx, al
-			lodsb
-			out		dx, al
+		%rep 4	; BYTEs
+			lodsb				; Load BYTE from [DS:SI]
+			out		dx, al		; Write BYTE
+		%endrep
 			loop	.WriteNextDword
 			pop		ds
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm	(revision 445)
@@ -121,5 +121,5 @@
 	jc		SHORT ReturnWithMemoryIOtransferErrorInAH
 
-	; All rectors succesfully transferred
+	; All sectors successfully transferred
 	add		cx, [bp+PIOVARS.bSectorsDone]		; Never sets CF
 	ret
Index: trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm	(revision 445)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 ; Section containing code
@@ -37,12 +37,12 @@
 
 ;
-; Note that this section is not under %ifdef MODULE_SERIAL_FLOPPY.  It is important to 
+; Note that this section is not under %ifdef MODULE_SERIAL_FLOPPY.  It is important to
 ; distinguish floppy disks presented by the server and not treat them as hard disks, even
 ; if the floppy support is disabled.
 ;
 		mov		al, [es:si+SerialServer_ATA_wDriveFlags]
-		shl		al, 1
+		eSHL_IM	al, 1
 		mov		byte [di+DPT.bFlagsHigh], al
-		
+
 		ret
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm	(revision 445)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 ; Section containing code
@@ -103,5 +103,5 @@
 	; Jump to correct BIOS function
 	eMOVZX	bx, ah
-	shl		bx, 1
+	eSHL_IM	bx, 1
 	cmp		ah, 25h						; Possible EBIOS function?
 %ifndef MODULE_EBIOS
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm	(revision 445)
@@ -244,4 +244,5 @@
 ;		Nothing
 ;--------------------------------------------------------------------
+DoNotEnable8bitMode:
 IgnoreInvalidCommandError:
 	xor		ah, ah	; Clears CF
@@ -270,10 +271,8 @@
 ;--------------------------------------------------------------------
 AH9h_Enable8bitPioModeForXTCF:
-	eMOVZX	bx, BYTE [di+DPT.bIdevarsOffset]
+	eMOVZX	bx, [di+DPT.bIdevarsOffset]
 	cmp		BYTE [cs:bx+IDEVARS.bDevice], DEVICE_8BIT_XTCF
-	je		SHORT .Enable8bitMode
-	xor		ah, ah		; Do nothing for this device
-	ret
-.Enable8bitMode:
+	jne		SHORT DoNotEnable8bitMode
+
 	mov		si, FEATURE_ENABLE_8BIT_PIO_TRANSFER_MODE
 	jmp		AH23h_SetControllerFeatures
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm	(revision 445)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ; GNU General Public License for more details.
-; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html				
-;				
+; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+;
 
 ; Section containing code
@@ -106,5 +106,5 @@
 	push	cx
 	push	ax
-	call	AHDh_WaitUnilDriveMotorHasReachedFullSpeed
+	call	AHDh_WaitUntilDriveMotorHasReachedFullSpeed
 	call	AH9h_InitializeDriveForUse			; Initialize Master or Slave (Master will come first in DPT list)
 
@@ -133,5 +133,5 @@
 
 ;--------------------------------------------------------------------
-; AHDh_WaitUnilDriveMotorHasReachedFullSpeed
+; AHDh_WaitUntilDriveMotorHasReachedFullSpeed
 ;	Parameters:
 ;		DS:DI:	Ptr to DPT
@@ -142,5 +142,5 @@
 ;		AL, BX, CX, DX
 ;--------------------------------------------------------------------
-AHDh_WaitUnilDriveMotorHasReachedFullSpeed:
+AHDh_WaitUntilDriveMotorHasReachedFullSpeed:
 %ifdef MODULE_SERIAL
 	test	BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm	(revision 445)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ; GNU General Public License for more details.
-; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html				
-;				
+; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+;
 
 ; Section containing code
@@ -55,5 +55,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/AtaID.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm	(revision 445)
@@ -4,5 +4,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -11,11 +11,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 ; Section containing code
@@ -28,5 +28,5 @@
 ;	Returns:
 ;		CF:		Set if failed to verify ATA-ID
-;				Cleared if ATA-ID verified succesfully
+;				Cleared if ATA-ID verified successfully
 ;	Corrupts registers:
 ;		AX, BX, CX
@@ -44,9 +44,9 @@
 	call	.CompareCHorSfromOffsetBXtoMaxValueInCX
 
-	add		bx, BYTE ATA1.wHeadCnt - ATA1.wCylCnt
+	mov		bl, ATA1.wHeadCnt & 0FFh
 	mov		cx, MAX_VALID_PCHS_HEADS
 	call	.CompareCHorSfromOffsetBXtoMaxValueInCX
 
-	add		bx, BYTE ATA1.wSPT - ATA1.wHeadCnt
+	mov		bl, ATA1.wSPT & 0FFh
 	mov		cl, MAX_VALID_PCHS_SECTORS_PER_TRACK
 	call	.CompareCHorSfromOffsetBXtoMaxValueInCX
@@ -69,6 +69,5 @@
 	; Check checksum byte
 	mov		cx, ATA6_size
-	call	Memory_SumCXbytesFromESSItoAL
-	test	al, al
+	call	Memory_SumCXbytesFromESSItoAL		; Returns with ZF set according to result
 	jnz		SHORT .FailedToVerifyAtaID
 
@@ -119,5 +118,5 @@
 	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
+	eSHL_IM	bx, 1					; Shift for WORD lookup
 	mov		cx, [cs:bx+.rgwPio0to2CycleTimeInNanosecs]
 
@@ -187,17 +186,15 @@
 ;--------------------------------------------------------------------
 AtaID_GetActiveTimeToAXfromPioModeInBX:
-	shl		bx, 1
-	mov		ax, [cs:bx+.rgwPioModeToActiveTimeNs]
-	shr		bx, 1
-	ret
-
-.rgwPioModeToActiveTimeNs:
-	dw		PIO_0_MIN_ACTIVE_TIME_NS
-	dw		PIO_1_MIN_ACTIVE_TIME_NS
-	dw		PIO_2_MIN_ACTIVE_TIME_NS
-	dw		PIO_3_MIN_ACTIVE_TIME_NS
-	dw		PIO_4_MIN_ACTIVE_TIME_NS
-	dw		PIO_5_MIN_ACTIVE_TIME_NS
-	dw		PIO_6_MIN_ACTIVE_TIME_NS
+	eMOVZX	ax, [cs:bx+.rgbPioModeToActiveTimeNs]
+	ret
+
+.rgbPioModeToActiveTimeNs:
+	db		PIO_0_MIN_ACTIVE_TIME_NS
+	db		PIO_1_MIN_ACTIVE_TIME_NS
+	db		PIO_2_MIN_ACTIVE_TIME_NS
+	db		PIO_3_MIN_ACTIVE_TIME_NS
+	db		PIO_4_MIN_ACTIVE_TIME_NS
+	db		PIO_5_MIN_ACTIVE_TIME_NS
+	db		PIO_6_MIN_ACTIVE_TIME_NS
 
 %endif ; MODULE_ADVANCED_ATA
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 445)
@@ -4,10 +4,10 @@
 ;
 ; 					These algorithms are taken from: http://www.mossywell.com/boot-sequence
-; 					Take a look at it for more detailed information.		
+; 					Take a look at it for more detailed information.
 ;
 ;					This file is shared with BIOS Drive Information Tool.
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -16,12 +16,12 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ;
-		
+
 ; Section containing code
 SECTION .text
@@ -33,5 +33,5 @@
 ;		ES:SI:	Ptr to 512-byte ATA information read from the drive
 ;	Returns:
-;		BX:DX:AX:	48-bit sectohr count
+;		BX:DX:AX:	48-bit sector count
 ;		CL:			FLGL_DPT_LBA48 if LBA48 supported
 ;					Zero if only LBA28 is supported
@@ -239,5 +239,5 @@
 	jbe		SHORT ReturnLCHSinAXBLBH
 	shr		ax, 1		; Halve cylinders
-	shl		bl, 1		; Double heads
+	eSHL_IM	bl, 1		; Double heads
 	inc		cx			; Increment bit shift count
 	mov		dl, TRANSLATEMODE_LARGE
@@ -300,8 +300,7 @@
 	cmp		ax, cx
 	jbe		SHORT .NumberOfHeadsNowInCX
-	shl		cx, 1						; Double number of heads
-	test	ch, ch						; Reached 256 heads?
-	jz		SHORT .CompareNextValidNumberOfHeads
-	dec		cx							;  If so, limit heads to 255
+	eSHL_IM	cl, 1						; Double number of heads
+	jnz		SHORT .CompareNextValidNumberOfHeads	; Reached 256 heads?
+	dec		cl							;  If so, limit heads to 255
 .NumberOfHeadsNowInCX:
 	mov		bx, cx						; Number of heads are returned in BL
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 445)
@@ -3,5 +3,5 @@
 
 ;
-; XTIDE Universal BIOS and Associated Tools 
+; XTIDE Universal BIOS and Associated Tools
 ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
 ;
@@ -10,11 +10,11 @@
 ; the Free Software Foundation; either version 2 of the License, or
 ; (at your option) any later version.
-; 
+;
 ; This program is distributed in the hope that it will be useful,
 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.		
+; GNU General Public License for more details.
 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-;		
+;
 
 ; Section containing code
@@ -145,6 +145,6 @@
 
 	; Compare user defined and ATA-ID sector count and select smaller
-	xor		dx, dx
-	xchg	bx, dx		; User defined LBA now in BX:DX:AX
+	mov		dx, bx
+	xor		bx, bx		; User defined LBA now in BX:DX:AX
 	cmp		bx, [di+DPT.twLbaSectors+4]
 	jb		SHORT .StoreUserDefinedSectorCountToDPT
Index: trunk/XTIDE_Universal_BIOS/makefile
===================================================================
--- trunk/XTIDE_Universal_BIOS/makefile	(revision 444)
+++ trunk/XTIDE_Universal_BIOS/makefile	(revision 445)
@@ -1,40 +1,40 @@
-##################################################################################################
-# Makefile to build XTIDE Universal BIOS.                                                        #
-#                                                                                                #
-# Valid makefile targets are:                                                                    #
-# all       Removes existing files and builds binary files in \Build                             #
-# small     Builds 8 kiB binaries only (without checksum)                                        #
-# large     Builds 15 kiB binaries only (without checksum)                                       #
-# clean     Removes all files from \Build                                                        #
-# checksum* Builds all and then generates checksum byte to all binary files                      #
-# strings*  Compress src\Strings.asm to src\StringsCompressed.asm                                #
-#                                                                                                #
-# * at the end of target name means that Perl is required for the job.                           #
-# Build directory must be created manually if it does not exist.                                 #
-#                                                                                                #
-#                                                                                                #
-# Following modules can be included or excluded:                                                 #
-# MODULE_8BIT_IDE			Support for 8-BIT IDE cards like XTIDE                               #
-# MODULE_JRIDE              Support for JR-IDE/ISA                                               #
-# MODULE_ADVANCED_ATA       Native support for some VLB IDE controllers                          #
-# MODULE_BOOT_MENU          Boot Menu for selection of drive to boot from                        #
-# MODULE_EBIOS              Enhanced functions for accessing drives over 8.4 GB                  #
-# MODULE_HOTKEYS            Hotkey Bar to boot from any drive                                    #
-# MODULE_IRQ				IDE IRQ support                                                      #
-# MODULE_SERIAL             Virtual hard disks using serial port                                 #
-# MODULE_SERIAL_FLOPPY      Virtual floppy drives using serial port (requires MODULE_SERIAL)     #
-# MODULE_STRINGS_COMPRESSED Use compressed strings to save space                                 #
-# MODULE_FEATURE_SETS       Power Management support                                             #
-#                                                                                                #
-# Not modules but these affect the assembly:                                                     #
-# ELIMINATE_CGA_SNOW        Prevents CGA snowing at the cost of a few bytes                      #
-# RELOCATE_INT13H_STACK     Relocates INT 13h stack to top of stolen conventional memory         #
-# RESERVE_DIAGNOSTIC_CYLINDER Reserve one L-CHS cylinder for compatibility with old BIOSes       #
-# USE_186                   Use instructions supported by 80188/80186 and V20/V30 and later      #
-# USE_286                   Use instructions supported by 286 and later                          #
-# USE_386                   Use instructions supported by 386 and later                          #
-# USE_AT                    Use features supported on AT and later systems (not available on XT) #
-#                                                                                                #
-##################################################################################################
+####################################################################################################
+# Makefile to build XTIDE Universal BIOS.                                                          #
+#                                                                                                  #
+# Valid makefile targets are:                                                                      #
+# all       Removes existing files and builds binary files in \Build                               #
+# small     Builds 8 kiB binaries only (without checksum)                                          #
+# large     Builds 15 kiB binaries only (without checksum)                                         #
+# clean     Removes all files from \Build                                                          #
+# checksum* Builds all and then generates checksum byte to all binary files                        #
+# strings*  Compress src\Strings.asm to src\StringsCompressed.asm                                  #
+#                                                                                                  #
+# * at the end of target name means that Perl is required for the job.                             #
+# Build directory must be created manually if it does not exist.                                   #
+#                                                                                                  #
+#                                                                                                  #
+# Following modules can be included or excluded:                                                   #
+# MODULE_8BIT_IDE             Support for 8-BIT IDE cards like XTIDE                               #
+# MODULE_JRIDE                Support for JR-IDE/ISA                                               #
+# MODULE_ADVANCED_ATA         Native support for some VLB IDE controllers                          #
+# MODULE_BOOT_MENU            Boot Menu for selection of drive to boot from                        #
+# MODULE_EBIOS                Enhanced functions for accessing drives over 8.4 GB                  #
+# MODULE_HOTKEYS              Hotkey Bar to boot from any drive                                    #
+# MODULE_IRQ                  IDE IRQ support                                                      #
+# MODULE_SERIAL               Virtual hard disks using serial port                                 #
+# MODULE_SERIAL_FLOPPY        Virtual floppy drives using serial port (requires MODULE_SERIAL)     #
+# MODULE_STRINGS_COMPRESSED   Use compressed strings to save space                                 #
+# MODULE_FEATURE_SETS         Power Management support                                             #
+#                                                                                                  #
+# Not modules but these affect the assembly:                                                       #
+# ELIMINATE_CGA_SNOW          Prevents CGA snowing at the cost of a few bytes                      #
+# RELOCATE_INT13H_STACK       Relocates INT 13h stack to top of stolen conventional memory         #
+# RESERVE_DIAGNOSTIC_CYLINDER Reserve one L-CHS cylinder for compatibility with old BIOSes         #
+# USE_186                     Use instructions supported by 80188/80186 and V20/V30 and later      #
+# USE_286                     Use instructions supported by 286 and later                          #
+# USE_386                     Use instructions supported by 386 and later                          #
+# USE_AT                      Use features supported on AT and later systems (not available on XT) #
+#                                                                                                  #
+####################################################################################################
 
 ###########################################
