|
|
@ -34,17 +34,22 @@ var disasmCommand = cli.Command{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func disasmCmd(ctx *cli.Context) error { |
|
|
|
func disasmCmd(ctx *cli.Context) error { |
|
|
|
if len(ctx.Args().First()) == 0 { |
|
|
|
var in string |
|
|
|
return errors.New("filename required") |
|
|
|
switch { |
|
|
|
|
|
|
|
case len(ctx.Args().First()) > 0: |
|
|
|
|
|
|
|
fn := ctx.Args().First() |
|
|
|
|
|
|
|
input, err := ioutil.ReadFile(fn) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
in = string(input) |
|
|
|
|
|
|
|
case ctx.GlobalIsSet(InputFlag.Name): |
|
|
|
|
|
|
|
in = ctx.GlobalString(InputFlag.Name) |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return errors.New("Missing filename or --input value") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn := ctx.Args().First() |
|
|
|
code := strings.TrimSpace(in) |
|
|
|
in, err := ioutil.ReadFile(fn) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
code := strings.TrimSpace(string(in)) |
|
|
|
|
|
|
|
fmt.Printf("%v\n", code) |
|
|
|
fmt.Printf("%v\n", code) |
|
|
|
return asm.PrintDisassembled(code) |
|
|
|
return asm.PrintDisassembled(code) |
|
|
|
} |
|
|
|
} |
|
|
|