* add neg

* change fmt_instr
This commit is contained in:
Mylloon 2022-12-08 19:54:17 +01:00
parent 9480a8aba2
commit af7799ea2c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -44,6 +44,7 @@ type instr =
| Sb of reg * loc
| Lb of reg * loc
| Move of reg * reg
| Neg of reg * reg
| Addi of reg * reg * int
| Add of reg * reg * reg
| Mul of reg * reg * reg
@ -112,6 +113,11 @@ let fmt_loc = function
;;
let fmt_instr = function
| Label _ -> ""
| _ as i ->
Printf.sprintf " "
^
(match i with
| Label l -> Printf.sprintf "%s:" l
| Li (r, i) -> Printf.sprintf "li %s, %d" (fmt_reg r) i
| La (r, a) -> Printf.sprintf "la %s, %s" (fmt_reg r) (fmt_loc a)
@ -120,6 +126,7 @@ let fmt_instr = function
| Sb (r, a) -> Printf.sprintf "sb %s, %s" (fmt_reg r) (fmt_loc a)
| Lb (r, a) -> Printf.sprintf "lb %s, %s" (fmt_reg r) (fmt_loc a)
| Move (rd, rs) -> Printf.sprintf "move %s, %s" (fmt_reg rd) (fmt_reg rs)
| Neg (r, a) -> Printf.sprintf "neg %s, %s" (fmt_reg r) (fmt_reg a)
| Addi (rd, rs, i) -> Printf.sprintf "addi %s, %s, %d" (fmt_reg rd) (fmt_reg rs) i
| Add (rd, rs, rt) ->
Printf.sprintf "add %s, %s, %s" (fmt_reg rd) (fmt_reg rs) (fmt_reg rt)
@ -129,7 +136,7 @@ let fmt_instr = function
| B l -> Printf.sprintf "b %s" l
| Beqz (r, l) -> Printf.sprintf "beqz %s, %s" (fmt_reg r) l
| Jal l -> Printf.sprintf "jal %s" l
| Jr r -> Printf.sprintf " jr %s" (fmt_reg r)
| Jr r -> Printf.sprintf "jr %s" (fmt_reg r))
;;
let fmt_dir = function