22 lines
442 B
Go
22 lines
442 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) != 2 {
|
|
fmt.Printf("usage: %s file\n", os.Args[0])
|
|
} else if file, err := os.Open(os.Args[1]); err != nil {
|
|
fmt.Printf("Cannot open file: %s\n", err)
|
|
} else if code, err := Assemble(file); err != nil {
|
|
fmt.Printf("Assembly failed: %s\n", err)
|
|
} else if err = Run(code); err != nil {
|
|
fmt.Printf("Runtime error: %s\n", err)
|
|
} else {
|
|
os.Exit(0)
|
|
}
|
|
os.Exit(1)
|
|
}
|