added Debugger::setC(bool) and family, for explicitly setting a CPU flag

DebuggerParser flag-setting commands now take one optional argument, to
support the above.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@557 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-06-24 16:36:41 +00:00
parent d7fa47f917
commit 6efeb3238b
3 changed files with 99 additions and 9 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Debugger.cxx,v 1.33 2005-06-24 13:51:55 urchlay Exp $ // $Id: Debugger.cxx,v 1.34 2005-06-24 16:36:41 urchlay Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -467,6 +467,51 @@ void Debugger::toggleN() {
myDebugger->ps( myDebugger->ps() ^ 0x80 ); myDebugger->ps( myDebugger->ps() ^ 0x80 );
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// NV-BDIZC
void Debugger::setC(bool value) {
myDebugger->ps( set_bit(myDebugger->ps(), 0, value) );
// myDebugger->ps( myDebugger->ps() ^ 0x01 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setZ(bool value) {
myDebugger->ps( set_bit(myDebugger->ps(), 1, value) );
// myDebugger->ps( myDebugger->ps() ^ 0x02 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setI(bool value) {
myDebugger->ps( set_bit(myDebugger->ps(), 2, value) );
// myDebugger->ps( myDebugger->ps() ^ 0x04 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setD(bool value) {
myDebugger->ps( set_bit(myDebugger->ps(), 3, value) );
// myDebugger->ps( myDebugger->ps() ^ 0x08 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setB(bool value) {
myDebugger->ps( set_bit(myDebugger->ps(), 4, value) );
// myDebugger->ps( myDebugger->ps() ^ 0x10 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setV(bool value) {
myDebugger->ps( set_bit(myDebugger->ps(), 6, value) );
// myDebugger->ps( myDebugger->ps() ^ 0x40 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setN(bool value) {
myDebugger->ps( set_bit(myDebugger->ps(), 7, value) );
// myDebugger->ps( myDebugger->ps() ^ 0x80 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EquateList *Debugger::equates() { EquateList *Debugger::equates() {
return equateList; return equateList;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Debugger.hxx,v 1.30 2005-06-24 13:51:57 urchlay Exp $ // $Id: Debugger.hxx,v 1.31 2005-06-24 16:36:41 urchlay Exp $
//============================================================================ //============================================================================
#ifndef DEBUGGER_HXX #ifndef DEBUGGER_HXX
@ -51,7 +51,7 @@ enum {
for all debugging operations in Stella (parser, 6502 debugger, etc). for all debugging operations in Stella (parser, 6502 debugger, etc).
@author Stephen Anthony @author Stephen Anthony
@version $Id: Debugger.hxx,v 1.30 2005-06-24 13:51:57 urchlay Exp $ @version $Id: Debugger.hxx,v 1.31 2005-06-24 16:36:41 urchlay Exp $
*/ */
class Debugger : public DialogContainer class Debugger : public DialogContainer
{ {
@ -125,6 +125,14 @@ class Debugger : public DialogContainer
return to_bin(dec, 16, buf); return to_bin(dec, 16, buf);
} }
static unsigned char set_bit(unsigned char input, int bit, bool value) {
if(value)
return input | (1 << bit);
else
return input & (~(1 << bit));
}
int stringToValue(const string& stringval) int stringToValue(const string& stringval)
{ return myParser->decipher_arg(stringval); } { return myParser->decipher_arg(stringval); }
const string valueToString(int value, BaseFormat outputBase = kBASE_DEFAULT); const string valueToString(int value, BaseFormat outputBase = kBASE_DEFAULT);
@ -198,6 +206,13 @@ class Debugger : public DialogContainer
void toggleI(); void toggleI();
void toggleZ(); void toggleZ();
void toggleC(); void toggleC();
void setN(bool value);
void setV(bool value);
void setB(bool value);
void setD(bool value);
void setI(bool value);
void setZ(bool value);
void setC(bool value);
void reset(); void reset();
void autoLoadSymbols(string file); void autoLoadSymbols(string file);
void nextFrame(int frames); void nextFrame(int frames);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: DebuggerParser.cxx,v 1.33 2005-06-24 12:10:31 urchlay Exp $ // $Id: DebuggerParser.cxx,v 1.34 2005-06-24 16:36:41 urchlay Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -448,15 +448,40 @@ string DebuggerParser::run(const string& command) {
else else
return "one argument required"; return "one argument required";
} else if(subStringMatch(verb, "c")) { } else if(subStringMatch(verb, "c")) {
if(argCount == 0)
debugger->toggleC(); debugger->toggleC();
else if(argCount == 1)
debugger->setC(args[0]);
else
return "0 or 1 arguments required";
} else if(subStringMatch(verb, "z")) { } else if(subStringMatch(verb, "z")) {
if(argCount == 0)
debugger->toggleZ(); debugger->toggleZ();
else if(argCount == 1)
debugger->setZ(args[0]);
else
return "0 or 1 arguments required";
} else if(subStringMatch(verb, "n")) { } else if(subStringMatch(verb, "n")) {
if(argCount == 0)
debugger->toggleN(); debugger->toggleN();
else if(argCount == 1)
debugger->setN(args[0]);
else
return "0 or 1 arguments required";
} else if(subStringMatch(verb, "v")) { } else if(subStringMatch(verb, "v")) {
if(argCount == 0)
debugger->toggleV(); debugger->toggleV();
else if(argCount == 1)
debugger->setV(args[0]);
else
return "0 or 1 arguments required";
} else if(subStringMatch(verb, "d")) { } else if(subStringMatch(verb, "d")) {
if(argCount == 0)
debugger->toggleD(); debugger->toggleD();
else if(argCount == 1)
debugger->setD(args[0]);
else
return "0 or 1 arguments required";
} else if(subStringMatch(verb, "pc")) { } else if(subStringMatch(verb, "pc")) {
if(argCount == 1) if(argCount == 1)
debugger->setPC(args[0]); debugger->setPC(args[0]);
@ -652,11 +677,13 @@ string DebuggerParser::run(const string& command) {
"break - Set/clear breakpoint at current PC\n" "break - Set/clear breakpoint at current PC\n"
"break xx - Set/clear breakpoint at address xx\n" "break xx - Set/clear breakpoint at address xx\n"
"c - Toggle Carry Flag\n" "c - Toggle Carry Flag\n"
"c xx - Set Carry Flag to value xx (0 or 1)\n"
"*cartinfo - Show cartridge information\n" "*cartinfo - Show cartridge information\n"
"clearbreaks - Clear all breakpoints\n" "clearbreaks - Clear all breakpoints\n"
"cleartraps - Clear all traps\n" "cleartraps - Clear all traps\n"
"clearwatches - Clear all watches\n" "clearwatches - Clear all watches\n"
"d - Toggle Decimal Flag\n" "d - Toggle Decimal Flag\n"
"d xx - Set Decimal Flag to value xx (0 or 1)\n"
"define ll xx - Define label ll with value xx\n" "define ll xx - Define label ll with value xx\n"
"delwatch xx - Delete watch xx\n" "delwatch xx - Delete watch xx\n"
"disasm - Disassemble (from current PC)\n" "disasm - Disassemble (from current PC)\n"
@ -670,6 +697,7 @@ string DebuggerParser::run(const string& command) {
"listsym - List all currently defined symbols\n" "listsym - List all currently defined symbols\n"
"loadsym f - Load DASM symbols from file f\n" "loadsym f - Load DASM symbols from file f\n"
"n - Toggle Negative Flag\n" "n - Toggle Negative Flag\n"
"n xx - Set Negative Flag to value xx (0 or 1)\n"
"pc xx - Set Program Counter to xx\n" "pc xx - Set Program Counter to xx\n"
"print xx - Evaluate and print expression xx in hex/decimal/binary\n" "print xx - Evaluate and print expression xx in hex/decimal/binary\n"
//"poke xx yy - Write data yy to address xx (may be ROM, TIA, etc)\n" //"poke xx yy - Write data yy to address xx (may be ROM, TIA, etc)\n"
@ -689,10 +717,12 @@ string DebuggerParser::run(const string& command) {
"trapwrite xx - Trap any write access to location xx\n" "trapwrite xx - Trap any write access to location xx\n"
"undef ll - Undefine label ll (if defined)\n" "undef ll - Undefine label ll (if defined)\n"
"v - Toggle Overflow Flag\n" "v - Toggle Overflow Flag\n"
"v xx - Set Overflow Flag to value xx (0 or 1)\n"
"watch xx - Print contents of location xx before every prompt\n" "watch xx - Print contents of location xx before every prompt\n"
"x xx - Set X register to xx\n" "x xx - Set X register to xx\n"
"y xx - Set Y register to xx\n" "y xx - Set Y register to xx\n"
"z - Toggle Zero Flag\n" "z - Toggle Zero Flag\n"
"z xx - Set Zero Flag to value xx (0 or 1)\n"
; ;
} else { } else {
return "unimplemented command (try \"help\")"; return "unimplemented command (try \"help\")";