init
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Command asm assembles ship-program source into the binary that the
|
||||
// program endpoint accepts: asm prog.s > prog.bin
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"wh/vm"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Fprintln(os.Stderr, "usage: asm <source.s> > program.bin")
|
||||
os.Exit(2)
|
||||
}
|
||||
src, err := os.ReadFile(os.Args[1])
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
prog, err := vm.Assemble(string(src))
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Stdout.Write(prog)
|
||||
}
|
||||
Reference in New Issue
Block a user