Home | History | Annotate | Line # | Download | only in libdos
dos_rename.S revision 1.2.8.2
      1  1.2.8.2  toshii |	XC compatible RENAME() function
      2  1.2.8.2  toshii |	int DOS_RENAME __P((const char *path, const char *newname));
      3  1.2.8.2  toshii |
      4  1.2.8.2  toshii |	written by Yasha (ITOH Yasufumi)
      5  1.2.8.2  toshii |	public domain
      6  1.2.8.2  toshii |
      7  1.2.8.2  toshii |	$NetBSD: dos_rename.S,v 1.2.8.2 2001/07/05 08:38:27 toshii Exp $
      8  1.2.8.2  toshii 
      9  1.2.8.2  toshii #include "dos_asm.h"
     10  1.2.8.2  toshii 
     11  1.2.8.2  toshii Lbufsz	=	92	| sizeof(struct dos_nameckbuf)
     12  1.2.8.2  toshii Lnamoff	=	67	| offsetof(struct dos_nameckbuf, name)
     13  1.2.8.2  toshii Lextoff	=	86	| offsetof(struct dos_nameckbuf, ext)
     14  1.2.8.2  toshii 
     15  1.2.8.2  toshii ENTRY_NOPROFILE(DOS_RENAME)
     16  1.2.8.2  toshii 	link	%a6,#-Lbufsz*2			| allocate two  dos_nameckbuf
     17  1.2.8.2  toshii 
     18  1.2.8.2  toshii 	moveal	%sp,%a1				| dos_nameckbuf for path
     19  1.2.8.2  toshii 
     20  1.2.8.2  toshii 	pea	%sp@(Lbufsz)
     21  1.2.8.2  toshii 	movel	%a6@(4 + 8),%sp@-		| newname
     22  1.2.8.2  toshii 	.word	0xff37				| DOS_NAMECK
     23  1.2.8.2  toshii 	tstl	%d0
     24  1.2.8.2  toshii 	bmis	Lerr
     25  1.2.8.2  toshii 
     26  1.2.8.2  toshii 	addql	#4,%sp
     27  1.2.8.2  toshii 
     28  1.2.8.2  toshii 	movel	%a1,%sp@
     29  1.2.8.2  toshii 	movel	%a6@(4 + 4),%sp@-		| (old) path
     30  1.2.8.2  toshii 	.word	0xff37				| DOS_NAMECK
     31  1.2.8.2  toshii 	tstl	%d0
     32  1.2.8.2  toshii 	bmis	Lerr
     33  1.2.8.2  toshii 
     34  1.2.8.2  toshii 	| we don't pop arguments since the same args are used by DOS_MOVE below
     35  1.2.8.2  toshii 
     36  1.2.8.2  toshii 	| search end of dirname of (old) path
     37  1.2.8.2  toshii Lpath:	tstb	%a1@+
     38  1.2.8.2  toshii 	bnes	Lpath
     39  1.2.8.2  toshii 	subql	#1,%a1				| remove nul char
     40  1.2.8.2  toshii 
     41  1.2.8.2  toshii 	| add new name
     42  1.2.8.2  toshii 	lea	%sp@(8 + Lbufsz+Lnamoff),%a0	| new name (8: args on stack)
     43  1.2.8.2  toshii Lname:	moveb	%a0@+,%a1@+
     44  1.2.8.2  toshii 	bnes	Lname
     45  1.2.8.2  toshii 	subql	#1,%a1				| remove nul char
     46  1.2.8.2  toshii 
     47  1.2.8.2  toshii 	| add new extension
     48  1.2.8.2  toshii 	lea	%sp@(8 + Lbufsz+Lextoff),%a0	| new ext (8: args on stack)
     49  1.2.8.2  toshii Lext:	moveb	%a0@+,%a1@+
     50  1.2.8.2  toshii 	bnes	Lext
     51  1.2.8.2  toshii 
     52  1.2.8.2  toshii 	| we already have the arguments on stack
     53  1.2.8.2  toshii 	bsr	_C_LABEL(DOS_MOVE)
     54  1.2.8.2  toshii 
     55  1.2.8.2  toshii 	| version check of Human68k and error handlings are done in DOS_MOVE()
     56  1.2.8.2  toshii 
     57  1.2.8.2  toshii 	unlk	%a6				| restore stack
     58  1.2.8.2  toshii 	rts
     59  1.2.8.2  toshii 
     60  1.2.8.2  toshii Lerr:	unlk	%a6
     61  1.2.8.2  toshii 	bra	CERROR
     62