Improve trace

This commit is contained in:
Ivan Izaguirre 2020-04-04 20:13:53 +02:00
parent 38a187ee5b
commit b9dbcc43a8
2 changed files with 5 additions and 4 deletions

View File

@ -117,7 +117,7 @@ func lineString(line []uint8, opcode opcode) string {
case modeAccumulator:
t += fmt.Sprintf(" A")
case modeImmediate:
t += fmt.Sprintf(" #%02x", line[1])
t += fmt.Sprintf(" #$%02x", line[1])
case modeZeroPage:
t += fmt.Sprintf(" $%02x", line[1])
case modeZeroPageX:
@ -144,7 +144,7 @@ func lineString(line []uint8, opcode opcode) string {
case modeAbsoluteIndexedIndirectX:
t += fmt.Sprintf(" ($%04x,X)", getWordInLine(line))
case modeZeroPageAndRelative:
t += fmt.Sprintf(" $%02x *%+x", line[1], int8(line[2]))
t += fmt.Sprintf(" $%02x %+x", line[1], int8(line[2]))
default:
t += "UNKNOWN MODE"
}

View File

@ -87,6 +87,7 @@ func (r *registers) updateFlagZN(t uint8) {
}
func (r registers) String() string {
return fmt.Sprintf("A: %#02x, X: %#02x, Y: %#02x, SP: %#02x, PC: %#04x, P: %#02x, (NV-BDIZC): %08b",
r.getA(), r.getX(), r.getY(), r.getSP(), r.getPC(), r.getP(), r.getP())
ch := (r.getA() & 0x3F) + 0x40
return fmt.Sprintf("A: %#02x(%v), X: %#02x, Y: %#02x, SP: %#02x, PC: %#04x, P: %#02x, (NV-BDIZC): %08b",
r.getA(), string(ch), r.getX(), r.getY(), r.getSP(), r.getPC(), r.getP(), r.getP())
}