Newer
Older
uBix-Retro / dump / oa-2.0.9 / apps / file / mv.a65
/****************************************************************************
   
    OS/A65 Version 2.0.0
    lib6502 mv program

    Copyright (C) 1997-1998 Andre Fachat 

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

****************************************************************************/


#include "lib6502.i65"

main	.(
	.zero
argp	.word 0
	.text

	sta argp
	sty argp+1

	ldy #0
l0	lda (argp),y
	beq first
	iny
	bne l0

first	iny
	lda (argp),y
	bne ok
	
usage	lda #<usagetxt
	ldy #>usagetxt
	jmp etxtout

ok	tya
	clc
	adc argp
	sta argp
	bcc l1
	inc argp+1
l1
	ldy #0
c0	lda (argp),y
	beq c1
	iny
	bne c0
c1	iny
	lda (argp),y
	beq usage
c2	lda (argp),y
	beq c3
	iny
	bne c2
c3	iny
	lda (argp),y
	bne usage

	lda argp
	ldy argp+1
	ldx #FC_RENAME
	jsr fcmd

	/* TODO: print error code */

	rts

etxtout	
	.zero
tp	.word 0
	.text

	sta tp
	sty tp+1
	ldx #STDERR
	ldy #0
t0	lda (tp),y
	beq te
	sec
	jsr fputc
	iny
	bne t0
te	rts

usagetxt
	.byt 13,10,"Usage:",13,10," mv oldfilename newfilename",13,10,0

	.)