diff options
author | David Schleef <ds@schleef.org> | 2009-06-28 00:10:26 -0700 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2009-06-28 00:12:18 -0700 |
commit | 7bb86857e788b7a694c812bdcd3d5611cf6f909a (patch) | |
tree | b8241756e870c055b62c130f3807e84704709045 | |
parent | 1903feb1a3bc856deb45d0d2e3b73180b6818750 (diff) |
orcc: handle constants
-rw-r--r-- | orc/orcparse.c | 4 | ||||
-rw-r--r-- | tools/orcc.c | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/orc/orcparse.c b/orc/orcparse.c index 6fb9c08..e27f5c0 100644 --- a/orc/orcparse.c +++ b/orc/orcparse.c @@ -137,6 +137,10 @@ orc_parse (const char *code, OrcProgram ***programs) } else if (strcmp (token[0], ".param") == 0) { int size = strtol (token[1], NULL, 0); orc_program_add_parameter (parser->program, size, token[2]); + } else if (strcmp (token[0], ".const") == 0) { + int size = strtol (token[1], NULL, 0); + int value = strtoul (token[3], NULL, 0); + orc_program_add_constant (parser->program, size, value, token[2]); } else { ORC_ERROR("ERROR: unknown directive: %s", token[0]); } diff --git a/tools/orcc.c b/tools/orcc.c index fce5ef1..86938cf 100644 --- a/tools/orcc.c +++ b/tools/orcc.c @@ -354,8 +354,13 @@ output_code (OrcProgram *p, FILE *output) for(i=0;i<8;i++){ var = &p->vars[ORC_VAR_C1 + i]; if (var->size) { - fprintf(output, " orc_program_add_constant (p, %d, %d, \"%s\");\n", - var->size, var->value, varnames[ORC_VAR_C1 + i]); + if (var->value != 0x80000000) { + fprintf(output, " orc_program_add_constant (p, %d, %u, \"%s\");\n", + var->size, var->value, varnames[ORC_VAR_C1 + i]); + } else { + fprintf(output, " orc_program_add_constant (p, %d, 0x%08x, \"%s\");\n", + var->size, var->value, varnames[ORC_VAR_C1 + i]); + } } } for(i=0;i<8;i++){ |