summaryrefslogtreecommitdiff
path: root/tools/builtin.s
blob: 17e262d67ca0cf7124fc04909a43652f134be285 (plain)
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
36
37
38
.global printi
.type printi, @function

.global _start
.type _start, @function

.text
printi:
    addi sp, sp, -4
    sw s0, 0(sp)
    sw ra, 4(sp)
    addi s0, sp, 4

    addi t0, a0, 0
    addi a0, a0, '0'
    sw a0, 0(s0)
    addi a0, x0, 1
    addi a1, s0, 0
    addi a2, x0, 1
    addi a7, x0, 64
    ecall

    addi t1, x0, '\n'
    sw t1, 0(s0)
    ecall

    addi a0, t0, 0

    lw s0, 0(sp)
    lw ra, 4(sp)
    addi sp, sp, 4
    ret

_start:
    call main
    addi a0, zero, 0
    addi a7, zero, 93
    ecall