Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm	(revision 218)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm	(revision 221)
@@ -22,5 +22,6 @@
 ALIGN JUMP_ALIGN
 AH25h_HandlerForGetDriveInformation:
-	mov		si, [bp+IDEPACK.intpack+INTPACK.bx]
+	mov		al, 1			; Read 1 sector
+	call	Prepare_BufferToESSIforOldInt13hTransfer
 %ifdef USE_186
 	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm	(revision 218)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm	(revision 221)
@@ -15,5 +15,5 @@
 ;		SS:BP:	Ptr to IDEPACK
 ;	Parameters on INTPACK:
-;		AL:		Number of sectors to read (1...255, 0=256)
+;		AL:		Number of sectors to read (1...128)
 ;		CH:		Cylinder number, bits 7...0
 ;		CL:		Bits 7...6: Cylinder number bits 9 and 8
@@ -28,5 +28,6 @@
 ALIGN JUMP_ALIGN
 AH2h_HandlerForReadDiskSectors:
-	call	CommandLookup_GetOldInt13hIndexToBX
+	call	Prepare_BufferToESSIforOldInt13hTransfer
+	call	Prepare_GetOldInt13hCommandIndexToBX
 	mov		ah, [cs:bx+g_rgbReadCommandLookup]
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm	(revision 218)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm	(revision 221)
@@ -15,5 +15,5 @@
 ;		SS:BP:	Ptr to IDEREGS_AND_INTPACK
 ;	Parameters on INTPACK:
-;		AL:		Number of sectors to write (1...255, 0=256)
+;		AL:		Number of sectors to write (1...128)
 ;		CH:		Cylinder number, bits 7...0
 ;		CL:		Bits 7...6: Cylinder number bits 9 and 8
@@ -27,8 +27,8 @@
 ALIGN JUMP_ALIGN
 AH3h_HandlerForWriteDiskSectors:
-	call	CommandLookup_GetOldInt13hIndexToBX
+	call	Prepare_BufferToESSIforOldInt13hTransfer
+	call	Prepare_GetOldInt13hCommandIndexToBX
 	mov		ah, [cs:bx+g_rgbWriteCommandLookup]
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
-	mov		si, [bp+IDEPACK.intpack+INTPACK.bx]
 %ifdef USE_186
 	push	Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 218)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm	(revision 221)
@@ -15,5 +15,5 @@
 ;		SS:BP:	Ptr to INTPACK
 ;	Parameters on INTPACK in SS:BP:
-;		AL:		Number of sectors to verify (1...255, 0=256)
+;		AL:		Number of sectors to verify (1...128)
 ;		CH:		Cylinder number, bits 7...0
 ;		CL:		Bits 7...6: Cylinder number bits 9 and 8
@@ -26,4 +26,5 @@
 ALIGN JUMP_ALIGN
 AH4h_HandlerForVerifyDiskSectors:
+	call	Prepare_ByValidatingSectorsInALforOldInt13h
 	mov		ah, COMMAND_VERIFY_SECTORS
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH42h_ExtendedReadSectors.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH42h_ExtendedReadSectors.asm	(revision 218)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH42h_ExtendedReadSectors.asm	(revision 221)
@@ -24,6 +24,5 @@
 ALIGN JUMP_ALIGN
 AH42h_HandlerForExtendedReadSectors:
-	call	AH42h_LoadDapToESSIandVerifyForTransfer
-	call	CommandLookup_GetEbiosIndexToBX
+	call	Prepare_ByLoadingDapToESSIandVerifyingForTransfer
 	mov		ah, [cs:bx+g_rgbReadCommandLookup]
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
@@ -35,28 +34,2 @@
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %endif
-
-
-;--------------------------------------------------------------------
-; AH42h_LoadDapToESSIandVerifyForTransfer
-;	Parameters:
-;		SI:		Same as in INTPACK
-;		SS:BP:	Ptr to IDEPACK
-;	Parameters on INTPACK:
-;		DS:SI:	Ptr to Disk Address Packet
-;	Returns:
-;		ES:SI:	Ptr to Disk Address Packet (DAP)
-;		Exits from INT 13h if invalid DAP
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-AH42h_LoadDapToESSIandVerifyForTransfer:
-	mov		es, [bp+IDEPACK.intpack+INTPACK.ds]	; ES:SI to point Disk Address Packet
-	cmp		BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
-	jb		SHORT AH42h_ReturnWithInvalidFunctionError
-	cmp		WORD [es:si+DAP.bSectorCount], BYTE 0
-	je		SHORT AH42h_ReturnWithInvalidFunctionError
-	ret
-AH42h_ReturnWithInvalidFunctionError:
-	mov		ah, RET_HD_INVALID
-	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH43h_ExtendedWriteSectors.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH43h_ExtendedWriteSectors.asm	(revision 218)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH43h_ExtendedWriteSectors.asm	(revision 221)
@@ -27,8 +27,7 @@
 AH43h_HandlerForExtendedWriteSectors:
 	cmp		BYTE [bp+IDEPACK.intpack+INTPACK.al], 2	; Verify requested?
-	jae		SHORT AH42h_ReturnWithInvalidFunctionError
+	jae		SHORT Prepare_ReturnFromInt13hWithInvalidFunctionError
 
-	call	AH42h_LoadDapToESSIandVerifyForTransfer
-	call	CommandLookup_GetEbiosIndexToBX
+	call	Prepare_ByLoadingDapToESSIandVerifyingForTransfer
 	mov		ah, [cs:bx+g_rgbWriteCommandLookup]
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH44h_ExtendedVerifySectors.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH44h_ExtendedVerifySectors.asm	(revision 218)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH44h_ExtendedVerifySectors.asm	(revision 221)
@@ -24,6 +24,5 @@
 ALIGN JUMP_ALIGN
 AH44h_HandlerForExtendedVerifySectors:
-	call	AH42h_LoadDapToESSIandVerifyForTransfer
-	call	CommandLookup_GetEbiosIndexToBX
+	call	Prepare_ByLoadingDapToESSIandVerifyingForTransfer
 	mov		ah, [cs:bx+g_rgbVerifyCommandLookup]
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH47h_ExtendedSeek.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH47h_ExtendedSeek.asm	(revision 218)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH47h_ExtendedSeek.asm	(revision 221)
@@ -25,5 +25,5 @@
 	mov		es, [bp+IDEPACK.intpack+INTPACK.ds]	; ES:SI to point Disk Address Packet
 	cmp		BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
-	jb		SHORT AH42h_ReturnWithInvalidFunctionError
+	jb		SHORT Prepare_ReturnFromInt13hWithInvalidFunctionError
 
 	mov		ah, COMMAND_SEEK
@@ -36,2 +36,5 @@
 	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
 %endif
+
+.WriteWithVerifyNotSupported:
+	jmp		Prepare_ReturnFromInt13hWithInvalidFunctionError
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 218)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm	(revision 221)
@@ -40,5 +40,5 @@
 	mov		ax, MINIMUM_EDRIVEINFO_SIZE
 	cmp		[di+EDRIVE_INFO.wSize], ax
-	jb		SHORT AH42h_ReturnWithInvalidFunctionError
+	jb		SHORT Prepare_ReturnFromInt13hWithInvalidFunctionError
 	je		SHORT .SkipEddConfigurationParameters
 
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/CommandLookup.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/CommandLookup.asm	(revision 218)
+++ 	(revision )
@@ -1,66 +1,0 @@
-; Project name	:	XTIDE Universal BIOS
-; Description	:	Functions for loading correct transfer command.
-
-; Section containing code
-SECTION .text
-
-;--------------------------------------------------------------------
-; CommandLookup_GetEbiosIndexToBX
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;		ES:SI:	Ptr to DAP (Disk Address Packet)
-;	Returns:
-;		BX:		Index to command lookup table
-;	Corrupts registers:
-;		AX, DX
-;--------------------------------------------------------------------
-%ifdef MODULE_EBIOS
-ALIGN JUMP_ALIGN
-CommandLookup_GetEbiosIndexToBX:
-	; LBA28 or LBA48 command
-	xor		dx, dx
-	mov		al, [es:si+DAP.qwLBA+3]	; Load LBA48 byte 3 (bits 24...31)
-	and		ax, 00F0h				; Clear LBA28 bits 24...27
-	or		ax, [es:si+DAP.qwLBA+4]	; Set bits from LBA bytes 4 and 5
-	cmp		dx, ax					; Set CF if any of bits 28...47 set
-	rcl		dx, 1					; DX = 0 for LBA28, DX = 1 for LBA48
-	call	CommandLookup_GetOldInt13hIndexToBX
-	or		bx, dx					; Set block mode / single sector bit
-	ret
-%endif
-
-;--------------------------------------------------------------------
-; CommandLookup_GetOldInt13hIndexToBX
-;	Parameters:
-;		DS:DI:	Ptr to DPT
-;	Returns:
-;		BX:		Index to command lookup table
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-CommandLookup_GetOldInt13hIndexToBX:
-	; Block mode or single sector
-	mov		bl, [di+DPT.bFlagsHigh]
-	and		bx, BYTE FLGH_DPT_BLOCK_MODE_SUPPORTED	; Bit 1
-	ret
-
-
-g_rgbReadCommandLookup:
-	db		COMMAND_READ_SECTORS		; 00b, CHS or LBA28 single sector
-	db		COMMAND_READ_SECTORS_EXT	; 01b, LBA48 single sector
-	db		COMMAND_READ_MULTIPLE		; 10b, CHS or LBA28 block mode
-	db		COMMAND_READ_MULTIPLE_EXT	; 11b, LBA48 block mode
-
-g_rgbWriteCommandLookup:
-	db		COMMAND_WRITE_SECTORS
-	db		COMMAND_WRITE_SECTORS_EXT
-	db		COMMAND_WRITE_MULTIPLE
-	db		COMMAND_WRITE_MULTIPLE_EXT
-
-g_rgbVerifyCommandLookup:
-	db		COMMAND_VERIFY_SECTORS
-	db		COMMAND_VERIFY_SECTORS_EXT
-	db		COMMAND_VERIFY_SECTORS
-	db		COMMAND_VERIFY_SECTORS_EXT
-
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm	(revision 221)
+++ trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm	(revision 221)
@@ -0,0 +1,156 @@
+; Project name	:	XTIDE Universal BIOS
+; Description	:	Functions for preparing data buffer for transfer.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; Prepare_ByLoadingDapToESSIandVerifyingForTransfer
+;	Parameters:
+;		SI:		Offset to DAP
+;		DS:DI:	Ptr to DPT
+;		SS:BP:	Ptr to IDEPACK
+;	Parameters on INTPACK:
+;		DS:SI:	Ptr to Disk Address Packet
+;	Returns:
+;		BX:		Index to command lookup table
+;		ES:SI:	Ptr to Disk Address Packet (DAP)
+;		Exits from INT 13h if invalid DAP
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+%ifdef MODULE_EBIOS
+ALIGN JUMP_ALIGN
+Prepare_ByLoadingDapToESSIandVerifyingForTransfer:
+	; Load pointer to DAP to ES:SI and make sure it is valid
+	mov		es, [bp+IDEPACK.intpack+INTPACK.ds]	; ES:SI to point Disk Address Packet
+	cmp		BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
+	jb		SHORT InvalidDAP
+
+	; Make sure that sector count is valid
+	mov		ax, [es:si+DAP.wSectorCount]
+	test	ax, ax
+	jz		SHORT ZeroSectorsRequestedSoNoErrors
+	cmp		ax, BYTE 127
+	ja		SHORT InvalidNumberOfSectorsRequested
+	; Fall to GetEbiosCommandIndexToBX
+
+;--------------------------------------------------------------------
+; GetEbiosCommandIndexToBX
+;	Parameters:
+;		DS:DI:	Ptr to DPT
+;		ES:SI:	Ptr to DAP (Disk Address Packet)
+;	Returns:
+;		BX:		Index to command lookup table
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+GetEbiosCommandIndexToBX:
+	; LBA28 or LBA48 command
+	xor		dx, dx
+	mov		al, [es:si+DAP.qwLBA+3]	; Load LBA48 byte 3 (bits 24...31)
+	and		ax, 00F0h				; Clear LBA28 bits 24...27
+	or		ax, [es:si+DAP.qwLBA+4]	; Set bits from LBA bytes 4 and 5
+	cmp		dx, ax					; Set CF if any of bits 28...47 set
+	rcl		dx, 1					; DX = 0 for LBA28, DX = 1 for LBA48
+	call	Prepare_GetOldInt13hCommandIndexToBX
+	or		bx, dx					; Set block mode / single sector bit
+	ret
+%endif
+
+
+;--------------------------------------------------------------------
+; Prepare_GetOldInt13hCommandIndexToBX
+;	Parameters:
+;		DS:DI:	Ptr to DPT
+;	Returns:
+;		BX:		Index to command lookup table
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Prepare_GetOldInt13hCommandIndexToBX:
+	; Block mode or single sector
+	mov		bl, [di+DPT.bFlagsHigh]
+	and		bx, BYTE FLGH_DPT_BLOCK_MODE_SUPPORTED	; Bit 1
+	ret
+
+
+;---------------------------------------------------------------------
+; Prepare_BufferToESSIforOldInt13hTransfer
+;	Parameters:
+;		AL:		Number of sectors to transfer
+;		SS:BP:	Ptr to IDEPACK
+;	Parameters on INTPACK:
+;		ES:BX:	Ptr to data buffer
+;	Returns:
+;		ES:SI:	Ptr to normalized data buffer
+;		Exits INT 13h if error
+;	Corrupts registers:
+;		BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Prepare_BufferToESSIforOldInt13hTransfer:
+	; Normalize buffer pointer
+	mov		bx, [bp+IDEPACK.intpack+INTPACK.bx]	; Load offset
+	mov		si, bx
+	eSHR_IM	bx, 4								; Divide offset by 16
+	add		bx, [bp+IDEPACK.intpack+INTPACK.es]
+	mov		es, bx								; Segment normalized
+	and		si, BYTE 0Fh						; Offset normalized
+	; Fall to Prepare_ByValidatingSectorsInALforOldInt13h
+
+
+;---------------------------------------------------------------------
+; Prepare_ByValidatingSectorsInALforOldInt13h
+;	Parameters:
+;		AL:		Number of sectors to transfer
+;	Returns:
+;		Exits INT 13h if invalid number of sectors in AL
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Prepare_ByValidatingSectorsInALforOldInt13h:
+	test	al, al
+	js		SHORT .CheckZeroOffsetFor128Sectors		; 128 or more
+	jz		SHORT InvalidNumberOfSectorsRequested	; Zero not allowed for old INT 13h
+	ret		; Continue with transfer
+
+ALIGN JUMP_ALIGN
+.CheckZeroOffsetFor128Sectors:
+	cmp		al, 128
+	ja		SHORT InvalidNumberOfSectorsRequested
+	mov		ah, RET_HD_BOUNDARY
+	test	si, si								; Offset must be zero to xfer 128 sectors
+	jnz		SHORT CannotAlignPointerProperly
+	ret		; Continue with transfer
+
+InvalidDAP:
+InvalidNumberOfSectorsRequested:
+Prepare_ReturnFromInt13hWithInvalidFunctionError:
+	mov		ah, RET_HD_INVALID
+ZeroSectorsRequestedSoNoErrors:
+CannotAlignPointerProperly:
+	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
+
+
+
+; Command lookup tables
+g_rgbReadCommandLookup:
+	db		COMMAND_READ_SECTORS		; 00b, CHS or LBA28 single sector
+	db		COMMAND_READ_SECTORS_EXT	; 01b, LBA48 single sector
+	db		COMMAND_READ_MULTIPLE		; 10b, CHS or LBA28 block mode
+	db		COMMAND_READ_MULTIPLE_EXT	; 11b, LBA48 block mode
+
+g_rgbWriteCommandLookup:
+	db		COMMAND_WRITE_SECTORS
+	db		COMMAND_WRITE_SECTORS_EXT
+	db		COMMAND_WRITE_MULTIPLE
+	db		COMMAND_WRITE_MULTIPLE_EXT
+
+g_rgbVerifyCommandLookup:
+	db		COMMAND_VERIFY_SECTORS
+	db		COMMAND_VERIFY_SECTORS_EXT
+	db		COMMAND_VERIFY_SECTORS
+	db		COMMAND_VERIFY_SECTORS_EXT
Index: trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/PrepareBuffer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/PrepareBuffer.asm	(revision 218)
+++ 	(revision )
@@ -1,49 +1,0 @@
-; Project name	:	XTIDE Universal BIOS
-; Description	:	Functions for preparing data buffer for transfer.
-
-; Section containing code
-SECTION .text
-
-;---------------------------------------------------------------------
-; PrepareBuffer_ToESSIforOldInt13hTransfer
-;	Parameters:
-;		AL:		Number of sectors to transfer
-;		SS:BP:	Ptr to IDEPACK
-;	Parameters on INTPACK:
-;		ES:BX:	Ptr to data buffer
-;	Returns:
-;		ES:SI:	Ptr to normalized data buffer
-;		Exits INT 13h if error
-;	Corrupts registers:
-;		BX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-PrepareBuffer_ToESSIforOldInt13hTransfer:
-	; Normalize buffer pointer
-	mov		bx, [bp+IDEPACK.intpack+INTPACK.bx]	; Load offset
-	mov		si, bx
-	eSHR_IM	bx, 4								; Divide offset by 16
-	add		bx, [bp+IDEPACK.intpack+INTPACK.es]
-	mov		es, bx								; Segment normalized
-	and		si, BYTE 0Fh						; Offset normalized
-
-	; Check if valid number of sectors
-	test	al, al
-	js		SHORT .CheckZeroOffsetFor128Sectors
-	jz		SHORT .InvalidNumberOfSectorsRequested
-	ret		; Continue with transfer
-
-ALIGN JUMP_ALIGN
-.CheckZeroOffsetFor128Sectors:
-	cmp		al, 128
-	ja		SHORT .InvalidNumberOfSectorsRequested
-	mov		ah, RET_HD_BOUNDARY
-	test	si, si								; Offset must be zero to xfer 128 sectors
-	jnz		SHORT .CannotAlignPointerProperly
-	ret		; Continue with transfer
-
-.InvalidNumberOfSectorsRequested:
-	mov		ah, RET_HD_INVALID
-.CannotAlignPointerProperly:
-	jmp		Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
-
