mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2025-04-02 11:02:17 -04:00
o debugger
- ONHALT now performs the new command sequence straight away - added RAM command - HEX output alongside disassembly
This commit is contained in:
parent
4e9f48630b
commit
63fa147a16
5 changed files with 56 additions and 2 deletions
|
@ -25,6 +25,7 @@ const (
|
|||
KeywordDebuggerState = "DEBUGGERSTATE"
|
||||
KeywordCPU = "CPU"
|
||||
KeywordPeek = "PEEK"
|
||||
KeywordRAM = "RAM"
|
||||
KeywordRIOT = "RIOT"
|
||||
KeywordTIA = "TIA"
|
||||
KeywordTV = "TV"
|
||||
|
@ -64,6 +65,7 @@ var DebuggerCommands = parser.Commands{
|
|||
KeywordDebuggerState: parser.CommandArgs{},
|
||||
KeywordCPU: parser.CommandArgs{},
|
||||
KeywordPeek: parser.CommandArgs{parser.Arg{Typ: parser.ArgValue, Req: true}},
|
||||
KeywordRAM: parser.CommandArgs{},
|
||||
KeywordRIOT: parser.CommandArgs{},
|
||||
KeywordTIA: parser.CommandArgs{},
|
||||
KeywordTV: parser.CommandArgs{},
|
||||
|
@ -104,6 +106,7 @@ var Help = map[string]string{
|
|||
KeywordDebuggerState: "Display summary of debugger options",
|
||||
KeywordCPU: "Display the current state of the CPU",
|
||||
KeywordPeek: "Inspect an individual memory address",
|
||||
KeywordRAM: "Display the current contents of PIA RAM",
|
||||
KeywordRIOT: "Display the current state of the RIOT",
|
||||
KeywordTIA: "Display current state of the TIA",
|
||||
KeywordTV: "Display the current TV state",
|
||||
|
|
|
@ -454,6 +454,9 @@ func (dbg *Debugger) parseCommand(input string) (bool, error) {
|
|||
|
||||
dbg.print(ui.Feedback, "auto-command on halt: %s", dbg.commandOnHalt)
|
||||
|
||||
// run the new onhalt command(s)
|
||||
_, _ = dbg.parseInput(dbg.commandOnHalt)
|
||||
|
||||
case KeywordMemMap:
|
||||
dbg.print(ui.MachineInfo, "%v", dbg.vcs.Mem.MemoryMap())
|
||||
|
||||
|
@ -554,6 +557,9 @@ func (dbg *Debugger) parseCommand(input string) (bool, error) {
|
|||
dbg.print(ui.MachineInfo, s)
|
||||
}
|
||||
|
||||
case KeywordRAM:
|
||||
dbg.printMachineInfo(dbg.vcs.Mem.PIA)
|
||||
|
||||
case KeywordRIOT:
|
||||
dbg.printMachineInfo(dbg.vcs.RIOT)
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ const (
|
|||
// compound styles
|
||||
const (
|
||||
StyleBrief = StyleFlagSymbols
|
||||
StyleFull = StyleFlagSymbols | StyleFlagLocation | StyleFlagColumns | StyleFlagNotes
|
||||
StyleFull = StyleFlagHex | StyleFlagSymbols | StyleFlagLocation | StyleFlagColumns | StyleFlagNotes
|
||||
)
|
||||
|
||||
// Has tests to see if style has the supplied flag in its definition
|
||||
|
|
|
@ -47,6 +47,7 @@ func columnise(s string, width int) string {
|
|||
// function to implicit calls to String()
|
||||
func (result InstructionResult) GetString(symtable *symbols.Table, style symbols.Style) string {
|
||||
// columns
|
||||
var hex string
|
||||
var label, programCounter string
|
||||
var operator, operand string
|
||||
var notes string
|
||||
|
@ -86,6 +87,21 @@ func (result InstructionResult) GetString(symtable *symbols.Table, style symbols
|
|||
}
|
||||
}
|
||||
|
||||
if style.Has(symbols.StyleFlagHex) {
|
||||
switch result.Defn.Bytes {
|
||||
case 3:
|
||||
hex = fmt.Sprintf("%02x", idx&0xff00>>8)
|
||||
fallthrough
|
||||
case 2:
|
||||
hex = fmt.Sprintf("%02x %s", idx&0x00ff, hex)
|
||||
fallthrough
|
||||
case 1:
|
||||
hex = fmt.Sprintf("%02x %s", result.Defn.ObjectCode, hex)
|
||||
default:
|
||||
panic("unsupported number of bytes in instruction")
|
||||
}
|
||||
}
|
||||
|
||||
// ... and use assembler symbol for the operand if available/appropriate
|
||||
if symtable.Valid && style.Has(symbols.StyleFlagSymbols) && result.InstructionData != nil && (operand == "" || operand[0] != '?') {
|
||||
if result.Defn.AddressingMode != definitions.Immediate {
|
||||
|
@ -183,6 +199,7 @@ func (result InstructionResult) GetString(symtable *symbols.Table, style symbols
|
|||
|
||||
// force column widths
|
||||
if style.Has(symbols.StyleFlagColumns) {
|
||||
hex = columnise(hex, 8)
|
||||
programCounter = columnise(programCounter, 6)
|
||||
operator = columnise(operator, 3)
|
||||
if symtable.Valid {
|
||||
|
@ -195,7 +212,8 @@ func (result InstructionResult) GetString(symtable *symbols.Table, style symbols
|
|||
}
|
||||
|
||||
// build final string
|
||||
s := fmt.Sprintf("%s %s %s %s %s",
|
||||
s := fmt.Sprintf("%s %s %s %s %s %s",
|
||||
hex,
|
||||
label,
|
||||
programCounter,
|
||||
operator,
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package memory
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PIA defines the information for and operation allowed for PIA PIA
|
||||
type PIA struct {
|
||||
CPUBus
|
||||
|
@ -55,3 +60,25 @@ func (pia PIA) Peek(address uint16) (uint8, string, error) {
|
|||
oa := address - pia.origin
|
||||
return pia.memory[oa], "", nil
|
||||
}
|
||||
|
||||
// MachineInfoTerse returns the RIOT information in terse format
|
||||
func (pia PIA) MachineInfoTerse() string {
|
||||
return pia.MachineInfo()
|
||||
}
|
||||
|
||||
// MachineInfo returns the RIOT information in verbose format
|
||||
func (pia PIA) MachineInfo() string {
|
||||
s := ""
|
||||
for y := 0; y < 8; y++ {
|
||||
for x := 0; x < 16; x++ {
|
||||
s = fmt.Sprintf("%s %02x", s, pia.memory[uint16((y*16)+x)])
|
||||
}
|
||||
s = fmt.Sprintf("%s\n", s)
|
||||
}
|
||||
return strings.Trim(s, "\n")
|
||||
}
|
||||
|
||||
// map String to MachineInfo
|
||||
func (pia PIA) String() string {
|
||||
return pia.MachineInfo()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue