Index: trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 241)
+++ trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc	(revision 242)
@@ -71,6 +71,6 @@
 endstruc
 
-%if IDEVARS.bSerialCOMPortChar+1 != IDEVARS.bDevice 
-%erorr "IDEVARS.bSerialCOMPortChar needs to come immediately before IDEVARS.bDevice so that both bytes can be fetched at the same time inside DetectPrint.asm"
+%if IDEVARS.bSerialCOMPortChar+1 != IDEVARS.bDevice
+	%error "IDEVARS.bSerialCOMPortChar needs to come immediately before IDEVARS.bDevice so that both bytes can be fetched at the same time inside DetectPrint.asm"
 %endif
 
@@ -111,5 +111,5 @@
 ; COM Number to I/O Port Address Mapping
 ;
-; COM Number:                               1,    2,    3,    4,    5,    6,    7,    8,    9,   10,   11,   12		
+; COM Number:                               1,    2,    3,    4,    5,    6,    7,    8,    9,   10,   11,   12
 ; Corresponds to I/O port:                3f8,  2f8,  3e8,  2e8,  2f0,  3e0,  2e0,  260,  368,  268,  360,  270
 ; Corresponds to Packed I/O port (hex):    37,   17,   35,   15,   16,   34,   14,    4,   25,    5,   24,    6
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm	(revision 241)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm	(revision 242)
@@ -14,5 +14,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, CX, DX
+;		AX
 ;--------------------------------------------------------------------
 IdeDPT_Finalize:
@@ -28,5 +28,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		Nothing
+;		AX
 ;--------------------------------------------------------------------
 .StoreBlockMode:
Index: trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 241)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm	(revision 242)
@@ -35,32 +35,21 @@
 ALIGN JUMP_ALIGN
 IdeTransfer_StartWithCommandInAL:
-	mov		ah, [bp+IDEPACK.bSectorCount]
-
 	; Are we reading or writing?
 	test	al, 16	; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands
-	jnz		SHORT .PrepareToWriteDataFromESSI
+	mov		ah, [bp+IDEPACK.bSectorCount]
+	jnz		SHORT WriteToDrive
 	cmp		al, COMMAND_WRITE_MULTIPLE
-	je		SHORT .PrepareToWriteDataFromESSI
-
-	; Prepare to read data to ESSI
-	mov		bx, g_rgfnPioRead
-	call	InitializePiovarsInSSBPwithSectorCountInAH
-	xchg	si, di
-	jmp		SHORT ReadFromDrive
-
-ALIGN JUMP_ALIGN
-.PrepareToWriteDataFromESSI:
-	mov		bx, g_rgfnPioWrite
-	call	InitializePiovarsInSSBPwithSectorCountInAH
-	; Fall to WriteToDrive
-
-
-;--------------------------------------------------------------------
-; WriteToDrive
-;	Parameters:
+	je		SHORT WriteToDrive
+	; Fall to ReadFromDrive
+
+;--------------------------------------------------------------------
+; ReadFromDrive
+;	Parameters:
+;		AH:		Number of sectors to transfer (1...128)
+;		ES:SI:	Normalized ptr to buffer to receive data
 ;		DS:DI:	Ptr to DPT (in RAMVARS segment)
-;		ES:SI:	Normalized ptr to buffer containing data
 ;		SS:BP:	Ptr to PIOVARS
 ;	Returns:
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
 ;		AH:		BIOS Error code
 ;		CX:		Number of successfully transferred sectors
@@ -70,5 +59,77 @@
 ;		AL, BX, DX, SI, ES
 ;--------------------------------------------------------------------
+ReadFromDrive:
+	; Prepare to read data to ESSI
+	mov		bx, g_rgfnPioRead
+	call	InitializePiovarsInSSBPwithSectorCountInAH
+
+	; Wait until drive is ready to transfer
+	call	IdeWait_IRQorDRQ					; Wait until ready to transfer
+	jc		SHORT ReturnWithTransferErrorInAH
+	xchg	si, di								; ES:DI now points buffer
+
+	mov		cx, [bp+PIOVARS.wWordsInBlock]
+
+ALIGN JUMP_ALIGN
+.ReadNextBlockFromDrive:
+	mov		dx, [bp+PIOVARS.wDataPort]
+	cmp		[bp+PIOVARS.wWordsLeft], cx
+	jbe		SHORT .ReadLastBlockFromDrive
+	call	[bp+PIOVARS.fnXfer]
+
+	; Wait until ready for next block and check for errors
+	xchg	di, si								; DS:DI now points DPT
+	call	IdeWait_IRQorDRQ					; Wait until ready to transfer
+	jc		SHORT ReturnWithTransferErrorInAH
+	xchg	si, di								; ES:DI now points buffer
+
+	; Increment number of successfully read WORDs
+	mov		cx, [bp+PIOVARS.wWordsInBlock]
+	sub		[bp+PIOVARS.wWordsLeft], cx
+	add		[bp+PIOVARS.wWordsDone], cx
+	jmp		SHORT .ReadNextBlockFromDrive
+
+ALIGN JUMP_ALIGN
+.ReadLastBlockFromDrive:
+	mov		cx, [bp+PIOVARS.wWordsLeft]
+	call	[bp+PIOVARS.fnXfer]					; Transfer possibly partial block
+
+	; Check for errors in last block
+	mov		di, si								; DS:DI now points DPT
+CheckErrorsAfterTransferringLastBlock:
+	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
+	call	IdeWait_PollStatusFlagInBLwithTimeoutInBH
+
+	; Return number of successfully read sectors
+ReturnWithTransferErrorInAH:
+	mov		cx, [bp+PIOVARS.wWordsDone]
+	jc		SHORT .ConvertTransferredWordsInCXtoSectors
+	add		cx, [bp+PIOVARS.wWordsLeft]			; Never sets CF
+.ConvertTransferredWordsInCXtoSectors:
+	xchg	cl, ch
+	ret
+
+
+;--------------------------------------------------------------------
+; WriteToDrive
+;	Parameters:
+;		AH:		Number of sectors to transfer (1...128)
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		ES:SI:	Normalized ptr to buffer containing data
+;		SS:BP:	Ptr to PIOVARS
+;	Returns:
+;		AH:		BIOS Error code
+;		CX:		Number of successfully transferred sectors
+;		CF:		0 if transfer succesfull
+;				1 if any error
+;	Corrupts registers:
+;		AL, BX, DX, SI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
 WriteToDrive:
+	; Prepare to write data from ESSI
+	mov		bx, g_rgfnPioWrite
+	call	InitializePiovarsInSSBPwithSectorCountInAH
+
 	; Always poll when writing first block (IRQs are generated for following blocks)
 	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
@@ -76,7 +137,8 @@
 	jc		SHORT ReturnWithTransferErrorInAH
 
+	mov		cx, [bp+PIOVARS.wWordsInBlock]
+
 ALIGN JUMP_ALIGN
 .WriteNextBlockToDrive:
-	mov		cx, [bp+PIOVARS.wWordsInBlock]
 	mov		dx, [bp+PIOVARS.wDataPort]
 	cmp		[bp+PIOVARS.wWordsLeft], cx
@@ -89,7 +151,7 @@
 
 	; Increment number of successfully written WORDs
-	mov		ax, [bp+PIOVARS.wWordsInBlock]
-	sub		[bp+PIOVARS.wWordsLeft], ax
-	add		[bp+PIOVARS.wWordsDone], ax
+	mov		cx, [bp+PIOVARS.wWordsInBlock]
+	sub		[bp+PIOVARS.wWordsLeft], cx
+	add		[bp+PIOVARS.wWordsDone], cx
 	jmp		SHORT .WriteNextBlockToDrive
 
@@ -107,68 +169,4 @@
 
 ;--------------------------------------------------------------------
-; ReadFromDrive
-;	Parameters:
-;		ES:DI:	Normalized ptr to buffer to recieve data
-;		DS:SI:	Ptr to DPT (in RAMVARS segment)
-;		SS:BP:	Ptr to PIOVARS
-;	Returns:
-;		DS:DI:	Ptr to DPT (in RAMVARS segment)
-;		AH:		BIOS Error code
-;		CX:		Number of successfully transferred sectors
-;		CF:		0 if transfer succesfull
-;				1 if any error
-;	Corrupts registers:
-;		AL, BX, DX, SI, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-ReadFromDrive:
-	; Wait until drive is ready to transfer
-	xchg	di, si								; DS:DI now points DPT
-	call	IdeWait_IRQorDRQ					; Wait until ready to transfer
-	jc		SHORT ReturnWithTransferErrorInAH
-	xchg	si, di								; ES:DI now points buffer
-
-ALIGN JUMP_ALIGN
-.ReadNextBlockFromDrive:
-	mov		cx, [bp+PIOVARS.wWordsInBlock]
-	mov		dx, [bp+PIOVARS.wDataPort]
-	cmp		[bp+PIOVARS.wWordsLeft], cx
-	jbe		SHORT .ReadLastBlockFromDrive
-	call	[bp+PIOVARS.fnXfer]
-
-	; Wait until ready for next block and check for errors
-	xchg	di, si								; DS:DI now points DPT
-	call	IdeWait_IRQorDRQ					; Wait until ready to transfer
-	jc		SHORT ReturnWithTransferErrorInAH
-	xchg	si, di								; ES:DI now points buffer
-
-	; Increment number of successfully read WORDs
-	mov		ax, [bp+PIOVARS.wWordsInBlock]
-	sub		[bp+PIOVARS.wWordsLeft], ax
-	add		[bp+PIOVARS.wWordsDone], ax
-	jmp		SHORT .ReadNextBlockFromDrive
-
-ALIGN JUMP_ALIGN
-.ReadLastBlockFromDrive:
-	mov		cx, [bp+PIOVARS.wWordsLeft]
-	call	[bp+PIOVARS.fnXfer]					; Transfer possibly partial block
-
-	; Check for errors in last block
-	mov		di, si								; DS:DI now points DPT
-CheckErrorsAfterTransferringLastBlock:
-	mov		bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
-	call	IdeWait_PollStatusFlagInBLwithTimeoutInBH
-
-	; Return number of successfully read sectors
-ReturnWithTransferErrorInAH:
-	mov		cx, [bp+PIOVARS.wWordsDone]
-	jc		SHORT .ConvertTransferredWordsInCXtoSectors
-	add		cx, [bp+PIOVARS.wWordsLeft]			; Never sets CF
-.ConvertTransferredWordsInCXtoSectors:
-	xchg	cl, ch
-	ret
-
-
-;--------------------------------------------------------------------
 ; InitializePiovarsInSSBPwithSectorCountInAH
 ;	Parameters:
@@ -180,5 +178,5 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, CX, DX
+;		AX, BX, DX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
@@ -187,17 +185,17 @@
 	xor		al, al
 	mov		[bp+PIOVARS.wWordsLeft], ax
+	mov		ah, [di+DPT_ATA.bSetBlock]
+	mov		[bp+PIOVARS.wWordsInBlock], ax
 	cbw
 	mov		[bp+PIOVARS.wWordsDone], ax			; Zero
-	mov		ah, [di+DPT_ATA.bSetBlock]
-	mov		[bp+PIOVARS.wWordsInBlock], ax
 
 	; Get transfer function based on bus type
 	xchg	ax, bx								; Lookup table offset to AX
-	eMOVZX	bx, BYTE [di+DPT.bIdevarsOffset]	; CS:BX now points to IDEVARS
+	mov		bl, [di+DPT.bIdevarsOffset]			; CS:BX now points to IDEVARS
 	mov		dx, [cs:bx+IDEVARS.wPort]			; Load IDE Data port address
 	mov		bl, [cs:bx+IDEVARS.bDevice]			; Load device type to BX
 	add		bx, ax
+	mov		[bp+PIOVARS.wDataPort], dx
 	mov		ax, [cs:bx]							; Load offset to transfer function
-	mov		[bp+PIOVARS.wDataPort], dx
 	mov		[bp+PIOVARS.fnXfer], ax
 	ret
@@ -213,5 +211,5 @@
 ;		CX:		Block size in WORDs
 ;		DX:		IDE Data port address
-;		ES:DI:	Normalized ptr to buffer to recieve data
+;		ES:DI:	Normalized ptr to buffer to receive data
 ;	Returns:
 ;		Nothing
@@ -236,6 +234,9 @@
 SingleByteRead:
 %ifdef USE_186	; INS instruction available
+	dec		cx			; Avoid overflowing CX on a 128 sector transfer
 	shl		cx, 1		; WORD count to BYTE count
+	inc		cx
 	rep insb
+	insb
 %else			; If 8088/8086
 	shr		cx, 1		; WORD count to DWORD count
@@ -328,7 +329,10 @@
 SingleByteWrite:
 %ifdef USE_186	; OUTS instruction available
+	dec		cx			; Avoid overflowing CX on a 128 sector transfer
 	shl		cx, 1		; WORD count to BYTE count
+	inc		cx
 	es					; Source is ES segment
 	rep outsb
+	es outsb
 %else			; If 8088/8086
 	shr		cx, 1		; WORD count to DWORD count
@@ -386,5 +390,4 @@
 
 
-
 ; Lookup tables to get transfer function based on bus type
 ALIGN WORD_ALIGN
Index: trunk/XTIDE_Universal_BIOS/Src/Device/MemoryMappedIDE/MemIdeTransfer.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/MemoryMappedIDE/MemIdeTransfer.asm	(revision 241)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/MemoryMappedIDE/MemIdeTransfer.asm	(revision 242)
@@ -8,5 +8,6 @@
 	.wWordsLeft				resb	2	; 2, WORDs left to transfer
 	.wWordsDone				resb	2	; 4, Number of sectors xferred
-							resb	1	; 6, 
+	; TODO: The above word vars could just as well be byte vars?
+							resb	1	; 6,
 							resb	1	; 7, IDEPACK.bDeviceControl
 	.fpDPT					resb	4	; 8, Far pointer to DPT
@@ -34,44 +35,28 @@
 ALIGN JUMP_ALIGN
 MemIdeTransfer_StartWithCommandInAL:
+	push	cs	; We push CS here (segment of SAW) and later pop it to DS (reads) or ES (writes)
+
 	; Initialize MEMPIOVARS
-	xchg	cx, ax								; IDE command to CL
-	xor		al, al
-	mov		ah, [bp+IDEPACK.bSectorCount]
-	mov		[bp+MEMPIOVARS.wWordsLeft], ax
-	cbw
-	mov		[bp+MEMPIOVARS.wWordsDone], ax		; Zero
-	mov		ah, [di+DPT_ATA.bSetBlock]
-	mov		[bp+MEMPIOVARS.wWordsInBlock], ax
+	xor		cx, cx
+	mov		[bp+MEMPIOVARS.wWordsDone], cx
+	mov		ch, [bp+IDEPACK.bSectorCount]
+	mov		[bp+MEMPIOVARS.wWordsLeft], cx
+	mov		ch, [di+DPT_ATA.bSetBlock]
+	mov		[bp+MEMPIOVARS.wWordsInBlock], cx
 	mov		[bp+MEMPIOVARS.fpDPT], di
 	mov		[bp+MEMPIOVARS.fpDPT+2], ds
 
 	; Are we reading or writing?
-	test	cl, 16	; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands
-	jnz		SHORT .PrepareToWriteDataFromESSI
-	cmp		cl, COMMAND_WRITE_MULTIPLE
-	je		SHORT .PrepareToWriteDataFromESSI
-
-	; Prepare to read data to ES:DI
-	mov		di, si
-	push	cs
-	pop		ds
-	mov		si, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET
-	jmp		SHORT ReadFromSectorAccessWindowInDSSItoESDI
-
-ALIGN JUMP_ALIGN
-.PrepareToWriteDataFromESSI:
-	push	es
-	pop		ds
-	push	cs
-	pop		es
-	mov		di, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET
-	; Fall to WriteToSectorAccessWindowInESDIfromDSSI
-
-
-;--------------------------------------------------------------------
-; WriteToSectorAccessWindowInESDIfromDSSI
-;	Parameters:
-;		DS:SI:	Normalized ptr to buffer containing data
-;		ES:DI:	Ptr to Sector Access Window
+	test	al, 16	; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands
+	jnz		SHORT WriteToSectorAccessWindow
+	cmp		al, COMMAND_WRITE_MULTIPLE
+	je		SHORT WriteToSectorAccessWindow
+	; Fall to ReadFromSectorAccessWindow
+
+;--------------------------------------------------------------------
+; ReadFromSectorAccessWindow
+;	Parameters:
+;		Stack:	Segment part of ptr to Sector Access Window
+;		ES:SI:	Normalized ptr to buffer to receive data
 ;		SS:BP:	Ptr to MEMPIOVARS
 ;	Returns:
@@ -84,85 +69,18 @@
 ;		AL, BX, DX, SI, ES
 ;--------------------------------------------------------------------
-WriteToSectorAccessWindowInESDIfromDSSI:
-	; Always poll when writing first block (IRQs are generated for following blocks)
-	call	WaitUntilReadyToTransferNextBlock
-	jc		SHORT ReturnWithMemoryIOtransferErrorInAH
-
-ALIGN JUMP_ALIGN
-.WriteNextBlockToDrive:
-	mov		cx, [bp+PIOVARS.wWordsInBlock]
-	cmp		[bp+PIOVARS.wWordsLeft], cx
-	jbe		SHORT .WriteLastBlockToDrive
-	eMOVZX	dx, ch								; DX = Sectors in block
-	call	WriteSingleBlockFromDSSIToSectorAccessWindowInESDI
-	call	WaitUntilReadyToTransferNextBlock
-	jc		SHORT ReturnWithMemoryIOtransferErrorInAH
-
-	; Increment number of successfully written WORDs
-	mov		ax, [bp+PIOVARS.wWordsInBlock]
-	sub		[bp+PIOVARS.wWordsLeft], ax
-	add		[bp+PIOVARS.wWordsDone], ax
-	jmp		SHORT .WriteNextBlockToDrive
-
-ALIGN JUMP_ALIGN
-.WriteLastBlockToDrive:
-	eMOVZX	dx, BYTE [bp+PIOVARS.wWordsLeft+1]	; Sectors left
-%ifdef USE_186
-	push	CheckErrorsAfterTransferringLastMemoryMappedBlock
-	jmp		WriteSingleBlockFromDSSIToSectorAccessWindowInESDI
-%else
-	call	WriteSingleBlockFromDSSIToSectorAccessWindowInESDI
-	jmp		SHORT CheckErrorsAfterTransferringLastMemoryMappedBlock
-%endif
-
-
-;--------------------------------------------------------------------
-; WriteSingleBlockFromDSSIToSectorAccessWindowInESDI
-;	Parameters:
-;		DX:		Number of sectors in block
-;		DS:SI:	Normalized ptr to source buffer
-;		ES:DI:	Ptr to Sector Access Window
-;	Returns:
-;		CX, DX:	Zero
-;		SI:		Updated
-;	Corrupts registers:
-;		Nothing
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-WriteSingleBlockFromDSSIToSectorAccessWindowInESDI:
-	mov		cx, JRIDE_SECTOR_ACCESS_WINDOW_SIZE / 2
-	rep movsw
-	sub		di, JRIDE_SECTOR_ACCESS_WINDOW_SIZE	; Reset for next sector
-	dec		dx
-	jnz		SHORT WriteSingleBlockFromDSSIToSectorAccessWindowInESDI
-	ret
-
-
-;--------------------------------------------------------------------
-; ReadFromSectorAccessWindowInDSSItoESDI
-;	Parameters:
-;		ES:DI:	Normalized ptr to buffer to recieve data
-;		DS:SI:	Ptr to Sector Access Window
-;		SS:BP:	Ptr to MEMPIOVARS
-;	Returns:
-;		DS:DI:	Ptr to DPT (in RAMVARS segment)
-;		AH:		BIOS Error code
-;		CX:		Number of successfully transferred sectors
-;		CF:		0 if transfer succesfull
-;				1 if any error
-;	Corrupts registers:
-;		AL, BX, DX, SI, ES
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-ReadFromSectorAccessWindowInDSSItoESDI:
-	call	WaitUntilReadyToTransferNextBlock
-	jc		SHORT ReturnWithMemoryIOtransferErrorInAH
+ReadFromSectorAccessWindow:
+	pop		ds	; CS -> DS
+	mov		di, si
+	mov		si, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET
+
+	call	WaitUntilReadyToTransferNextBlock
+	jc		SHORT ReturnWithMemoryIOtransferErrorInAH
+
+	mov		cx, [bp+PIOVARS.wWordsInBlock]
 
 ALIGN JUMP_ALIGN
 .ReadNextBlockFromDrive:
-	mov		cx, [bp+PIOVARS.wWordsInBlock]
 	cmp		[bp+PIOVARS.wWordsLeft], cx
 	jbe		SHORT .ReadLastBlockFromDrive
-	eMOVZX	dx, ch								; DX = Sectors in block
 	call	ReadSingleBlockFromSectorAccessWindowInDSSItoESDI
 	call	WaitUntilReadyToTransferNextBlock
@@ -170,12 +88,12 @@
 
 	; Increment number of successfully read WORDs
-	mov		ax, [bp+PIOVARS.wWordsInBlock]
-	sub		[bp+PIOVARS.wWordsLeft], ax
-	add		[bp+PIOVARS.wWordsDone], ax
+	mov		cx, [bp+PIOVARS.wWordsInBlock]
+	sub		[bp+PIOVARS.wWordsLeft], cx
+	add		[bp+PIOVARS.wWordsDone], cx
 	jmp		SHORT .ReadNextBlockFromDrive
 
 ALIGN JUMP_ALIGN
 .ReadLastBlockFromDrive:
-	eMOVZX	dx, BYTE [bp+PIOVARS.wWordsLeft+1]	; Sectors left
+	mov		ch, [bp+PIOVARS.wWordsLeft+1]		; Sectors left
 	call	ReadSingleBlockFromSectorAccessWindowInDSSItoESDI
 
@@ -186,5 +104,5 @@
 	call	IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH
 
-	; Return number of successfully read sectors
+	; Return number of successfully transferred sectors
 ReturnWithMemoryIOtransferErrorInAH:
 	lds		di, [bp+MEMPIOVARS.fpDPT]			; DPT now in DS:DI
@@ -198,8 +116,88 @@
 
 ;--------------------------------------------------------------------
+; WriteToSectorAccessWindow
+;	Parameters:
+;		Stack:	Segment part of ptr to Sector Access Window
+;		ES:SI:	Normalized ptr to buffer containing data
+;		SS:BP:	Ptr to MEMPIOVARS
+;	Returns:
+;		DS:DI:	Ptr to DPT (in RAMVARS segment)
+;		AH:		BIOS Error code
+;		CX:		Number of successfully transferred sectors
+;		CF:		0 if transfer succesfull
+;				1 if any error
+;	Corrupts registers:
+;		AL, BX, DX, SI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+WriteToSectorAccessWindow:
+	push	es
+	pop		ds
+	pop		es	; CS -> ES
+	mov		di, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET
+
+	; Always poll when writing first block (IRQs are generated for following blocks)
+	call	WaitUntilReadyToTransferNextBlock
+	jc		SHORT ReturnWithMemoryIOtransferErrorInAH
+
+	mov		cx, [bp+PIOVARS.wWordsInBlock]
+
+ALIGN JUMP_ALIGN
+.WriteNextBlockToDrive:
+	cmp		[bp+PIOVARS.wWordsLeft], cx
+	jbe		SHORT .WriteLastBlockToDrive
+	call	WriteSingleBlockFromDSSIToSectorAccessWindowInESDI
+	call	WaitUntilReadyToTransferNextBlock
+	jc		SHORT ReturnWithMemoryIOtransferErrorInAH
+
+	; Increment number of successfully written WORDs
+	mov		cx, [bp+PIOVARS.wWordsInBlock]
+	sub		[bp+PIOVARS.wWordsLeft], cx
+	add		[bp+PIOVARS.wWordsDone], cx
+	jmp		SHORT .WriteNextBlockToDrive
+
+ALIGN JUMP_ALIGN
+.WriteLastBlockToDrive:
+	mov		ch, [bp+PIOVARS.wWordsLeft+1]		; Sectors left
+%ifndef USE_186
+	mov		bx, CheckErrorsAfterTransferringLastMemoryMappedBlock
+	push	bx
+%else
+	push	CheckErrorsAfterTransferringLastMemoryMappedBlock
+%endif
+	; Fall to WriteSingleBlockFromDSSIToSectorAccessWindowInESDI
+
+;--------------------------------------------------------------------
+; WriteSingleBlockFromDSSIToSectorAccessWindowInESDI
+;	Parameters:
+;		CH:		Number of sectors in block
+;		DS:SI:	Normalized ptr to source buffer
+;		ES:DI:	Ptr to Sector Access Window
+;	Returns:
+;		CX, DX:	Zero
+;		SI:		Updated
+;	Corrupts registers:
+;		BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+WriteSingleBlockFromDSSIToSectorAccessWindowInESDI:
+	mov		bx, di
+	eMOVZX	dx, ch
+	xor		cl, cl
+ALIGN JUMP_ALIGN
+.WriteBlock:
+	mov		ch, JRIDE_SECTOR_ACCESS_WINDOW_SIZE >> 9
+	rep movsw
+	mov		di, bx	; Reset for next sector
+	dec		dx
+	jnz		SHORT .WriteBlock
+	ret
+
+
+;--------------------------------------------------------------------
 ; ReadSingleBlockFromSectorAccessWindowInDSSItoESDI
 ;	Parameters:
-;		DX:		Number of sectors in block
-;		ES:DI:	Normalized ptr to buffer to recieve data (destination)
+;		CH:		Number of sectors in block
+;		ES:DI:	Normalized ptr to buffer to receive data (destination)
 ;		DS:SI:	Ptr to Sector Access Window (source)
 ;	Returns:
@@ -207,13 +205,18 @@
 ;		DI:		Updated
 ;	Corrupts registers:
-;		Nothing
+;		BX
 ;--------------------------------------------------------------------
 ALIGN JUMP_ALIGN
 ReadSingleBlockFromSectorAccessWindowInDSSItoESDI:
-	mov		cx, JRIDE_SECTOR_ACCESS_WINDOW_SIZE / 2
+	mov		bx, si
+	eMOVZX	dx, ch
+	xor		cl, cl
+ALIGN JUMP_ALIGN
+.ReadBlock:
+	mov		ch, JRIDE_SECTOR_ACCESS_WINDOW_SIZE >> 9
 	rep movsw
-	sub		si, JRIDE_SECTOR_ACCESS_WINDOW_SIZE	; Reset for next sector
+	mov		si, bx	; Reset for next sector
 	dec		dx
-	jnz		SHORT ReadSingleBlockFromSectorAccessWindowInDSSItoESDI
+	jnz		SHORT .ReadBlock
 	ret
 
@@ -238,2 +241,8 @@
 	pop		ds
 	ret
+
+
+%if JRIDE_SECTOR_ACCESS_WINDOW_SIZE <> 512
+	%error "JRIDE_SECTOR_ACCESS_WINDOW_SIZE is no longer equal to 512. MemIdeTransfer.asm needs changes."
+%endif
+
Index: trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm	(revision 241)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm	(revision 242)
@@ -112,6 +112,6 @@
 		mov		ch,dh
 		xor		dh,dh
-		eSHL_IM	dx, 2			; shift from one byte to two		
-		
+		eSHL_IM	dx, 2			; shift from one byte to two
+
 		mov		al,[bp+IDEPACK.bSectorCount]
 
@@ -599,5 +599,5 @@
 ;		   wSerialPortAndBaud Non-Zero:
 ;		   	   previous serial drive not found:   -> Error - Not Found (4)
-;			   previosu serial drive found:       -> Continue with wSerialPackedAndBaud (5)
+;			   previous serial drive found:       -> Continue with wSerialPackedAndBaud (5)
 ;          wSerialPortAndBaud Zero:
 ;		   	   previous serial drive not found:	  -> Error - Not Found (4)
@@ -608,5 +608,5 @@
 ;     And as with the int13h/25h case, we just go off and get the needed information using the user's setting.
 ; (2) We are using the special .ideVarsSerialAuto structure.  During drive detection, we would only be here
-;     if we hand't already seen a serial drive (since we only scan if no explicit drives are set),
+;     if we hadn't already seen a serial drive (since we only scan if no explicit drives are set),
 ;     so we go off to scan.
 ; (3) We are using the special .ideVarsSerialAuto structure.  We won't get here during drive detection, but
@@ -633,6 +633,6 @@
 		pop		si
 		jnc		.notfounddpt
-		mov		ax,[ds:di+DPT_SERIAL.wSerialPortAndBaud]
-.notfounddpt:	
+		mov		ax, [di+DPT_SERIAL.wSerialPortAndBaud]
+.notfounddpt:
 
 		test	bh, FLG_DRVNHEAD_DRV
@@ -647,5 +647,5 @@
 		jnz		.identifyDeviceInDX
 
-		or		dx,ax			; Since DX is zero, this effectively moves the previously found serial drive 
+		or		dx,ax			; Since DX is zero, this effectively moves the previously found serial drive
 								; information to dx, as well as test for zero
 		jz		.scanSerial
@@ -672,8 +672,8 @@
 		pop		cx
 		pop		dx
-		
+
 		pop		bp
 ;
-; place port and baud word in to the return sector, in a vendor specific area, 
+; place port and baud word in to the return sector, in a vendor specific area,
 ; which is read by FinalizeDPT and DetectDrives
 ;
@@ -732,7 +732,7 @@
 ; Begin baud rate scan on this port...
 ;
-; On a scan, we support 6 baud rates, starting here and going higher by a factor of two each step, with a 
+; On a scan, we support 6 baud rates, starting here and going higher by a factor of two each step, with a
 ; small jump between 9600 and 38800.  These 6 were selected since we wanted to support 9600 baud and 115200,
-; *on the server side* if the client side had a 4x clock multiplier, a 2x clock multiplier, or no clock multiplier. 
+; *on the server side* if the client side had a 4x clock multiplier, a 2x clock multiplier, or no clock multiplier.
 ;
 ; Starting with 30h, that means 30h (2400 baud), 18h (4800 baud), 0ch (9600 baud), and
@@ -747,5 +747,5 @@
 		shr		dh,1
 		jz		.nextPort
-		cmp		dh,6			; skip from 6 to 4, to move from the top of the 9600 baud range 
+		cmp		dh,6			; skip from 6 to 4, to move from the top of the 9600 baud range
 		jnz		.testBaud		; to the bottom of the 115200 baud range
 		mov		dh,4
Index: trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm	(revision 241)
+++ trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm	(revision 242)
@@ -13,10 +13,10 @@
 ;		Nothing
 ;	Corrupts registers:
-;		AX, BX, CX, DX
+;		AX
 ;--------------------------------------------------------------------
 SerialDPT_Finalize:
 		or		byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
 		mov		ax, [es:si+ATA6.wVendor]
-		mov		word [di+DPT_SERIAL.wSerialPortAndBaud], ax
+		mov		[di+DPT_SERIAL.wSerialPortAndBaud], ax
 		ret
 
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 241)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm	(revision 242)
@@ -29,18 +29,18 @@
 
 	mov		cx, g_szDetectSlave
-	mov		bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV  
+	mov		bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV
 	call	StartDetectionWithDriveSelectByteInBHandStringInAX
-		
+
 	pop		cx
 
 	add		bp, BYTE IDEVARS_size			; Point to next IDEVARS
 
-%ifdef MODULE_SERIAL		
+%ifdef MODULE_SERIAL
 	jcxz	.done							; Set to zero on .ideVarsSerialAuto iteration (if any)
 %endif
-		
+
 	loop	.DriveDetectLoop
 
-%ifdef MODULE_SERIAL		
+%ifdef MODULE_SERIAL
 ;
 ; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we already have a connection)
@@ -49,10 +49,10 @@
 	jc		.done
 
-	mov		bp, ROMVARS.ideVarsSerialAuto	; Point to our special IDEVARS sructure, just for serial scans		
-				
+	mov		bp, ROMVARS.ideVarsSerialAuto	; Point to our special IDEVARS structure, just for serial scans
+
 	mov		al,[cs:ROMVARS.wFlags]			; Configurator set to always scan?
 	or		al,[es:BDA.bKBFlgs1]			; Or, did the user hold down the ALT key?
 	and		al,8							; 8 = alt key depressed, same as FLG_ROMVARS_SERIAL_ALWAYSDETECT
-	jnz		.DriveDetectLoop							
+	jnz		.DriveDetectLoop
 %endif
 
@@ -61,8 +61,8 @@
 
 %if FLG_ROMVARS_SERIAL_SCANDETECT != 8
-%error "DetectDrives is currently coded to assume that FLG_ROMVARS_SERIAL_SCANDETECT is the same bit as the ALT key code in the BDA.  Changes in the code will be needed if these values are no longer the same."
+	%error "DetectDrives is currently coded to assume that FLG_ROMVARS_SERIAL_SCANDETECT is the same bit as the ALT key code in the BDA.  Changes in the code will be needed if these values are no longer the same."
 %endif
 
-		
+
 ;--------------------------------------------------------------------
 ; StartDetectionWithDriveSelectByteInBHandStringInAX
@@ -110,5 +110,5 @@
 	;call	ReadAtapiInfoFromDrive		; Assume CD-ROM
 	;jnc	SHORT _CreateBiosTablesForCDROM
-	
+
 	;jmp	short DetectDrives_DriveNotFound
 ;;; fall-through instead of previous jmp instruction
@@ -122,7 +122,7 @@
 ;		AX, SI
 ;--------------------------------------------------------------------
-DetectDrives_DriveNotFound:		
+DetectDrives_DriveNotFound:
 	mov		si, g_szNotFound
-	jmp		BootMenuPrint_NullTerminatedStringFromCSSIandSetCF		
+	jmp		BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
 
 
Index: trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 241)
+++ trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm	(revision 242)
@@ -22,6 +22,6 @@
 	ePUSH_T	ax, ROMVARS.szTitle			; Bios title string
 	push	cs							; BIOS segment
-		
-DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:		
+
+DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
 	jmp		BootMenuPrint_FormatCSSIfromParamsInSSBP
 
@@ -32,5 +32,5 @@
 ;		CS:CX:	Ptr to "Master" or "Slave" string
 ;		CS:BP:	Ptr to IDEVARS
-;       SI:		Ptr to template string 
+;       SI:		Ptr to template string
 ;	Returns:
 ;		Nothing
@@ -44,9 +44,9 @@
 											;			  DL=COM number character, DH=.bDevice
 
-	push	bp								; setup stack for call to 
+	push	bp								; setup stack for call to
 	mov		bp, sp							; BootMenuPrint_FormatCSSIfromParamsInSSBP
 
 	push 	cx								; Push "Master" or "Slave"
-		
+
 	mov		cl, (g_szDetectPort-$$) & 0xff	; Setup print string for standard IDE
 											; Note that we modify only the low order bits of CX a lot here,
@@ -55,11 +55,11 @@
 											; on the same 256 byte page, which is checked in strings.asm.
 
-	cmp		dx, DEVICE_SERIAL_PORT << 8  	; Check if this is a serial device, 
+	cmp		dx, DEVICE_SERIAL_PORT << 8  	; Check if this is a serial device,
 										 	; And also check if DL is zero, check with the jz below
-											; This optimization requires that DEVICE_SERIAL_PORT be 
+											; This optimization requires that DEVICE_SERIAL_PORT be
 											; the highest value in the DEVICE_* series, ensuring that
 											; anything less in the high order bits is a different device.
 
-	jl		.pushAndPrint					; CX = string to print, AX = port address, DX won't be used
+	jb		.pushAndPrint					; CX = string to print, AX = port address, DX won't be used
 
 	mov		cl, (g_szDetectCOM-$$) & 0xff	; Setup print string for COM ports
@@ -68,13 +68,13 @@
 
 	push	dx								; Push COM number character
-											; If the strnig is going to be "Auto", we will push a NULL (zero)
-											; here for the COM port number, which will be eaten by the 
-											; print routine (DisplayPrint_CharacterFromAL), resulting in 
+											; If the string is going to be "Auto", we will push a NULL (zero)
+											; here for the COM port number, which will be eaten by the
+											; print routine (DisplayPrint_CharacterFromAL), resulting in
 											; just "COM" being printed without a character after it.
-				
+
  	mov		cl, (g_szDetectCOMAuto-$$) & 0xff	; Setup secondary print string for "Auto"
-		
+
 	jz		.pushAndPrint					; CX = string to print, AX and DX won't be used
-		
+
 	mov		cl, (g_szDetectCOMLarge-$$) & 0xff	; Setup secondary print string for "COMn/xx.yK"
 
@@ -82,18 +82,18 @@
 	cbw										; clear AH, AL will always be less than 128
 	xchg	si,ax							; move AX to SI for divide
-	mov		ax,1152							; baud rate to displa is 115200/divisor, the "00" is handled
+	mov		ax,1152							; baud rate to display is 115200/divisor, the "00" is handled
 											; in the print strings
-	xor		dx,dx							; clear top 16-bits of dividend
+	cwd										; clear top 16-bits of dividend
 	div		si								; and divide...  Now AX = baud rate/100, DX = 0 (always a clean divide)
-		
+
 	mov		si,10							; Now separate the whole portion from the fractional for "K" display
 	div		si								; and divide...  Now AX = baud rate/1000, DX = low order digit
-		
-	cmp		ax,si							; <= 10: "2400", "9600", etc.; >10: "19.2K", "38.4K", etc.
+
+	cmp		ax,si							; < 10: "2400", "9600", etc.; >= 10: "19.2K", "38.4K", etc.
 	jae		.pushAndPrint
 
 	mov		cl, (g_szDetectCOMSmall-$$) & 0xff	; Setup secondary print string for "COMn/XXy00"
-		
-.pushAndPrint:	
+
+.pushAndPrint:
 	push	cx								; Push print string
 	push	ax								; Push high order digits, or port address, or N/A
@@ -102,5 +102,5 @@
 	mov		si, g_szDetectOuter				; Finally load SI with wrapper string "IDE %s at %s: "
 
-	jmp		short DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay	
+	jmp		short DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
 
 
@@ -127,5 +127,2 @@
 	ret
 
-
-
-
Index: trunk/XTIDE_Universal_BIOS/Src/Strings.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS/Src/Strings.asm	(revision 241)
+++ trunk/XTIDE_Universal_BIOS/Src/Strings.asm	(revision 242)
@@ -3,5 +3,5 @@
 
 %ifdef MODULE_STRINGS_COMPRESSED_PRECOMPRESS
-%include "Display.inc"
+	%include "Display.inc"
 %endif
 
@@ -10,46 +10,46 @@
 
 ; The following strings are used by DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP
-; To support an optimization in that code, these strings must start on the same 256 byte page, 
+; To support an optimization in that code, these strings must start on the same 256 byte page,
 ; which is checked at assembly time below.
 ;
-g_szDetectStart:		
-g_szDetectMaster:		db	"Master",NULL 
+g_szDetectStart:
+g_szDetectMaster:		db	"Master",NULL
 g_szDetectSlave:		db	"Slave ",NULL
 g_szDetectOuter:		db	"IDE %s at %s: ",NULL
 g_szDetectPort:			db	"%x",NULL					   	; IDE Master at 1F0h:
-g_szDetectCOM:			db  "COM%c%s",NULL            
+g_szDetectCOM:			db  "COM%c%s",NULL
 g_szDetectCOMAuto:		db	" Auto",NULL
 g_szDetectCOMSmall:		db	"/%u%u00",NULL					; IDE Master at COM1/9600:
 g_szDetectEnd:
 g_szDetectCOMLarge:		db	"/%u.%uK",NULL					; IDE Master at COM1/19.2K:
-		
-%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS				
-%if ((g_szDetectEnd-$$) & 0xff00) <> ((g_szDetectStart-$$) & 0xff00)
-%error "g_szDetect* strings must start on the same 256 byte page, required by DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP.  Please move this block up or down within strings.asm"
-%endif
+
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+	%if ((g_szDetectEnd-$$) & 0xff00) <> ((g_szDetectStart-$$) & 0xff00)
+		%error "g_szDetect* strings must start on the same 256 byte page, required by DetectPrint_StartDetectWithMasterOrSlaveStringInAXandIdeVarsInCSBP.  Please move this block up or down within strings.asm"
+	%endif
 %endif
 
 ; Boot Menu menuitem strings
-; 
+;
 ; The following strings are used by BootMenuPrint_* routines.
-; To support optimizations in that code, these strings must start on the same 256 byte page, 
+; To support optimizations in that code, these strings must start on the same 256 byte page,
 ; which is checked at assembly time below.
-;		
-g_szBootMenuPrintStart:	
+;
+g_szBootMenuPrintStart:
 g_szDriveNum:			db	"%x %s",NULL
 g_szDriveNumBOOTNFO:	db	"%x %z",NULL
 g_szFloppyDrv:			db	"Floppy Drive %c",NULL
-g_szBootMenuPrintEnd:	
+g_szBootMenuPrintEnd:
 g_szForeignHD:			db	"Foreign Hard Disk",NULL
 
-%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS				
-%if ((g_szBootMenuPrintStart-$$) & 0xff00) <> ((g_szBootMenuPrintEnd-$$) & 0xff00)
-%error "g_szBootMenuPrint* strings must start on the same 256 byte page, required by the BootMenuPrint_* routines.  Please move this block up or down within strings.asm"
-%endif
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+	%if ((g_szBootMenuPrintStart-$$) & 0xff00) <> ((g_szBootMenuPrintEnd-$$) & 0xff00)
+		%error "g_szBootMenuPrint* strings must start on the same 256 byte page, required by the BootMenuPrint_* routines.  Please move this block up or down within strings.asm"
+	%endif
 %endif
 
 ; POST drive detection strings
 g_szRomAt:		db	"%s @ %x",LF,CR,NULL
-				
+
 ; Boot loader strings
 g_szTryToBoot:			db	"Booting from %s %x",ANGLE_QUOTE_RIGHT,"%x",LF,CR,NULL
@@ -63,8 +63,8 @@
 g_szRomBoot:	db	"ROM Boot",NULL
 g_szHotkey:		db	"%A%c%c%A%s%A ",NULL
-				
+
 ; Boot Menu information strings
 g_szCapacity:			db	"Capacity : %s",NULL
-g_szCapacityNum:		db	"%5-u.%u %ciB",NULL		
+g_szCapacityNum:		db	"%5-u.%u %ciB",NULL
 g_szSizeDual:			db	"%s /%s",LF,CR
 	db	"Addr.",SINGLE_VERTICAL,"Block",SINGLE_VERTICAL,"Bus",SINGLE_VERTICAL,  "IRQ",SINGLE_VERTICAL,"Reset",LF,CR
@@ -72,24 +72,24 @@
 
 ; Boot Menu Floppy Disk strings
-; 
+;
 ; The following strings are used by BootMenuPrint_RefreshInformation
-; To support optimizations in that code, these strings must start on the same 256 byte page, 
+; To support optimizations in that code, these strings must start on the same 256 byte page,
 ; which is checked at assembly time below.
-;				
-g_szFddStart:	
+;
+g_szFddStart:
 g_szFddUnknown:	db	"Unknown",NULL
 g_szFddSizeOr:	db	"5",ONE_QUARTER,QUOTATION_MARK," or 3",ONE_HALF,QUOTATION_MARK," DD",NULL
 g_szFddSize:	db	"%s",QUOTATION_MARK,", %u kiB",NULL	; 3½", 1440 kiB
 g_szFddThreeHalf:		db  "3",ONE_HALF,NULL
-g_szFddEnd:		
+g_szFddEnd:
 g_szFddFiveQuarter:		db  "5",ONE_QUARTER,NULL
 
-%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS				
-%if ((g_szFddStart-$$) & 0xff00) <> ((g_szFddEnd-$$) & 0xff00)
-%error "g_szFdd* strings must start on the same 256 byte page, required by the BootMenuPrint_RefreshInformation routines for floppy drives.  Please move this block up or down within strings.asm"
-%endif
-%endif						
-
-g_szAddressingModes:					
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+	%if ((g_szFddStart-$$) & 0xff00) <> ((g_szFddEnd-$$) & 0xff00)
+		%error "g_szFdd* strings must start on the same 256 byte page, required by the BootMenuPrint_RefreshInformation routines for floppy drives.  Please move this block up or down within strings.asm"
+	%endif
+%endif
+
+g_szAddressingModes:
 g_szLCHS:		db	"L-CHS",NULL
 g_szPCHS:		db	"P-CHS",NULL
@@ -100,20 +100,20 @@
 ; Ensure that addressing modes are correctly spaced in memory
 ;
-%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS		
-%if g_szLCHS <> g_szAddressingModes
-%error "g_szAddressingModes Displacement Incorrect 1"
-%endif
-%if g_szPCHS <> g_szLCHS + g_szAddressingModes_Displacement
-%error "g_szAddressingModes Displacement Incorrect 2"
-%endif
-%if g_szLBA28 <> g_szPCHS + g_szAddressingModes_Displacement		
-%error "g_szAddressingModes Displacement Incorrect 3"
-%endif
-%if g_szLBA48 <> g_szLBA28 + g_szAddressingModes_Displacement		
-%error "g_szAddressingModes Displacement Incorrect 4"
-%endif
-%endif		
-		
-g_szBusTypeValues:		
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+	%if g_szLCHS <> g_szAddressingModes
+		%error "g_szAddressingModes Displacement Incorrect 1"
+	%endif
+	%if g_szPCHS <> g_szLCHS + g_szAddressingModes_Displacement
+		%error "g_szAddressingModes Displacement Incorrect 2"
+	%endif
+	%if g_szLBA28 <> g_szPCHS + g_szAddressingModes_Displacement
+		%error "g_szAddressingModes Displacement Incorrect 3"
+	%endif
+	%if g_szLBA48 <> g_szLBA28 + g_szAddressingModes_Displacement
+		%error "g_szAddressingModes Displacement Incorrect 4"
+	%endif
+%endif
+
+g_szBusTypeValues:
 g_szBusTypeValues_8Dual:		db		"D8 ",NULL
 g_szBusTypeValues_8Reversed:	db		"X8 ",NULL
@@ -126,25 +126,25 @@
 ; Ensure that bus type strings are correctly spaced in memory
 ;
-%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS				
-%if g_szBusTypeValues_8Dual <> g_szBusTypeValues
-%error "g_szBusTypeValues Displacement Incorrect 1"
-%endif
-%if g_szBusTypeValues_8Reversed <> g_szBusTypeValues + g_szBusTypeValues_Displacement
-%error "g_szBusTypeValues Displacement Incorrect 2"		
-%endif
-%if g_szBusTypeValues_8Single <> g_szBusTypeValues_8Reversed + g_szBusTypeValues_Displacement
-%error "g_szBusTypeValues Displacement Incorrect 3"				
-%endif
-%if g_szBusTypeValues_16 <> g_szBusTypeValues_8Single + g_szBusTypeValues_Displacement		
-%error "g_szBusTypeValues Displacement Incorrect 4"				
-%endif
-%if g_szBusTypeValues_32 <> g_szBusTypeValues_16 + g_szBusTypeValues_Displacement
-%error "g_szBusTypeValues Displacement Incorrect 5"				
-%endif
-%if g_szBusTypeValues_Serial <> g_szBusTypeValues_32 + g_szBusTypeValues_Displacement
-%error "g_szBusTypeValues Displacement Incorrect 6"				
-%endif
-%endif
-		
+%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
+	%if g_szBusTypeValues_8Dual <> g_szBusTypeValues
+		%error "g_szBusTypeValues Displacement Incorrect 1"
+	%endif
+	%if g_szBusTypeValues_8Reversed <> g_szBusTypeValues + g_szBusTypeValues_Displacement
+		%error "g_szBusTypeValues Displacement Incorrect 2"
+	%endif
+	%if g_szBusTypeValues_8Single <> g_szBusTypeValues_8Reversed + g_szBusTypeValues_Displacement
+		%error "g_szBusTypeValues Displacement Incorrect 3"
+	%endif
+	%if g_szBusTypeValues_16 <> g_szBusTypeValues_8Single + g_szBusTypeValues_Displacement
+		%error "g_szBusTypeValues Displacement Incorrect 4"
+	%endif
+	%if g_szBusTypeValues_32 <> g_szBusTypeValues_16 + g_szBusTypeValues_Displacement
+		%error "g_szBusTypeValues Displacement Incorrect 5"
+	%endif
+	%if g_szBusTypeValues_Serial <> g_szBusTypeValues_32 + g_szBusTypeValues_Displacement
+		%error "g_szBusTypeValues Displacement Incorrect 6"
+	%endif
+%endif
+
 g_szSelectionTimeout:	db		DOUBLE_BOTTOM_LEFT_CORNER,DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL,"%ASelection in %2-u s",NULL
 
@@ -153,5 +153,5 @@
 
 ;------------------------------------------------------------------------------------------
-; 
+;
 ; Tables for StringsCompress.pl
 ;
@@ -167,5 +167,5 @@
 ;$translate{ord('.')} = 9;
 ;$translate{ord('/')} = 10;
-;$translate{ord('1')} = 11;    
+;$translate{ord('1')} = 11;
 ;$translate{ord('2')} = 12;
 ;$translate{ord('3')} = 13;
@@ -197,5 +197,5 @@
 ;
 ; Starting point for the "normal" range, typically around 0x40 to cover upper and lower case
-; letters.  If lower case 'z' is not used, 0x3a can be a good choice as it adds ':' to the 
+; letters.  If lower case 'z' is not used, 0x3a can be a good choice as it adds ':' to the
 ; front end.
 ;
@@ -207,4 +207,2 @@
 
 
-
-
