Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 229)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 230)
@@ -45,21 +45,26 @@
 	mov		WORD [si+EDRIVE_INFO.wFlags], FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS
 
+	push	ds	; Move CS to DS to avoid segment overrides
+	push	cs
+	pop		ds
+
 	; Limit LBA if necessary
-	test	BYTE [cs:di+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERLBA
+	test	BYTE [di+DRVPARAMS.wFlags], FLG_DRVPARAMS_USERLBA
 	jz		SHORT .StoreTotalSectorsFromBXDXAX
 	test	bx, bx
 	jnz		SHORT .LimitTotalSectors
-	cmp		dx, [cs:di+DRVPARAMS.dwMaximumLBA+2]
+	cmp		dx, [di+DRVPARAMS.dwMaximumLBA+2]
 	jb		SHORT .StoreTotalSectorsFromBXDXAX		; Real size less than max
 	ja		SHORT .LimitTotalSectors
-	cmp		ax, [cs:di+DRVPARAMS.dwMaximumLBA]
+	cmp		ax, [di+DRVPARAMS.dwMaximumLBA]
 	jbe		SHORT .StoreTotalSectorsFromBXDXAX		; Real size less than max
 
 .LimitTotalSectors:
 	xor		bx, bx
-	mov		ax, [cs:di+DRVPARAMS.dwMaximumLBA]
-	mov		dx, [cs:di+DRVPARAMS.dwMaximumLBA+2]
+	mov		ax, [di+DRVPARAMS.dwMaximumLBA]
+	mov		dx, [di+DRVPARAMS.dwMaximumLBA+2]
 
 .StoreTotalSectorsFromBXDXAX:
+	pop		ds	; Restore DS from the change above
 	mov		[si+EDRIVE_INFO.qwTotalSectors], ax
 	xor		ax, ax									; Return with success
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 229)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Address.asm	(revision 230)
@@ -86,21 +86,21 @@
 Address_OldInt13hAddressToIdeAddress:
 		call	Address_ExtractLCHSparametersFromOldInt13hAddress
-			
+
 		AccessDPT_GetUnshiftedAddressModeToALZF
-		
-;;; 0: ADDR_DPT_LCHS		
-		jz		DoNotConvertLCHS	
-		
+
+;;; 0: ADDR_DPT_LCHS
+		jz		DoNotConvertLCHS
+
 ;;; 1: ADDR_DPT_PCHS
-		; 
+		;
 		; Since we are only checking for zero, we can do our math in the high order bits,
 		; in this case effectively subtracting 1 from the address mode.
 		;
 		sub		al,(1<<ADDRESSING_MODE_FIELD_POSITION)
-		jz		ConvertLCHStoPCHS	
+		jz		ConvertLCHStoPCHS
 
-;;; 2: ADDR_DPT_LBA28 and 3: ADDR_DPT_LBA48				
-		; Fall through to ConvertLCHStoLBARegisterValues  
-		
+;;; 2: ADDR_DPT_LBA28 and 3: ADDR_DPT_LBA48
+		; Fall through to ConvertLCHStoLBARegisterValues
+
 ;---------------------------------------------------------------------
 ; Converts LCHS parameters to 28-bit LBA address.
@@ -129,4 +129,7 @@
 	; cylToSeek*headsPerCyl (18-bit result)
 	mov		ax, cx					; Copy Cylinder number to AX
+	; We could save a byte here by using CWD instead of the XOR DH, DH in eMOVZX
+	; but I'm not sure how that would affect speed.
+
 	eMOVZX	dx, BYTE [di+DPT.bLbaHeads]
 	mul		dx						; DX:AX = cylToSeek*headsPerCyl
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 229)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 230)
@@ -62,5 +62,5 @@
 	jnz		SHORT .LimitAXtoMaxLCHScylinders
 	cmp		ax, MAX_LCHS_CYLINDERS
-	jbe		SHORT .returnLCHS
+	jb		SHORT .returnLCHS
 .LimitAXtoMaxLCHScylinders:
 	mov		ax, MAX_LCHS_CYLINDERS
@@ -71,5 +71,32 @@
 	mov		ax, [di+DPT.wPchsCylinders]
 	mov		bx, [di+DPT.wPchsHeadsAndSectors]
-	jmp		SHORT AccessDPT_ShiftPCHinAXBLtoLCH
+	; Fall to AccessDPT_ShiftPCHinAXBLtoLCH
+
+
+;--------------------------------------------------------------------
+; AccessDPT_ShiftPCHinAXBLtoLCH
+;	Parameters:
+;		AX:		P-CHS cylinders (1...16383)
+;		BL:		P-CHS heads (1...16)
+;	Returns:
+;		AX:		Number of L-CHS cylinders (1...1024)
+;		BL:		Number of L-CHS heads (1...255)
+;		CX:		Number of bits shifted (4 at most)
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+AccessDPT_ShiftPCHinAXBLtoLCH:
+	xor		cx, cx
+.ShiftLoop:
+	cmp		ax, MAX_LCHS_CYLINDERS		; Need to shift?
+	jbe		SHORT .LimitHeadsTo255		;  If not, return
+	inc		cx							; Increment shift count
+	shr		ax, 1						; Halve cylinders
+	shl		bl, 1						; Double heads
+	jnz		SHORT .ShiftLoop
+.LimitHeadsTo255:						; DOS does not support drives with 256 heads
+	cmp		bl, cl						; Set CF if BL is zero
+	sbb		bl, ch						; If BL=0 then BL=255
+	ret
 
 
@@ -87,31 +114,4 @@
 	mov		dx, [di+DPT.twLbaSectors+2]
 	mov		bx, [di+DPT.twLbaSectors+4]
-	ret
-
-
-;--------------------------------------------------------------------
-; AccessDPT_ShiftPCHinAXBLtoLCH
-;	Parameters:
-;		AX:		P-CHS cylinders (1...16383)
-;		BL:		P-CHS heads (1...16)
-;	Returns:
-;		AX:		Number of L-CHS cylinders (1...1024)
-;		BL:		Number of L-CHS heads (1...255)
-;		CX:		Number of bits shifted
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-AccessDPT_ShiftPCHinAXBLtoLCH:
-	xor		cx, cx
-.ShiftLoop:
-	cmp		ax, MAX_LCHS_CYLINDERS		; Need to shift?
-	jbe		SHORT .LimitHeadsTo255		;  If not, return
-	inc		cx							; Increment shift count
-	shr		ax, 1						; Halve cylinders
-	shl		bl, 1						; Double heads
-	jmp		SHORT .ShiftLoop
-.LimitHeadsTo255:						; DOS does not support drives with 256 heads
-	cmp		bl, cl						; Set CF if BL is zero
-	sbb		bl, ch						; If BL=0 then BL=255
 	ret
 
@@ -143,5 +143,5 @@
 ;		DS:DI:	Ptr to Disk Parameter Table
 ;	Returns:
-;		AL:		Addressing Mode (L-CHS, P-CHS, LBA28, LBA48) 
+;		AL:		Addressing Mode (L-CHS, P-CHS, LBA28, LBA48)
 ;               unshifted (still shifted where it is in bFlagsLow)
 ;       ZF:     Set based on value in AL
@@ -149,6 +149,6 @@
 ;		AL
 ;--------------------------------------------------------------------
-; 
-; Converted to a macro since only called in two places, and the call/ret overhead 
+;
+; 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)
 ;
