-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstrcat.as
More file actions
35 lines (31 loc) · 1.18 KB
/
strcat.as
File metadata and controls
35 lines (31 loc) · 1.18 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
30
31
32
33
34
35
/********************************* strcat.as ********************************
* Author: Agner Fog
* date created: 2018-03-25
* Last modified: 2018-03-25
* Version: 1.00
* Project: ForwardCom library libc.li
* Description: strcat function. Copy zero-terminated string src to the end of string dest
* C declaration: char *strcat(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
_strcat function public reguse = 0xBF, 0x7
int64 r5 = r0 // save destination
int64 r4 = r1 // save source
call _strlen // length of destination
int64 r7 = r5 + r0 // end of destination
int64 r0 = r4
call _strlen // length of source
int64 r2 = r0 + 1 // add 1 for terminating zero
int64 r0 = r7
int64 r1 = r4
call _memcpy
int64 r0 = r5 // return destination
return
_strcat end
code end