Add printc and exit builtin functions
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user