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