summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2009-10-31 20:02:14 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2009-10-31 20:02:14 +0300
commitbafd877d48b25e576a4c905a14f1301502cca69c (patch)
tree31dc41dbd7cb24d3020dd6a092797f410d50d231 /parser.c
parent41208028ff52d190044ee7532bf14c5aca0f899a (diff)
downloadnasm-bafd877d48b25e576a4c905a14f1301502cca69c.tar.gz
nasm-bafd877d48b25e576a4c905a14f1301502cca69c.tar.bz2
nasm-bafd877d48b25e576a4c905a14f1301502cca69c.zip
nasmlib: Introduce idata_bytes helper
This allow us to eliminate code duplication Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c55
1 files changed, 18 insertions, 37 deletions
diff --git a/parser.c b/parser.c
index 34fcf47..adf181c 100644
--- a/parser.c
+++ b/parser.c
@@ -429,44 +429,25 @@ restart_parse:
goto is_float;
}
} else if (i == TOKEN_FLOAT) {
- is_float:
+is_float:
eop->type = EOT_DB_STRING;
result->eops_float = true;
- switch (result->opcode) {
- case I_DB:
- eop->stringlen = 1;
- break;
- case I_DW:
- eop->stringlen = 2;
- break;
- case I_DD:
- eop->stringlen = 4;
- break;
- case I_DQ:
- eop->stringlen = 8;
- break;
- case I_DT:
- eop->stringlen = 10;
- break;
- case I_DO:
- eop->stringlen = 16;
- break;
- case I_DY:
- nasm_error(ERR_NONFATAL, "floating-point constant"
- " encountered in DY instruction");
- eop->stringlen = 0;
- break;
- default:
- nasm_error(ERR_NONFATAL, "floating-point constant"
- " encountered in unknown instruction");
- /*
- * fix suggested by Pedro Gimeno... original line
- * was:
- * eop->type = EOT_NOTHING;
- */
- eop->stringlen = 0;
- break;
- }
+
+ eop->stringlen = idata_bytes(result->opcode);
+ if (eop->stringlen > 16) {
+ nasm_error(ERR_NONFATAL, "floating-point constant"
+ " encountered in DY instruction");
+ eop->stringlen = 0;
+ } else if (eop->stringlen < 1) {
+ nasm_error(ERR_NONFATAL, "floating-point constant"
+ " encountered in unknown instruction");
+ /*
+ * fix suggested by Pedro Gimeno... original line was:
+ * eop->type = EOT_NOTHING;
+ */
+ eop->stringlen = 0;
+ }
+
eop = nasm_realloc(eop, sizeof(extop) + eop->stringlen);
tail = &eop->next;
*fixptr = eop;
@@ -481,7 +462,7 @@ restart_parse:
/* anything else, assume it is an expression */
expr *value;
- is_expression:
+is_expression:
value = evaluate(stdscan, NULL, &tokval, NULL,
critical, nasm_error, NULL);
i = tokval.t_type;