mirror of
https://github.com/open-simh/simtools.git
synced 2026-02-02 23:02:23 +00:00
Add evaluation of %+unary expressions.
This is a first step towards expressions like <%1>+1 and even later R1+1.
This commit is contained in:
32
extree.c
32
extree.c
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "util.h"
|
||||
#include "assemble_globals.h"
|
||||
#include "assemble_aux.h"
|
||||
#include "listing.h"
|
||||
#include "object.h"
|
||||
|
||||
|
||||
@@ -24,6 +26,10 @@ void print_tree(
|
||||
{
|
||||
SYMBOL *sym;
|
||||
|
||||
if (printfile == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tp == NULL) {
|
||||
fprintf(printfile, "(null)");
|
||||
return;
|
||||
@@ -57,6 +63,12 @@ void print_tree(
|
||||
fputc('>', printfile);
|
||||
break;
|
||||
|
||||
case EX_REG:
|
||||
fprintf(printfile, "%%<");
|
||||
print_tree(printfile, tp->data.child.left, depth + 4);
|
||||
fputc('>', printfile);
|
||||
break;
|
||||
|
||||
case EX_ERR:
|
||||
fprintf(printfile, "{expression error}");
|
||||
if (tp->data.child.left) {
|
||||
@@ -146,6 +158,7 @@ int num_subtrees(
|
||||
|
||||
case EX_COM:
|
||||
case EX_NEG:
|
||||
case EX_REG:
|
||||
case EX_ERR:
|
||||
return 1;
|
||||
|
||||
@@ -403,6 +416,25 @@ EX_TREE *evaluate(
|
||||
}
|
||||
break;
|
||||
|
||||
case EX_REG:
|
||||
/* Evaluate as a literal, and create a register label */
|
||||
{
|
||||
res = evaluate(tp->data.child.left, flags);
|
||||
int regno = get_register(res);
|
||||
|
||||
if (regno == NO_REG) {
|
||||
report(NULL, "Register expression out of range.\n");
|
||||
res = ex_err(res, res->cp);
|
||||
} else {
|
||||
EX_TREE *newresult = new_ex_tree(EX_SYM);
|
||||
|
||||
newresult->cp = res->cp;
|
||||
newresult->data.symbol = reg_sym[regno];
|
||||
res = newresult;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EX_ERR:
|
||||
/* Copy */
|
||||
res = dup_tree(tp);
|
||||
|
||||
Reference in New Issue
Block a user