OpenCores
URL https://opencores.org/ocsvn/forwardcom/forwardcom/trunk

Subversion Repositories forwardcom

[/] [forwardcom/] [libraries/] [strcpy.as] - Blame information for rev 162

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.