MCPcopy
hub / github.com/fogleman/nes / PrintInstruction

Method PrintInstruction

nes/cpu.go:268–286  ·  view source on GitHub ↗

PrintInstruction prints the current CPU state

()

Source from the content-addressed store, hash-verified

266
267// PrintInstruction prints the current CPU state
268func (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
289func pagesDiffer(a, b uint16) bool {

Callers

nothing calls this directly

Calls 2

FlagsMethod · 0.95
ReadMethod · 0.65

Tested by

no test coverage detected