Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 567)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm	(revision 568)
@@ -58,5 +58,5 @@
 
 %ifdef USE_UNDOC_INTEL
-	eSALC	; Clears AL using CF while preserving flags
+	salc	; Clears AL using CF while preserving flags
 %endif
 
@@ -163,25 +163,5 @@
 ;--------------------------------------------------------------------
 AccessDPT_GetIdevarsToCSBX:
-	eMOVZX	bx, BYTE [di+DPT.bIdevarsOffset]
+	eMOVZX	bx, [di+DPT.bIdevarsOffset]
 	ret
 
-
-;--------------------------------------------------------------------
-; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
-;	Parameters:
-;		DS:DI:	Ptr to Disk Parameter Table
-;	Returns:
-;		AX:		Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA)
-;				unshifted (still shifted where it is in bFlagsLow)
-;		ZF:		Set based on value in AL
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-;
-; 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)
-;
-%macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0
-	mov		al, [di+DPT.bFlagsLow]
-	and		ax, BYTE MASKL_DPT_TRANSLATEMODE
-%endmacro
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 567)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm	(revision 568)
@@ -142,5 +142,4 @@
 ; GetSectorCountToDXAXfromCHSinAXBLBH
 ;	Parameters:
-;		ES:SI:	Ptr to 512-byte ATA information read from the drive
 ;		AX:		Number of cylinders (1...16383)
 ;		BL:		Number of heads (1...255)
@@ -328,7 +327,7 @@
 	cmp		ax, cx
 	jbe		SHORT .NumberOfHeadsNowInCX
-	eSHL_IM	cl, 1						; Double number of heads
-	jnz		SHORT .CompareNextValidNumberOfHeads	; Reached 256 heads?
-	dec		cl							;  If so, limit heads to 255
+	eSHL_IM	cx, 1						; Double number of heads
+	jpo		SHORT .CompareNextValidNumberOfHeads	; Reached 256 heads?
+	dec		cx							;  If so, limit heads to 255
 .NumberOfHeadsNowInCX:
 	mov		bx, cx						; Number of heads are returned in BL
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm	(revision 567)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CompatibleDPT.asm	(revision 568)
@@ -114,18 +114,18 @@
 ;--------------------------------------------------------------------
 FillTranslatedDPTtoESDIfromDPTinDSSI:
-	xor		dx, dx						; Clear for checksum
+	cwd									; Clear for checksum
 	call	StoswThenAddALandAHtoDL		; Bytes 0 and 1 (Logical number of cylinders)
 
-	mov		al, BYTE [si+DPT.bLchsHeads]
+	mov		al, [si+DPT.bLchsHeads]
 	mov		ah, TRANSLATED_DPT_SIGNATURE
 	call	StoswThenAddALandAHtoDL		; Bytes 2 (Logical number of heads) and 3 (Axh signature to indicate Translated DPT)
 
-	eMOVZX	ax, BYTE [si+DPT.bPchsSectorsPerTrack]
+	eMOVZX	ax, [si+DPT.bPchsSectorsPerTrack]
 	call	StoswThenAddALandAHtoDL		; Bytes 4 (Physical sectors per track) and 5 (Write Precompensation Cylinder low)
 
-	mov		al, ah
-	call	StoswThenAddALandAHtoDL		; Bytes 6 (Write Precompensation Cylinder high) and 7
-
-	xchg	ax, cx						; Device Control byte to AL
+	mov		al, ah						; Zero AX
+	stosw								; Bytes 6 (Write Precompensation Cylinder high) and 7
+
+	xchg	cx, ax						; Device Control byte to AL, zero to CX
 	mov		ah, [si+DPT.wPchsCylinders]
 	call	StoswThenAddALandAHtoDL		; Bytes 8 (Drive Control Byte) and 9 (Physical number of cylinders low)
@@ -135,6 +135,6 @@
 	call	StoswThenAddALandAHtoDL		; Bytes 10 (Physical number of cylinders high) and 11 (Physical number of heads)
 
-	xor		ax, ax
-	call	StoswThenAddALandAHtoDL		; Bytes 12 and 13 (Landing Zone Cylinder)
+	xchg	cx, ax						; Zero to AX
+	stosw								; Bytes 12 and 13 (Landing Zone Cylinder)
 
 	mov		al, [si+DPT.bLchsSectorsPerTrack]
@@ -158,5 +158,5 @@
 ;		DI:		Incremented by 2
 ;	Corrupts registers:
-;		Nothing
+;		AH
 ;--------------------------------------------------------------------
 StoswALandChecksumFromDL:
@@ -182,12 +182,24 @@
 FillStandardDPTtoESDIfromDPTinDSSI:
 	stosw				; Bytes 0 and 1 (Physical number of cylinders)
-	eMOVZX	ax, BYTE [si+DPT.bLchsHeads]
+	eMOVZX	ax, [si+DPT.bLchsHeads]
 	stosw				; Bytes 2 (Physical number of heads) and 3
+%ifdef USE_UNDOC_INTEL
+%ifdef USE_386
+	xor		al, al		; Zero AX and clear CF
+%else
+	salc				; Zero AX (CF cleared by eMOVZX above)
+%endif
+%else
 	mov		al, ah		; Zero AX
+%endif
 	stosw				; Bytes 4 and 5 (Write Precompensation Cylinder low)
 	stosw				; Bytes 6 (Write Precompensation Cylinder high) and 7
 	mov		al, cl		; Device control byte to AL
 	stosw				; Bytes 8 (Drive Control Byte) and 9
+%ifdef USE_UNDOC_INTEL
+	salc				; Zero AX (CF cleared above)
+%else
 	mov		al, ah		; Zero AX
+%endif
 	stosw				; Bytes 10 and 11
 	stosw				; Bytes 12 and 13 (Landing Zone Cylinder)
@@ -208,8 +220,8 @@
 ;		ES:BX:	Ptr to Device Parameter Table Extension (DPTE)
 ;	Corrupts registers:
-;		AX, CX, DX, DI
+;		AX, CX, DL, DI
 ;--------------------------------------------------------------------
 CompatibleDPT_CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI:
-	call	GetTemporaryBufferForDPTEtoESDI	; valid until next AH=48h call
+	call	GetTemporaryBufferForDPTEtoESDI	; Valid until next AH=48h call
 
 	; Set 32-bit flag for 32-bit controllers
@@ -218,4 +230,6 @@
 	eCMOVE	cl, FLG_LBA_TRANSLATION_ENABLED | FLG_32BIT_XFER_MODE
 
+	xor		dl, dl							; Clear DL for checksum
+
 	; DPTE.wBasePort
 	mov		ax, [si+DPT.wBasePort]
@@ -223,5 +237,5 @@
 
 	; DPTE.wControlBlockPort
-	eMOVZX	bx, BYTE [si+DPT.bIdevarsOffset]
+	eMOVZX	bx, [si+DPT.bIdevarsOffset]
 	mov		ax, [cs:bx+IDEVARS.wControlBlockPort]
 	call	StoswThenAddALandAHtoDL			; Bytes 2 and 3
@@ -244,13 +258,14 @@
 	; DPTE.bDmaChannelAndType and DPTE.bPioMode
 	xor		ax, ax
-%ifdef MODULE_ADVANCED_ATA
+%ifndef MODULE_ADVANCED_ATA
+	stosw									; Bytes 8 and 9
+%else
 	or		ah, [si+DPT_ADVANCED_ATA.bPioMode]
 	jz		SHORT .DoNotSetFastPioFlag
-	cmp		WORD [si+DPT_ADVANCED_ATA.wControllerID], BYTE 0
-	je		SHORT .DoNotSetFastPioFlag
-	inc		cx		; FLG_FAST_PIO_ENABLED
+	cmp		WORD [si+DPT_ADVANCED_ATA.wControllerID], BYTE 1
+	sbb		cl, -1	; FLG_FAST_PIO_ENABLED (if .wControllerID > 0)
 .DoNotSetFastPioFlag:
-%endif
 	call	StoswThenAddALandAHtoDL			; Bytes 8 and 9
+%endif
 
 	; Set CHS translation flags and store DPTE.wFlags
@@ -261,5 +276,5 @@
 	test	al, FLGL_DPT_ASSISTED_LBA
 	jz		SHORT .NoChsTranslationOrBitShiftTranslationSet
-	or		cx, LBA_ASSISTED_TRANSLATION << TRANSLATION_TYPE_FIELD_POSITION
+	or		ch, LBA_ASSISTED_TRANSLATION << (TRANSLATION_TYPE_FIELD_POSITION - 8)
 .NoChsTranslationOrBitShiftTranslationSet:
 	xchg	ax, cx
@@ -268,11 +283,10 @@
 	; DPTE.wReserved (must be zero)
 	xor		ax, ax
-	call	StoswThenAddALandAHtoDL			; Bytes 12 and 13
+	stosw									; Bytes 12 and 13
 
 	; DPTE.bRevision and DPTE.bChecksum
 	mov		al, DPTE_REVISION
-	call	StoswALandChecksumFromDL		; Bytes 14 and 15
-	lea		bx, [di-DPTE_size]
-	ret
+	lea		bx, [di+2-DPTE_size]			; The +2 compensates for the last WORD yet to be stored
+	jmp		StoswALandChecksumFromDL		; Bytes 14 and 15
 %endif ; MODULE_EBIOS
 
Index: trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 567)
+++ trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm	(revision 568)
@@ -116,11 +116,9 @@
 	jnz		SHORT .NothingToChange
 
-.LimitHeadsForLargeAddressingMode:
 	; We cannot have 16 P-Heads heads in Revised ECHS mode (8193 or more cylinders)
 	; but 16 heads are allowed when there are 8192 or less cylinders (ECHS).
 	; Both of these are LARGE modes so do not confuse with NORMAL mode.
 	call	AtaGeometry_IsDriveSmallEnoughForECHS
-	jc		SHORT .NothingToChange
-	dec		bx						; Adjust 16 P-Heads to 15
+	adc		bx, -1					; Adjust 16 P-Heads to 15 if needed
 
 .NothingToChange:
