Skip to content

Commit

Permalink
Added Instruction datatype and i2s (Instruction to string) function.
Browse files Browse the repository at this point in the history
  • Loading branch information
ars13025 committed Jan 30, 2018
1 parent 83bfdb5 commit 4637682
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Homework_1.sml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ fun getA (m : MachineState) = #a m;
fun getB (m : MachineState) = #b m;
fun setA (m : MachineState, newA) = newMachine(newA, #b m);
fun setB (m : MachineState, newB) = newMachine(#a m, newB);

(*Instruction Set*)
datatype Instruction = SetA of int | SetB of int | Add | Sub | Disp;
fun i2s (SetA a) = "SetA " ^ Int.toString(a)
| i2s (SetB b) = "SetB " ^ Int.toString(b)
| i2s Add = "Add"
| i2s Sub = "Sub"
| i2s Disp = "Disp";

0 comments on commit 4637682

Please sign in to comment.