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")
flag.Parse()
startAddress := utils.DecodeCmdLineAddress(startString)
endAddress := utils.DecodeCmdLineAddress(endString)
start := utils.DecodeCmdLineAddress(startString)
end := utils.DecodeCmdLineAddress(endString)
if startAddress == nil {
if start == nil {
panic("Must include -start")
}
if endAddress == nil {
if end == nil {
e := uint16(0xffff)
endAddress = &e
end = &e
}
cpu.InitInstructionDecoder()
mmu.InitApple2eROM()
cpu.State.PC = *startAddress
for cpu.State.PC <= *endAddress {
cpu.PrintInstruction(false)
cpu.AdvanceInstruction()
}
utils.Disassemble(*start, *end)
}

View File

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