mirror of
https://github.com/zellyn/goapple2.git
synced 2024-12-09 11:49:16 +00:00
working on disasm
This commit is contained in:
parent
b78face2fe
commit
d42a92879b
20
a2/disasm.go
20
a2/disasm.go
@ -19,9 +19,13 @@ Disasm is a very simple disassembler for 6502 binary files.
|
||||
}
|
||||
|
||||
var disasmAddress uint // disasm -a flag
|
||||
var symbolFile string // disasm -s flag
|
||||
var printLabels bool // disasm -p flag
|
||||
|
||||
func init() {
|
||||
cmdDisasm.Flag.UintVar(&disasmAddress, "a", 0, "The starting memory address.")
|
||||
cmdDisasm.Flag.StringVar(&symbolFile, "s", "", "File of symbol definitions.")
|
||||
cmdDisasm.Flag.BoolVar(&printLabels, "p", false, "Print labels for symbols.")
|
||||
}
|
||||
|
||||
func runDisasm(cmd *commander.Command, args []string) error {
|
||||
@ -32,7 +36,7 @@ func runDisasm(cmd *commander.Command, args []string) error {
|
||||
|
||||
bytes, err := ioutil.ReadFile(args[0])
|
||||
if err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
if len(bytes) > 0x10000 {
|
||||
return fmt.Errorf("File %s is %04X bytes long, which is more than $10000.", args[0], len(bytes))
|
||||
@ -42,6 +46,18 @@ func runDisasm(cmd *commander.Command, args []string) error {
|
||||
disasmAddress, len(bytes), int(disasmAddress)+len(bytes))
|
||||
}
|
||||
|
||||
asm.DisasmBlock(bytes, uint16(disasmAddress), os.Stdout)
|
||||
var s asm.Symbols
|
||||
if symbolFile != "" {
|
||||
s, err = asm.ReadSymbols(symbolFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if printLabels {
|
||||
return fmt.Errorf("-p (print labels) specified without -s (symbol table file")
|
||||
}
|
||||
}
|
||||
|
||||
asm.DisasmBlock(bytes, uint16(disasmAddress), os.Stdout, s, 2, printLabels)
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user