PrintInstruction prints the current CPU state
()
| 266 | |
| 267 | // PrintInstruction prints the current CPU state |
| 268 | func (cpu *CPU) PrintInstruction() { |
| 269 | opcode := cpu.Read(cpu.PC) |
| 270 | bytes := instructionSizes[opcode] |
| 271 | name := instructionNames[opcode] |
| 272 | w0 := fmt.Sprintf("%02X", cpu.Read(cpu.PC+0)) |
| 273 | w1 := fmt.Sprintf("%02X", cpu.Read(cpu.PC+1)) |
| 274 | w2 := fmt.Sprintf("%02X", cpu.Read(cpu.PC+2)) |
| 275 | if bytes < 2 { |
| 276 | w1 = " " |
| 277 | } |
| 278 | if bytes < 3 { |
| 279 | w2 = " " |
| 280 | } |
| 281 | fmt.Printf( |
| 282 | "%4X %s %s %s %s %28s"+ |
| 283 | "A:%02X X:%02X Y:%02X P:%02X SP:%02X CYC:%3d\n", |
| 284 | cpu.PC, w0, w1, w2, name, "", |
| 285 | cpu.A, cpu.X, cpu.Y, cpu.Flags(), cpu.SP, (cpu.Cycles*3)%341) |
| 286 | } |
| 287 | |
| 288 | // pagesDiffer returns true if the two addresses reference different pages |
| 289 | func pagesDiffer(a, b uint16) bool { |