apple2-go/cmd/disasm.go

44 lines
1002 B
Go
Raw Permalink Normal View History

2018-05-10 12:32:42 +00:00
package main
2018-05-27 20:57:46 +00:00
// Command line tool to disassemble a range of addresses
2018-05-10 12:32:42 +00:00
import (
"flag"
2018-05-27 20:57:46 +00:00
"fmt"
"os"
2018-05-10 12:32:42 +00:00
2019-11-02 13:33:05 +00:00
"github.com/freewilll/apple2-go/cpu"
"github.com/freewilll/apple2-go/mmu"
"github.com/freewilll/apple2-go/utils"
2018-05-10 12:32:42 +00:00
)
func main() {
2018-05-27 20:57:46 +00:00
var Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n\n", os.Args[0])
fmt.Fprintf(flag.CommandLine.Output(), "Synopsis:\n %s -start ADDRESS [-end ADDRESS]\n\n", os.Args[0])
fmt.Fprintf(flag.CommandLine.Output(), "Example:\n %s -start d000 -end ffff\n\n", os.Args[0])
flag.PrintDefaults()
}
flag.Usage = Usage
2018-05-10 12:32:42 +00:00
startString := flag.String("start", "", "Start address")
endString := flag.String("end", "", "End address")
flag.Parse()
2018-05-19 10:42:14 +00:00
start := utils.DecodeCmdLineAddress(startString)
end := utils.DecodeCmdLineAddress(endString)
2018-05-10 12:32:42 +00:00
2018-05-19 10:42:14 +00:00
if start == nil {
2018-05-10 12:32:42 +00:00
panic("Must include -start")
}
2018-05-19 10:42:14 +00:00
if end == nil {
2018-05-10 12:32:42 +00:00
e := uint16(0xffff)
2018-05-19 10:42:14 +00:00
end = &e
2018-05-10 12:32:42 +00:00
}
cpu.InitInstructionDecoder()
mmu.InitApple2eROM()
2018-05-19 10:42:14 +00:00
utils.Disassemble(*start, *end)
2018-05-10 12:32:42 +00:00
}