	Title Re_name
	page ,132

;-------------------------------------------------------------------------

DATA	SEGMENT	PUBLIC	'DATA'
		DB	'RE_NAME '
SP_SAVE		DW	0
		DD	RE_NAME
		DD	0

DATA	ENDS

;-------------------------------------------------------------------------

;	PARAMETER LIST CONTROL BLOCK

FRAME	STRUC

	PARM1	DD	?	;OLD FILE (CHARACTER*80)
	PARM2	DD	?	;NEW FILE (CHARACTER*80)
	PARM3	DD	?	;ERROR (INTEGER*2)

FRAME	ENDS
;-------------------------------------------------------------------------


;-------------------CODE SEGMENT DEFINITION FOR PROFORT-------------------

CODE	SEGMENT	PARA	PUBLIC	'CODE'
	ASSUME	CS:CODE,DS:DATA			;required by RMFORT
	DW	SEG DATA			;required by RMFORT
;-------------------------------------------------------------------------
PUBLIC	RE_NAME
RE_NAME	PROC	FAR
	ASSUME	CS:CODE			;
	MOV	AX,DATA			;standard preamble, only CS,
	MOV	DS,AX			;SS, and SP must be maintained
	MOV	SP_SAVE,SP		;for PROFORT. Module address is

	LDS	SI,ES:PARM1[BX]
	MOV	DX,[SI+2]		;OFFSET OF OLD FILE NAME INTO DX
	MOV	AX,[SI+4]		;SEGMENT OF OLD FILE NAME INTO AX

	LDS	SI,ES:PARM2[BX]
	MOV	DI,[SI+2]		;OFFSET OF NEW FILE NAME INTO DI
	MOV	CX,[SI+4]		;SEGMENT OF NEW FILE NAME INTO CX

	PUSH	ES

	MOV	DS,AX
	MOV	ES,CX

	MOV	AH,56H			;RENAME OLD FILE TO NEW FILE
	INT	21H			;IF CARRY IS SET, AX=ERROR CODE

	POP	ES

	JC	RENAME_ERROR

	LDS	SI,ES:PARM3[BX]		;GET ADDR OF ERROR
	MOV	WORD PTR [SI],0			;NO ERROR
	JMP	RETURN

RENAME_ERROR:
	LDS	SI,ES:PARM3[BX]
	MOV	[SI],AX			;SET ERROR


RETURN:	RET

RE_NAME	ENDP
;-------------------------------------------------------------------------

CODE	ENDS
	END
