int64_t insn_end;
int32_t itimes;
int64_t start = offset;
- int64_t wsize = 0; /* size for DB etc. */
+ int64_t wsize; /* size for DB etc. */
errfunc = error; /* to pass to other functions */
cpu = cp;
outfmt = output; /* likewise */
list = listgen; /* and again */
- switch (instruction->opcode) {
- case -1:
+ wsize = idata_bytes(instruction->opcode);
+ if (wsize == -1)
return 0;
- case I_DB:
- wsize = 1;
- break;
- case I_DW:
- wsize = 2;
- break;
- case I_DD:
- wsize = 4;
- break;
- case I_DQ:
- wsize = 8;
- break;
- case I_DT:
- wsize = 10;
- break;
- case I_DO:
- wsize = 16;
- break;
- case I_DY:
- wsize = 32;
- break;
- default:
- break;
- }
if (wsize) {
extop *e;
instruction->opcode == I_DT || instruction->opcode == I_DO ||
instruction->opcode == I_DY) {
extop *e;
- int32_t isize, osize, wsize = 0; /* placate gcc */
+ int32_t isize, osize, wsize;
isize = 0;
- switch (instruction->opcode) {
- case I_DB:
- wsize = 1;
- break;
- case I_DW:
- wsize = 2;
- break;
- case I_DD:
- wsize = 4;
- break;
- case I_DQ:
- wsize = 8;
- break;
- case I_DT:
- wsize = 10;
- break;
- case I_DO:
- wsize = 16;
- break;
- case I_DY:
- wsize = 32;
- break;
- default:
- break;
- }
+ wsize = idata_bytes(instruction->opcode);
list_for_each(e, instruction->eops) {
int32_t align;
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;
/* 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;