Index: trunk/Assembly_Library/Src/File/FileIO.asm
===================================================================
--- trunk/Assembly_Library/Src/File/FileIO.asm	(revision 592)
+++ trunk/Assembly_Library/Src/File/FileIO.asm	(revision 621)
@@ -66,48 +66,4 @@
 
 ;--------------------------------------------------------------------
-; FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
-;	Parameters:
-;		BX:		File handle
-;		DX:CX:	Number of bytes to read
-;		DS:SI:	Ptr to destination buffer
-;	Returns:
-;		AX:		DOS error code if CF set
-;		CF:		Clear if successful
-;				Set if error
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-FileIO_ReadDXCXbytesToDSSIusingHandleFromBX:
-	push	bp
-	mov		bp, FileIO_ReadCXbytesToDSSIusingHandleFromBX
-	call	SplitLargeReadOrWritesToSmallerBlocks
-	pop		bp
-	ret
-
-
-;--------------------------------------------------------------------
-; FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
-;	Parameters:
-;		BX:		File handle
-;		DX:CX:	Number of bytes to write
-;		DS:SI:	Ptr to source buffer
-;	Returns:
-;		AX:		DOS error code if CF set
-;		CF:		Clear if successful
-;				Set if error
-;	Corrupts registers:
-;		AX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX:
-	push	bp
-	mov		bp, FileIO_WriteCXbytesFromDSSIusingHandleFromBX
-	call	SplitLargeReadOrWritesToSmallerBlocks
-	pop		bp
-	ret
-
-
-;--------------------------------------------------------------------
 ; File position is updated so next read will start where
 ; previous read stopped.
@@ -158,6 +114,46 @@
 
 ;--------------------------------------------------------------------
-; SplitLargeReadOrWritesToSmallerBlocks
-;	Parameters:
+; FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
+;	Parameters:
+;		BX:		File handle
+;		DX:CX:	Number of bytes to read
+;		DS:SI:	Ptr to destination buffer
+;	Returns:
+;		AX:		DOS error code if CF set
+;		CF:		Clear if successful
+;				Set if error
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+FileIO_ReadDXCXbytesToDSSIusingHandleFromBX:
+	push	bp
+	mov		bp, FileIO_ReadCXbytesToDSSIusingHandleFromBX
+	jmp		SHORT SplitLargeReadOrWriteToSmallerBlocks
+
+
+;--------------------------------------------------------------------
+; FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
+;	Parameters:
+;		BX:		File handle
+;		DX:CX:	Number of bytes to write
+;		DS:SI:	Ptr to source buffer
+;	Returns:
+;		AX:		DOS error code if CF set
+;		CF:		Clear if successful
+;				Set if error
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX:
+	push	bp
+	mov		bp, FileIO_WriteCXbytesFromDSSIusingHandleFromBX
+	; Fall to SplitLargeReadOrWriteToSmallerBlocks
+
+;--------------------------------------------------------------------
+; SplitLargeReadOrWriteToSmallerBlocks
+;	Parameters:
+;		[SP]:	Saved BP (restored on return)
 ;		BX:		File handle
 ;		BP:		Ptr to transfer function
@@ -171,6 +167,5 @@
 ;		AX
 ;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-SplitLargeReadOrWritesToSmallerBlocks:
+SplitLargeReadOrWriteToSmallerBlocks:
 	push	ds
 	push	si
@@ -199,4 +194,7 @@
 	call	NormalizeDSSI
 	call	bp
+	SKIP1B	dl
+.ErrorOccurredDuringTransfer:
+	pop		cx						; Remove bytes for last transfer
 .ReturnErrorCodeInAX:
 	pop		cx
@@ -204,8 +202,7 @@
 	pop		si
 	pop		ds
-	ret
-.ErrorOccurredDuringTransfer:
-	pop		cx						; Remove bytes for last transfer
-	jmp		SHORT .ReturnErrorCodeInAX
+	pop		bp						; Restore BP saved to stack by "caller"
+	ret
+
 
 ;--------------------------------------------------------------------
@@ -279,7 +276,6 @@
 FileIO_CloseUsingHandleFromBX:
 	mov		ah, CLOSE_FILE
-	SKIP2B	f	; cmp ax, <next instruction>
+	SKIP2B	f
 	; Fall to FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX
-
 
 ;--------------------------------------------------------------------
