-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (31 loc) · 820 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"os"
"github.com/jolatechno/go-lc3/src/lc3"
"github.com/jolatechno/go-lc3/src/cpu"
"github.com/jolatechno/go-lc3/src/interfaces"
)
func main() {
args := os.Args[1:]
if len(args) < 2 { /* check if there are enough arguments */
panic("Missing arguments")
}
var used_cpu interfaces.Cpu /* cpu var */
switch cpu_name := args[0]; cpu_name { /* see the used cpu */
case "lc3":
used_cpu = lc3.New()
default:
panic("cpu not understood")
}
imgs := args[1:]
for _, img := range imgs { /* for each iamge */
_, err := cpu.LoadFile(used_cpu, img) /* Load the image file loadFile */
if err != nil { /* throwing an error */
panic(err)
}
}
err := cpu.Run(used_cpu) /* run the vm */
if err != nil { /* throwing an error */
panic(err)
}
}