summaryrefslogtreecommitdiff
path: root/asm/asm.ml
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-08 18:17:03 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-08 18:17:03 +0100
commitfa2e69bf68346d653d194d863c019674ea0fd7e2 (patch)
treeef997981ef7a343e5b30dd479e75521106857cda /asm/asm.ml
parent479a6b1ef7f435e12327a8468b8e33d096b56ce2 (diff)
downloadSystDigit-Projet-fa2e69bf68346d653d194d863c019674ea0fd7e2.tar.gz
SystDigit-Projet-fa2e69bf68346d653d194d863c019674ea0fd7e2.zip
Premier mail emile
Diffstat (limited to 'asm/asm.ml')
-rw-r--r--asm/asm.ml95
1 files changed, 95 insertions, 0 deletions
diff --git a/asm/asm.ml b/asm/asm.ml
new file mode 100644
index 0000000..5a3a96b
--- /dev/null
+++ b/asm/asm.ml
@@ -0,0 +1,95 @@
+type reg = int
+
+type imm =
+ | Imm of int
+ | Lab of string
+ | Labu of string
+
+type fmt_r =
+ | Add
+ | Sub
+ | Mul
+ | Div
+ | Addu
+ | Subu
+ | Mulu
+ | Divu
+ | Or
+ | And
+ | Xor
+ | Nor
+ | Lsl
+ | Lsr
+ | Asr
+ | Se
+ | Sne
+ | Sle
+ | Slt
+ | Sltu
+ | Sleu
+ | Jer
+ | Jner
+ | Jltr
+ | Jler
+ | Jltru
+ | Jleru
+ | Lwr
+ | Swr
+ | Lbr
+ | Sbr
+
+type instr =
+ | R of (fmt_r * reg * reg * reg)
+ | Incri of (reg * int)
+ | Shi of (reg * int)
+ | J of imm
+ | Jal of imm
+ | Jr of reg
+ | Jalr of reg
+ | Lw of (reg * reg * int)
+ | Sw of (reg * reg * int)
+ | Lb of (reg * reg * int)
+ | Sb of (reg * reg * int)
+ | Lil of (reg * imm)
+ | Lilz of (reg * imm)
+ | Liu of (reg * imm)
+ | Liuz of (reg * imm)
+ | Lra of imm
+
+module Imap = Map.Make(String)
+
+type program = { text : instr list; data : (int * bool) list; lbls : int Imap.t }
+
+let keywords_r = [
+ "add",Add;
+ "sub",Sub;
+ "mul",Mul;
+ "div",Div;
+ "addu",Addu;
+ "subu",Subu;
+ "mulu",Mulu;
+ "divu",Divu;
+ "or",Or;
+ "and",And;
+ "xor",Xor;
+ "nor",Nor;
+ "lsl",Lsl;
+ "Asr",Asr;
+ "Lsr",Lsr;
+ "se",Se;
+ "sne",Sne;
+ "sle",Sle;
+ "slt",Slt;
+ "sltu",Sltu;
+ "sleu",Sleu;
+ "jer",Jer;
+ "jner",Jner;
+ "jltr",Jltr;
+ "jler",Jler;
+ "jltru",Jltru;
+ "jleru",Jleru;
+ "lwr",Lwr;
+ "lbr",Lbr;
+ "swr",Swr;
+ "sbr",Sbr
+ ]