X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/c2b45b3681553192a462bcdd376ee7a9bf83eef3..5c90fbb8681e975ccd0a1bc407b31daa1daef38a:/codegen/blarg.sml diff --git a/codegen/blarg.sml b/codegen/blarg.sml index cf3ea4c..cdd4a1b 100644 --- a/codegen/blarg.sml +++ b/codegen/blarg.sml @@ -19,6 +19,7 @@ sig MOVLIT of oper * word | MOVSYM of oper * Symbol.symbol | MOVLBL of oper * Label.label | + MOVSTR of oper * Stringref.stringref | LDR of oper * oper | STO of oper * oper | MOV of oper * oper | @@ -76,6 +77,7 @@ struct MOVLIT of oper * word | MOVSYM of oper * Symbol.symbol | MOVLBL of oper * Label.label | + MOVSTR of oper * Stringref.stringref | LDR of oper * oper | STO of oper * oper | MOV of oper * oper | @@ -197,13 +199,14 @@ struct val compare = Int.compare end) - fun pp_oper (REG r) = "%" ^ (regname r) + fun pp_oper (REG r) = (regname r) | pp_oper (TEMP t) = (Temp.name t) | pp_oper (STACKARG i) = "arg#"^Int.toString i - fun pp_insn pr (MOVLIT (d, w)) = "\tmov"^pr^" "^(pp_oper d)^", #"^(Word.toString w)^"\n" + fun pp_insn pr (MOVLIT (d, w)) = "\tmov"^pr^" "^(pp_oper d)^", #0x"^(Word.toString w)^"\n" | pp_insn pr (MOVSYM (d, s)) = "\tmov"^pr^" "^(pp_oper d)^", #"^(Symbol.name s)^"\n" | pp_insn pr (MOVLBL (d, l)) = "\tmov"^pr^" "^(pp_oper d)^", #"^(Label.name l)^"\n" + | pp_insn pr (MOVSTR (d, s)) = "\tmov"^pr^" "^(pp_oper d)^", #"^(Stringref.name s)^"\n" | pp_insn pr (LDR (d, s)) = "\tldr"^pr^" "^(pp_oper d)^", ["^(pp_oper s)^"]\n" | pp_insn pr (STO (d, s)) = "\tsto"^pr^" ["^(pp_oper d)^"], "^(pp_oper s)^"\n" | pp_insn pr (MOV (d, s)) = "\tmov"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n" @@ -218,13 +221,13 @@ struct | pp_insn pr (NOTS (d, s)) = "\tnots"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n" | pp_insn pr (PUSH (d, s)) = "\tpush"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n" | pp_insn pr (POP (d, s)) = "\tpop"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n" - | pp_insn pr (CALL (d, s, n)) = "\tcall"^pr^" "^(pp_oper d)^", "^(pp_oper s)^" # ("^(Int.toString n)^" args)\n" + | pp_insn pr (CALL (d, s, n)) = "\tcall"^pr^" "^(pp_oper d)^", "^(pp_oper s)^" @ ("^(Int.toString n)^" args)\n" | pp_insn pr (SHR (d, s)) = "\tshr"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n" | pp_insn pr (SHL (d, s)) = "\tshl"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n" (* pretty prints the asm *) fun print (DIRECTIVE(str)) = str ^ "\n" - | print (COMMENT(str)) = "// " ^ str ^ "\n" + | print (COMMENT(str)) = "@ " ^ str ^ "\n" | print (LABEL(l)) = Label.name l ^ ":\n" | print (INSN (pred, insn)) = pp_insn (predname pred) insn | print (LIVEIGN i) = print i