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