2016-07-10 14:35:33 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2016-10-19 20:20:43 +02:00
|
|
|
"os"
|
2016-07-10 14:35:33 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-20 00:12:24 +02:00
|
|
|
if len(os.Args) != 2 {
|
|
|
|
fmt.Printf("usage: %s file", os.Args[0])
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
file, err := os.Open(os.Args[1])
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("Cannot open file: %s", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
code, err := Assemble(file)
|
2016-07-10 14:35:33 +02:00
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("Assembly failed: %s", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2016-10-20 00:12:24 +02:00
|
|
|
err = Run(code)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("Runtime error: %s", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2016-07-10 14:35:33 +02:00
|
|
|
}
|