--- hatari/src/debug/evaluate.c 2019/04/09 08:49:26 1.1.1.2 +++ hatari/src/debug/evaluate.c 2019/04/09 08:54:22 1.1.1.4 @@ -1,10 +1,10 @@ /* - Hatari - calculate.c + Hatari - evaluate.c - Copyright (C) 1994, 2009-2010 by Eero Tamminen + Copyright (C) 1994, 2009-2014 by Eero Tamminen - This file is distributed under the GNU Public License, version 2 or at - your option any later version. Read the file gpl.txt for details. + This file is distributed under the GNU General Public License, version 2 + or at your option any later version. Read the file gpl.txt for details. calculate.c - parse numbers, number ranges and expressions. Supports most unary and binary operations. Parenthesis are used for indirect @@ -126,7 +126,7 @@ static long long close_bracket(long long static int getNumber(const char *str, Uint32 *number, int *nbase) { char *end; - const char const *start = str; + const char *start = str; int base = ConfigureParams.Debugger.nNumberBase; unsigned long int value; @@ -158,7 +158,7 @@ static int getNumber(const char *str, Ui } str += 2; } - else if (!isxdigit(str[0])) { + else if (!isxdigit((unsigned char)str[0])) { /* doesn't start with (hex) number -> is it prefix? */ switch (*str++) { @@ -206,8 +206,8 @@ static int getValue(const char *str, Uin Uint32 mask, *addr; int len; - for (end = str; *end == '_' || isalnum(*end); end++); - + for (end = str; *end == '_' || isalnum((unsigned char)*end); end++); + len = end-str; if (len >= (int)sizeof(name)) { fprintf(stderr, "ERROR: symbol name at '%s' too long (%d chars)\n", str, len); @@ -224,13 +224,19 @@ static int getValue(const char *str, Uin } if (bForDsp) { + int regsize = DSP_GetRegisterAddress(name, &addr, &mask); /* DSP register or symbol? */ - if (DSP_GetRegisterAddress(name, &addr, &mask)) { - *number = (*addr & mask); + switch (regsize) { + case 16: + *number = (*((Uint16*)addr) & mask); return len; - } - if (Symbols_GetDspAddress(SYMTYPE_ALL, name, number)) { + case 32: + *number = (*addr & mask); return len; + default: + if (Symbols_GetDspAddress(SYMTYPE_ALL, name, number)) { + return len; + } } } else { /* a special case CPU register? */ @@ -308,7 +314,10 @@ bool Eval_Number(const char *str, Uint32 * addition to numbers. */ offset = getNumber(str, number, &base); - return isNumberOK(str, offset, base); + if (!offset) + return false; + else + return isNumberOK(str, offset, base); } @@ -337,7 +346,7 @@ int Eval_Range(char *str1, Uint32 *lower } offset = getValue(str1, lower, &base, fordsp); - if (!isNumberOK(str1, offset, base)) { + if (offset == 0 || !isNumberOK(str1, offset, base)) { /* first number not OK */ fprintf(stderr,"Invalid address value '%s'!\n", str1); ret = -1; @@ -347,7 +356,7 @@ int Eval_Range(char *str1, Uint32 *lower } if (fDash) { offset = getValue(str2, upper, &base, fordsp); - if (!isNumberOK(str2, offset, base)) { + if (offset == 0 || !isNumberOK(str2, offset, base)) { /* second number not OK */ fprintf(stderr, "Invalid address value '%s'!\n", str2); ret = -1; @@ -683,7 +692,7 @@ static long long apply_op (char opcode, /* ==================================================================== */ /** - * open prenthesis, push values & operators to stack + * open parenthesis, push values & operators to stack */ static void open_bracket (void) { @@ -700,7 +709,7 @@ static void open_bracket (void) /* -------------------------------------------------------------------- */ /** - * close prenthesis, and evaluate / pop stacks + * close parenthesis, and evaluate / pop stacks */ /* last parsed value, last param. flag, trigonometric mode */ static long long close_bracket (long long value) @@ -708,7 +717,7 @@ static long long close_bracket (long lon /* returns the value of the parenthesised expression */ if (id.valid) { /* preceded by an operator */ - if (par.idx > 0) { /* prenthesis has a pair */ + if (par.idx > 0) { /* parenthesis has a pair */ Uint32 addr; /* calculate the value of parenthesised exp. */