o debugger

- implemented DISASSEMBLE command
This commit is contained in:
steve 2018-07-07 08:44:20 +01:00
parent 76b5d9503a
commit 404430fe08
3 changed files with 10 additions and 1 deletions

View file

@ -37,6 +37,7 @@ const (
KeywordPlayfield = "PLAYFIELD"
KeywordDisplay = "DISPLAY"
KeywordScript = "SCRIPT"
KeywordDisassemble = "DISASSEMBLE"
SubKeywordBreaks = "BREAKS"
SubKeywordTraps = "TRAPS"
@ -79,6 +80,7 @@ var DebuggerCommands = parser.Commands{
KeywordPlayfield: parser.CommandArgs{},
KeywordDisplay: parser.CommandArgs{},
KeywordScript: parser.CommandArgs{parser.Arg{Typ: parser.ArgFile, Req: true}},
KeywordDisassemble: parser.CommandArgs{},
}
func init() {
@ -121,4 +123,6 @@ var Help = map[string]string{
KeywordBall: "Display the current state of the Ball sprite",
KeywordPlayfield: "Display the current playfield data",
KeywordDisplay: "Display the TV image",
KeywordScript: "Run commands from specified file"}
KeywordScript: "Run commands from specified file",
KeywordDisassemble: "Print the full cartridge disassembly",
}

View file

@ -416,6 +416,9 @@ func (dbg *Debugger) parseCommand(input string) (bool, error) {
return false, err
}
case KeywordDisassemble:
dbg.print(ui.CPUStep, dbg.disasm.Dump())
case KeywordSymbol:
address, err := dbg.disasm.Symtable.SearchLocation(parts[1])
if err != nil {

View file

@ -109,6 +109,8 @@ func NewDisassembly(cartridgeFilename string) (*Disassembly, error) {
// Dump returns the entire disassembly as a string
func (dsm *Disassembly) Dump() (s string) {
// TODO: buffered output - it can take too long to build the string if the
// disassembly is too long
for _, pc := range dsm.SequencePoints {
s = fmt.Sprintf("%s\n%s", s, dsm.Program[pc].GetString(dsm.Symtable, result.StyleFull))
}