Add print integer fn

This commit is contained in:
Mylloon 2022-12-10 17:06:08 +01:00
parent 8f94d4673b
commit c8ba7704e4
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 5 additions and 0 deletions

View file

@ -9,6 +9,7 @@ let _types_ =
; "%sub", Func_t (Int_t, [ Int_t; Int_t ])
; "%mul", Func_t (Int_t, [ Int_t; Int_t ])
; "%div", Func_t (Int_t, [ Int_t; Int_t ])
; "puti", Func_t (Int_t, [ Int_t ])
])
;;
@ -20,5 +21,6 @@ let builtins =
; "%sub", [ Lw (T0, Mem (SP, 4)); Lw (T1, Mem (SP, 0)); Sub (V0, T0, T1) ]
; "%mul", [ Lw (T0, Mem (SP, 4)); Lw (T1, Mem (SP, 0)); Mul (V0, T0, T1) ]
; "%div", [ Lw (T0, Mem (SP, 4)); Lw (T1, Mem (SP, 0)); Div (V0, T0, T1) ]
; "puti", [ Lw (A0, Mem (SP, 0)); Li (V0, Syscall.print_int); Syscall ]
]
;;

3
tests/19_print.test Normal file
View file

@ -0,0 +1,3 @@
void main () {
puti(1312);
}