Skip to content

Commit

Permalink
add :aslt command for writing raw semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinafyi committed Feb 9, 2024
1 parent fc60f76 commit d0da068
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bin/asli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ let help_msg = [
{|:elf <file> Load an ELF file|};
{|:opcode <instr-set> <int> Decode and execute opcode|};
{|:sem <instr-set> <int> Decode and print opcode semantics|};
{|:ast <instr-set> <int> <file> Decode and write opcode semantics to a file, in a structured ast format|};
{|:project <file> Execute ASLi commands in <file>|};
{|:q :quit Exit the interpreter|};
{|:run Execute instructions|};
Expand Down Expand Up @@ -192,6 +193,14 @@ let rec process_command (tcenv: TC.Env.t) (cpu: Cpu.cpu) (fname: string) (input0
let op = Z.of_string opcode in
Printf.printf "Decoding instruction %s %s\n" iset (Z.format "%x" op);
cpu'.sem iset op
| [":ast"; iset; opcode; fname] ->
let op = Value.VBits (Primops.prim_cvt_int_bits (Z.of_int 32) (Z.of_string opcode)) in
let decoder = Eval.Env.getDecoder cpu.env (Ident iset) in
let chan = open_out fname in
List.iter
(fun s -> Printf.fprintf chan "%s\n" (Utils.to_string (PP.pp_raw_stmt s)))
(Dis.dis_decode_entry cpu.env cpu.denv decoder op);
close_out chan
| ":dump" :: iset :: opcode :: rest ->
let fname =
(match rest with
Expand Down

0 comments on commit d0da068

Please sign in to comment.