Skip to content

Commit

Permalink
cmd/geas: add flags --no-push0 and --no-nl
Browse files Browse the repository at this point in the history
  • Loading branch information
fjl committed Sep 29, 2023
1 parent 26bf7c1 commit b7b7bc2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/geas/geas.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
func main() {
var (
binaryOutput = flag.Bool("bin", false, "binary output")
noNL = flag.Bool("no-nl", false, "remove newline at end of output")
noPush0 = flag.Bool("no-push0", false, "disable use of PUSH0 instruction")
)
flag.Parse()

Expand All @@ -37,6 +39,7 @@ func main() {
file := flag.Arg(0)

c := asm.NewCompiler(os.DirFS("."))
c.SetUsePush0(!*noPush0)
bin := c.CompileFile(file)
if len(c.Errors()) > 0 {
for _, err := range c.Errors() {
Expand All @@ -47,10 +50,12 @@ func main() {

if *binaryOutput {
os.Stdout.Write(bin)
return
} else {
os.Stdout.WriteString(hex.EncodeToString(bin))
if !*noNL {
os.Stdout.WriteString("\n")
}
}
os.Stdout.WriteString(hex.EncodeToString(bin))
os.Stdout.WriteString("\n")
}

func exit(err error) {
Expand Down

0 comments on commit b7b7bc2

Please sign in to comment.