Allow register names in address expressions.
This commit is contained in:
parent
a643a2e833
commit
e4644f70aa
19
mspdebug.man
19
mspdebug.man
|
@ -732,10 +732,19 @@ Any command which accepts a memory address, length or register value
|
|||
as an argument may be given an address expression. An address
|
||||
expression consists of an algebraic combination of values.
|
||||
|
||||
An address value may be either a symbol name, a hex value preceded
|
||||
with the specifier "0x", a decimal value preceded with the specifier
|
||||
"0d", or a number in the default input radix (without a specifier). See
|
||||
the option \fBiradix\fR for more information.
|
||||
An address value can be one of the following:
|
||||
.RS
|
||||
A symbol name
|
||||
.br
|
||||
A CPU register name preceded with "@"
|
||||
.br
|
||||
A hex value preceded with the specifier "0x"
|
||||
.br
|
||||
A decimal value preceded with the specifier "0d"
|
||||
.br
|
||||
A number in the default input radix (without a specifier). See the option
|
||||
\fBiradix\fR for more information.
|
||||
.RE
|
||||
|
||||
The operators recognised are the usual algebraic operators: \fB+\fR, \fB-\fR,
|
||||
\fB*\fR, \fB/\fR, \fB%\fR, \fB(\fR and \fB)\fR. Operator precedence is the
|
||||
|
@ -751,6 +760,8 @@ The following are all valid examples of address expressions:
|
|||
.B main+0x3f
|
||||
.br
|
||||
.B __bss_end-__bss_start
|
||||
.br
|
||||
.B @sp
|
||||
.SH OPTIONS
|
||||
MSPDebug's behaviour can be configured via the following variables:
|
||||
.IP "\fBcolor\fR (boolean)"
|
||||
|
|
16
util/expr.c
16
util/expr.c
|
@ -29,6 +29,8 @@
|
|||
#include "output.h"
|
||||
#include "opdb.h"
|
||||
#include "demangle.h"
|
||||
#include "device.h"
|
||||
#include "dis.h"
|
||||
|
||||
/************************************************************************
|
||||
* Address expression parsing.
|
||||
|
@ -56,6 +58,18 @@ static int addr_exp_data(struct addr_exp_state *s, const char *text)
|
|||
value = strtoul(text + 2, NULL, 16);
|
||||
} else if (*text == '0' && text[1] == 'd') {
|
||||
value = atoi(text + 2);
|
||||
} else if (*text == '@') {
|
||||
int reg = dis_reg_from_name(text + 1);
|
||||
if (reg < 0) {
|
||||
printc_err("invalid register: %s\n", text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
address_t regs[DEVICE_NUM_REGS];
|
||||
if (device_getregs(regs) < 0)
|
||||
return -1;
|
||||
|
||||
value = regs[reg];
|
||||
} else if (stab_get(text, &value) < 0) {
|
||||
char *end;
|
||||
|
||||
|
@ -252,7 +266,7 @@ int expr_eval(const char *text, address_t *addr)
|
|||
else if (!*text || isspace(*text))
|
||||
cc = 2;
|
||||
else if (isalnum(*text) || *text == '.' || *text == '_' ||
|
||||
*text == '$' || *text == ':')
|
||||
*text == '$' || *text == ':' || *text == '@')
|
||||
cc = 3;
|
||||
else {
|
||||
printc_err("illegal character in expression: %c\n",
|
||||
|
|
Loading…
Reference in New Issue