Пример #1
0
// BeforeExecute receives each cpu.Instruction just before the program
// counter is incremented and the instruction executed.
func (d *Debugger) BeforeExecute(in cpu.Instruction) {

	d.doBreakpoints(in)

	if d.run {
		return
	}

	fmt.Println(d.cpu)

	var symbols []string
	if in.IsAbsolute() {
		symbols = d.symbols.labelsFor(in.Op16)
	}

	if len(symbols) > 0 {
		fmt.Printf("Next: %v (%s)\n", in, strings.Join(symbols, ","))
	} else {
		fmt.Println("Next:", in)
	}

	for !d.commandLoop(in) {
		// next
	}
}
Пример #2
0
func (d *Debugger) doBreakpoints(in cpu.Instruction) {
	inName := in.Name()

	if inName == d.breakInstruction {
		fmt.Printf("Breakpoint for instruction %s\n", inName)
		d.run = false
	}

	if d.breakAddress && d.cpu.PC == d.breakAddressValue {
		fmt.Printf("Breakpoint for PC address = $%04X\n", d.breakAddressValue)
		d.run = false
	}

	d.checkRegBreakpoint("A", d.breakRegA, d.breakRegAValue, d.cpu.AC)
	d.checkRegBreakpoint("X", d.breakRegX, d.breakRegXValue, d.cpu.X)
	d.checkRegBreakpoint("Y", d.breakRegY, d.breakRegYValue, d.cpu.Y)
}