* Debugger: added 'T' condition (checks the bank of the data accessed)

This commit is contained in:
ansstuff 2013-05-26 19:40:41 +00:00
parent 32fdd7f4c8
commit 120a5b7e1f
3 changed files with 40 additions and 11 deletions

View File

@ -37,10 +37,11 @@
* Register -> 'A' | 'X' | 'Y' | 'P' * Register -> 'A' | 'X' | 'Y' | 'P'
* Flag -> 'N' | 'C' | 'Z' | 'I' | 'B' | 'V' * Flag -> 'N' | 'C' | 'Z' | 'I' | 'B' | 'V'
* PC Bank -> 'K' * PC Bank -> 'K'
* Data Bank -> 'T'
*/ */
#include "conddebug.h"
#include "types.h" #include "types.h"
#include "conddebug.h"
#include "utils/memory.h" #include "utils/memory.h"
#include <cstdio> #include <cstdio>
@ -49,6 +50,8 @@
#include <cassert> #include <cassert>
#include <cctype> #include <cctype>
// hack: this address is used by 'T' condition
uint16 addressOfTheLastAccessedData = 0;
// Next non-whitespace character in string // Next non-whitespace character in string
char next; char next;
@ -137,12 +140,18 @@ int isRegister(char c)
return c == 'A' || c == 'X' || c == 'Y' || c == 'P'; return c == 'A' || c == 'X' || c == 'Y' || c == 'P';
} }
// Determines if a character is for bank // Determines if a character is for PC bank
int isBank(char c) int isPCBank(char c)
{ {
return c == 'K'; return c == 'K';
} }
// Determines if a character is for Data bank
int isDataBank(char c)
{
return c == 'T';
}
// Reads a hexadecimal number from str // Reads a hexadecimal number from str
int getNumber(unsigned int* number, const char** str) int getNumber(unsigned int* number, const char** str)
{ {
@ -229,16 +238,33 @@ Condition* Primitive(const char** str, Condition* c)
return c; return c;
} }
else if (isBank(next)) /* PC Bank */ else if (isPCBank(next)) /* PC Bank */
{ {
if (c->type1 == TYPE_NO) if (c->type1 == TYPE_NO)
{ {
c->type1 = TYPE_BANK; c->type1 = TYPE_PC_BANK;
c->value1 = next; c->value1 = next;
} }
else else
{ {
c->type2 = TYPE_BANK; c->type2 = TYPE_PC_BANK;
c->value2 = next;
}
scan(str);
return c;
}
else if (isDataBank(next)) /* Data Bank */
{
if (c->type1 == TYPE_NO)
{
c->type1 = TYPE_DATA_BANK;
c->value1 = next;
}
else
{
c->type2 = TYPE_DATA_BANK;
c->value2 = next; c->value2 = next;
} }

View File

@ -26,7 +26,8 @@
#define TYPE_FLAG 2 #define TYPE_FLAG 2
#define TYPE_NUM 3 #define TYPE_NUM 3
#define TYPE_ADDR 4 #define TYPE_ADDR 4
#define TYPE_BANK 5 #define TYPE_PC_BANK 5
#define TYPE_DATA_BANK 6
#define OP_NO 0 #define OP_NO 0
#define OP_EQ 1 #define OP_EQ 1
@ -42,6 +43,7 @@
#define OP_OR 11 #define OP_OR 11
#define OP_AND 12 #define OP_AND 12
extern uint16 addressOfTheLastAccessedData;
//mbg merge 7/18/06 turned into sane c++ //mbg merge 7/18/06 turned into sane c++
struct Condition struct Condition
{ {

View File

@ -313,7 +313,8 @@ int evaluate(Condition* c)
switch(c->type1) switch(c->type1)
{ {
case TYPE_ADDR: value1 = GetMem(value1); break; case TYPE_ADDR: value1 = GetMem(value1); break;
case TYPE_BANK: value1 = getBank(_PC); break; case TYPE_PC_BANK: value1 = getBank(_PC); break;
case TYPE_DATA_BANK: value1 = getBank(addressOfTheLastAccessedData); break;
} }
f = value1; f = value1;
@ -337,7 +338,8 @@ int evaluate(Condition* c)
switch(c->type2) switch(c->type2)
{ {
case TYPE_ADDR: value2 = GetMem(value2); break; case TYPE_ADDR: value2 = GetMem(value2); break;
case TYPE_BANK: value2 = getBank(_PC); break; case TYPE_PC_BANK: value2 = getBank(_PC); break;
case TYPE_DATA_BANK: value2 = getBank(addressOfTheLastAccessedData); break;
} }
switch (c->op) switch (c->op)
@ -732,8 +734,6 @@ static void breakpoint(uint8 *opcode, uint16 A, int size) {
} }
//bbit edited: this is the end of the inserted code //bbit edited: this is the end of the inserted code
int debug_tracing;
void DebugCycle() void DebugCycle()
{ {
uint8 opcode[3] = {0}; uint8 opcode[3] = {0};
@ -783,6 +783,7 @@ void DebugCycle()
case 7: A = (opcode[1] | (opcode[2] << 8)) + _X; break; case 7: A = (opcode[1] | (opcode[2] << 8)) + _X; break;
case 8: A = opcode[1] + _Y; break; case 8: A = opcode[1] + _Y; break;
} }
addressOfTheLastAccessedData = A;
if (numWPs || dbgstate.step || dbgstate.runline || dbgstate.stepout || watchpoint[64].flags || dbgstate.badopbreak || break_on_cycles || break_on_instructions || break_asap) if (numWPs || dbgstate.step || dbgstate.runline || dbgstate.stepout || watchpoint[64].flags || dbgstate.badopbreak || break_on_cycles || break_on_instructions || break_asap)
breakpoint(opcode, A, size); breakpoint(opcode, A, size);