summaryrefslogtreecommitdiff
path: root/mipshelpers.ml
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2009-01-14 09:39:18 +0100
committerGuillaume Seguin <guillaume@segu.in>2009-01-14 09:39:18 +0100
commiteae584152cd35e0ee489a7f2938878fb294faa9e (patch)
treefd5472f1d24f7e385d0cbdfe1a2a7c325272cce9 /mipshelpers.ml
parent44b8335645e10cc1065eea8c904a3b8bd11da378 (diff)
downloadpetitcaml-eae584152cd35e0ee489a7f2938878fb294faa9e.tar.gz
petitcaml-eae584152cd35e0ee489a7f2938878fb294faa9e.tar.bz2
[petitcaml] Make it actually work
Diffstat (limited to 'mipshelpers.ml')
-rw-r--r--mipshelpers.ml22
1 files changed, 22 insertions, 0 deletions
diff --git a/mipshelpers.ml b/mipshelpers.ml
new file mode 100644
index 0000000..241b6a7
--- /dev/null
+++ b/mipshelpers.ml
@@ -0,0 +1,22 @@
+open Mips
+
+let heap_push n =
+ [Comment (Printf.sprintf "heap_push %d" n) ;
+ Addi (SP, SP, - n)]
+let heap_pop n =
+ [Comment (Printf.sprintf "heap_pop %d" n) ;
+ Addi (SP, SP, n)]
+
+let push reg =
+ [Addi (SP, SP, -4) ;
+ Sw (reg, (0, SP))]
+
+let pop reg =
+ [Lw (reg, (0, SP)) ;
+ Addi (SP, SP, 4)]
+
+let malloc n =
+ [Comment (Printf.sprintf "Malloc %d" n) ;
+ Li (V0, 9) ;
+ Li (A0, n) ;
+ Syscall]