Files
Halcyon/cmd/asm/main.go
T
2026-09-19 20:21:47 +02:00

29 lines
518 B
Go

// 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)
}