-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstrcpy.as
More file actions
29 lines (25 loc) · 1 KB
/
strcpy.as
File metadata and controls
29 lines (25 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/********************************* strcpy.as ********************************
* Author: Agner Fog
* date created: 2018-03-25
* Last modified: 2018-03-25
* Version: 1.00
* Project: ForwardCom library libc.li
* Description: strcpy function. Copy zero-terminated string
* C declaration: char *strcpy(char *dest, const char *src)
*
* Copyright 2018 GNU General Public License http://www.gnu.org/licenses
*****************************************************************************/
extern _strlen: function, reguse = 0xF, 0x7
extern _memcpy: function, reguse = 0x1F, 1
code section execute align = 4
// r0 = destination
// r1 = source
_strcpy function public reguse = 0x1F, 0x7
push (r0, r1) // save source and destination
int64 r0 = r1
call _strlen // length of source
int64 r2 = r0 + 1 // length including terminating zero
pop (r1, r0)
jump _memcpy // tail call. return dest in r0 unchanged
_strcpy end
code end