From c8ba7704e4c4d9a086557c68b75c84d6b7b04022 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 10 Dec 2022 17:06:08 +0100 Subject: [PATCH] Add print integer fn --- baselib.ml | 2 ++ tests/19_print.test | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 tests/19_print.test diff --git a/baselib.ml b/baselib.ml index 63a650e..f4e9958 100644 --- a/baselib.ml +++ b/baselib.ml @@ -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 ] ] ;; diff --git a/tests/19_print.test b/tests/19_print.test new file mode 100644 index 0000000..ea1e6d7 --- /dev/null +++ b/tests/19_print.test @@ -0,0 +1,3 @@ +void main () { + puti(1312); +}