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

Subversion Repositories forwardcom

[/] [forwardcom/] [libraries/] [puts_light.as] - Blame information for rev 163

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

Line No. Rev Author Line
1 107 Agner
/*********************************  puts_light.as *****************************
2
* Author:        Agner Fog
3
* date created:  2021-05-16
4
* Last modified: 2021-05-16
5
* Version:       1.11
6
* Project:       ForwardCom library libc_light.li
7
* Description:   puts: print a string to stdout, append linefeed
8
* This version is for CPUs with limited capabilities
9
* C declaration: int puts (const char * str);
10
*
11
* Copyright 2021 GNU General Public License http://www.gnu.org/licenses
12
******************************************************************************/
13
 
14
code section execute align = 4                   // code section
15
 
16
// Print a string to stdout, append \n
17
_puts function public reguse=3,0
18
if (int64 r0 != 0) {  // check for null pointer
19
    while (true) {    // loop through string
20
        int8 r1 = [r0]             // read character
21
        if (int8 r1 == 0) {break}  // end of string
22
        int8 output(r1, r1, 10);   // output character
23
        int64 r0++                 // next character
24
    }
25
    int8 r1 = '\n'                 // write newline
26
    int8 output(r1, r1, 10);
27
    int r0 = 0                     // indicate success
28
    return
29
}
30
int r0 = -1                        // indicate error
31
return
32
_puts end
33
 
34
code end

powered by: WebSVN 2.1.0

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