Added Disassemble utils

This commit is contained in:
Will Angenent 2018-05-19 11:42:14 +01:00
parent c2163c8197
commit a43fd7c08c
3 changed files with 19 additions and 12 deletions

View File

@ -13,24 +13,19 @@ func main() {
endString := flag.String("end", "", "End address") endString := flag.String("end", "", "End address")
flag.Parse() flag.Parse()
startAddress := utils.DecodeCmdLineAddress(startString) start := utils.DecodeCmdLineAddress(startString)
endAddress := utils.DecodeCmdLineAddress(endString) end := utils.DecodeCmdLineAddress(endString)
if startAddress == nil { if start == nil {
panic("Must include -start") panic("Must include -start")
} }
if endAddress == nil { if end == nil {
e := uint16(0xffff) e := uint16(0xffff)
endAddress = &e end = &e
} }
cpu.InitInstructionDecoder() cpu.InitInstructionDecoder()
mmu.InitApple2eROM() mmu.InitApple2eROM()
utils.Disassemble(*start, *end)
cpu.State.PC = *startAddress
for cpu.State.PC <= *endAddress {
cpu.PrintInstruction(false)
cpu.AdvanceInstruction()
}
} }

View File

@ -851,7 +851,7 @@ func Run(showInstructions bool, breakAddress *uint16, exitAtBreak bool, disableF
postProcessIncDec(addressMode) postProcessIncDec(addressMode)
default: default:
fmt.Printf("Unknown opcode $%02x\n", opcode) fmt.Printf("Unknown opcode $%02x at %04x\n", opcode, State.PC)
return return
} }
} }

View File

@ -60,3 +60,15 @@ func RunUntilBreakPoint(t *testing.T, breakAddress uint16, seconds int, showInst
t.Fatalf("Did not reach breakpoint at %04x. Got to %04x", breakAddress, cpu.State.PC) t.Fatalf("Did not reach breakpoint at %04x. Got to %04x", breakAddress, cpu.State.PC)
} }
} }
func Disassemble(start uint16, end uint16) {
oldPC := cpu.State.PC
cpu.State.PC = start
for cpu.State.PC <= end {
cpu.PrintInstruction(false)
cpu.AdvanceInstruction()
}
cpu.State.PC = oldPC
}