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
|
|
|
|
2018-05-27 10:48:03 +00:00
|
|
|
"github.com/freewilll/apple2/cpu"
|
|
|
|
"github.com/freewilll/apple2/mmu"
|
|
|
|
"github.com/freewilll/apple2/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
|
|
|
}
|