diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-10-04 18:26:10 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-10-04 18:26:10 +0200 |
| commit | 35742aa52587400950cf25170c2247f98f498d4d (patch) | |
| tree | 78d0fd208e2e08d30c18ada33c52bc76a91267d6 /tools/builtin.s | |
| parent | fdf56ce9d0de459dc5bd65537847ded7b02ad5c2 (diff) | |
| download | elna-35742aa52587400950cf25170c2247f98f498d4d.tar.gz | |
Add printc and exit builtin functions
Diffstat (limited to 'tools/builtin.s')
| -rw-r--r-- | tools/builtin.s | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/tools/builtin.s b/tools/builtin.s index ecea15b..0f5f82c 100644 --- a/tools/builtin.s +++ b/tools/builtin.s @@ -1,6 +1,12 @@ .global printi .type printi, @function +.global printc +.type printc, @function + +.global exit +.type exit, @function + .global _start .type _start, @function @@ -53,8 +59,35 @@ printi: addi sp, sp, 16 ret -_start: - call main +printc: + addi sp, sp, -12 + sw s0, 0(sp) + sw ra, 4(sp) + addi s0, sp, 12 + + addi t1, zero, '\n' + sb t1, -1(s0) + + lw t0, 0(s0) + sb t0, -2(s0) + + addi a0, zero, 1 + addi a1, s0, -2 + addi a2, zero, 2 + addi a7, zero, 64 + ecall + + lw s0, 0(sp) + lw ra, 4(sp) + addi sp, sp, 12 + ret + +exit: addi a0, zero, 0 addi a7, zero, 93 ecall + # ret + +_start: + call main + call exit |
