scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit f49a0894cf79d52e8399d44d22e86d07e5b2c754
parent 73ea23b4798899eeb1aec7d9e19b594f8000c016
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 11 Aug 2014 22:30:50 +0200

Add content and address operators

Diffstat:
cc2/cc2.h | 2++
cc2/cgen.c | 4++++
cc2/parser.c | 14++++++++++++++
3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -76,6 +76,8 @@ enum nerrors { #define OBAND '&' #define OBOR '|' #define OBXOR '^' +#define OPTR '@' +#define OADDR 'a' extern void error(unsigned nerror, ...); extern void genaddable(Node *list[]); diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -124,6 +124,7 @@ xcgen(Node *np) } switch (np->op) { + case OPTR: case OADDR: case OINC: case OADD: case OSUB: case OASSIG: case OMOD: case ODIV: case OSHL: case OSHR: @@ -192,6 +193,9 @@ xaddable(Node *np) case CONST: np->addable = 20; break; + case OPTR: case OADDR: + xaddable(lp); + break; case OINC: case OASSIG: case OADD: case OSUB: case OMOD: case ODIV: case OSHL: case OSHR: diff --git a/cc2/parser.c b/cc2/parser.c @@ -203,6 +203,18 @@ immediate(char *token) } static void +unary(char *token) +{ + Node *np = newnode(); + + np->right = NULL; + np->left = pop(); + np->type = gettype(token+1); + np->op = token[0]; + push(np); +} + +static void operator(char *token) { Node *np = newnode(); @@ -280,6 +292,8 @@ static void (*optbl[])(char *) = { ['G'] = variable, ['L'] = label, ['#'] = immediate, + ['@'] = unary, + ['a'] = unary, ['\177'] = NULL };