From 370964e23cf2457e3cd52bfcfef4a5963a66bcd3 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 10 Dec 2023 18:46:27 +0200 Subject: [PATCH] Debugger and calculator updates --- calc.cpp | 100 ++++++++++++++++++++++++++++++++++++++++++++++-------- debug.cpp | 17 ++++++---- 2 files changed, 96 insertions(+), 21 deletions(-) diff --git a/calc.cpp b/calc.cpp index d1812203..c5a929e2 100644 --- a/calc.cpp +++ b/calc.cpp @@ -32,6 +32,12 @@ #define MAX_VALUES 32 #define IOBUFFERS 256 +uae_u32 get_byte_debug(uaecptr addr); +uae_u32 get_word_debug(uaecptr addr); +uae_u32 get_long_debug(uaecptr addr); +int getregidx(TCHAR **c); +uae_u32 returnregx(int regid); + static double parsedvaluesd[MAX_VALUES]; static TCHAR *parsedvaluess[MAX_VALUES]; @@ -44,6 +50,7 @@ static TCHAR *parsedvaluess[MAX_VALUES]; static int op_preced(const TCHAR c) { switch(c) { + case 0xf0: case 0xf1: case 0xf2: case '!': return 4; case '*': case '/': case '\\': case '%': @@ -67,6 +74,7 @@ static bool op_left_assoc(const TCHAR c) // left to right case '*': case '/': case '%': case '+': case '-': case '|': case '&': case '^': + case 0xf0: case 0xf1: case 0xf2: return true; // right to left case '=': case '!': case '@': case '@' | 0x80: case '>': case '<': case '>' | 0x80: case '<' | 0x80: @@ -85,6 +93,7 @@ static unsigned int op_arg_count(const TCHAR c) return 2; case '!': case ':': + case 0xf0: case 0xf1: case 0xf2: return 1; default: return c - 'A'; @@ -94,7 +103,7 @@ static unsigned int op_arg_count(const TCHAR c) #define is_operator(c) (c == '+' || c == '-' || c == '/' || c == '*' || c == '!' || c == '%' || c == '=' || \ c == '|' || c == '&' || c == '^' || c == '@' || c == ('@' | 0x80) || c == '>' || c == '<' || c == ('>' | 0x80) || c == ('<' | 0x80) || \ - c == '?' || c == ':') + c == '?' || c == ':' || c == 0xf0 || c == 0xf1 || c == 0xf2) #define is_function(c) (c >= 'A' && c <= 'Z') #define is_ident(c) ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) @@ -389,6 +398,16 @@ static bool docalcx(TCHAR op, double v1, double v2, double *valp) case ':': v = v1; break; + case 0xf0: + v = get_byte_debug((uaecptr)v1); + break; + case 0xf1: + v = get_word_debug((uaecptr)v1); + break; + case 0xf2: + v = get_long_debug((uaecptr)v1); + break; + default: return false; } @@ -617,7 +636,16 @@ static bool parse_values(const TCHAR *ins, TCHAR *out) in[2] = ' '; in[3] = ' '; in[4] = ' '; - } else if (in[0] == '>' && in[1] == '>') { + } else if (!_tcsncmp(in, _T("rl("), 3)) { + in[0] = 0xf2; + in[1] = ' '; + } else if (!_tcsncmp(in, _T("rw("), 3)) { + in[0] = 0xf1; + in[1] = ' '; + } else if (!_tcsncmp(in, _T("rb("), 3)) { + in[0] = 0xf0; + in[1] = ' '; + } else if (in[0] == '>' && in[1] == '>') { in[0] = '>' | 0x80; in[1] = ' '; } else if (in[0] == '<' && in[1] == '<') { @@ -651,20 +679,64 @@ static bool parse_values(const TCHAR *ins, TCHAR *out) *in = '@' | 0x80; *(in + 1) = ' '; } - if (_istdigit (*in)) { + if (_totupper (*in) == 'R') { + if (ident >= MAX_VALUES) + return false; + TCHAR *tmpp = in + 1; + int idx = getregidx(&tmpp); + if (idx >= 0) { + *p++ = ident + 'a'; + uae_u32 val = returnregx(idx); + parsedvaluesd[ident++] = val; + in = tmpp; + } else { + in++; + } + op = 0; + } else if (_istxdigit(*in) || *in == '$') { if (ident >= MAX_VALUES) return false; - if (op > 1 && (in[-1] == '-' || in[-1] == '+')) { - instart--; - p--; - } - *p++ = ident + 'a'; - while (_istdigit (*in) || *in == '.') - in++; - tmp = *in; - *in = 0; - parsedvaluesd[ident++] = _tstof (instart); - *in = tmp; + if (op > 1 && (in[-1] == '-' || in[-1] == '+')) { + instart--; + p--; + } + *p++ = ident + 'a'; + bool hex = false; + if (*in == '$') { + in++; + hex = true; + } + if (!hex) { + TCHAR *tmpp = in; + while (_istxdigit(*tmpp)) { + tmp = _totupper(*tmpp); + if (tmp >= 'A' && tmp <= 'F') { + hex = true; + } + tmpp++; + } + } + if (hex) { + uae_u32 val = 0; + while (_istxdigit(*in)) { + val *= 16; + TCHAR c = _totupper(*in); + if (_istdigit(c)) { + val += c - '0'; + } else { + val += c - 'A' + 10; + } + in++; + } + parsedvaluesd[ident++] = val; + } else { + while (_istdigit(*in) || *in == '.') + in++; + tmp = *in; + *in = 0; + parsedvaluesd[ident++] = _tstof(instart); + *in = tmp; + } op = 0; } else { if (is_operator(*in)) diff --git a/debug.cpp b/debug.cpp index ddd379c6..39d1a6b3 100644 --- a/debug.cpp +++ b/debug.cpp @@ -504,8 +504,11 @@ static bool iscancel (int counter) static bool isoperator(TCHAR **cp) { - TCHAR c = **cp; - return c == '+' || c == '-' || c == '/' || c == '*' || c == '(' || c == ')' || c == '|' || c == '&' || c == '^' || c == '=' || c == '>' || c == '<'; + TCHAR c = _totupper(**cp); + TCHAR c1 = _totupper((*cp)[1]); + return c == '+' || c == '-' || c == '/' || c == '*' || c == '(' || c == ')' || + c == '|' || c == '&' || c == '^' || c == '=' || c == '>' || c == '<' || + (c == 'R' && (c1 == 'L' || c1 == 'W' || c1 == 'B')); } static void ignore_ws (TCHAR **c) @@ -652,7 +655,7 @@ static const TCHAR *debugregs[] = { NULL }; -static int getregidx(TCHAR **c) +int getregidx(TCHAR **c) { int i; TCHAR *p = *c; @@ -676,7 +679,7 @@ static int getregidx(TCHAR **c) return -1; } -static uae_u32 returnregx(int regid) +uae_u32 returnregx(int regid) { if (regid < BREAKPOINT_REG_PC) return regs.regs[regid]; @@ -851,11 +854,11 @@ static int checkvaltype2 (TCHAR **c, uae_u32 *val, TCHAR def) } if (nc == '$') { (*c)++; - return readhexx (c, val) ? 1 : 0; + return readhexx (c, val) ? 1 : 0; } if (nc == '0' && _totupper ((*c)[1]) == 'X') { (*c)+= 2; - return readhexx (c, val) ? 1 : 0; + return readhexx (c, val) ? 1 : 0; } if (nc == '%') { (*c)++; @@ -6976,7 +6979,7 @@ static bool debug_line (TCHAR *input) case 'v': case 'V': { - int v1 = vpos, v2 = 0, v3 = 0; + static int v1 = 0, v2 = 0, v3 = 0; if (*inptr == 'h') { inptr++; if (more_params(&inptr) && *inptr == '?') { -- 2.47.3