1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2009 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
35 * parser.c source line parser for the Netwide Assembler
56 extern int in_abs_seg; /* ABSOLUTE segment flag */
57 extern int32_t abs_seg; /* ABSOLUTE segment */
58 extern int32_t abs_offset; /* ABSOLUTE segment offset */
60 static int is_comma_next(void);
63 static struct tokenval tokval;
64 static struct location *location; /* Pointer to current line's segment,offset */
66 void parser_global_info(struct location * locp)
71 static int prefix_slot(enum prefixes prefix)
101 nasm_error(ERR_PANIC, "Invalid value %d passed to prefix_slot()", prefix);
106 static void process_size_override(insn *result, int operand)
108 if (tasm_compatible_mode) {
109 switch ((int)tokval.t_integer) {
110 /* For TASM compatibility a size override inside the
111 * brackets changes the size of the operand, not the
112 * address type of the operand as it does in standard
113 * NASM syntax. Hence:
115 * mov eax,[DWORD val]
117 * is valid syntax in TASM compatibility mode. Note that
118 * you lose the ability to override the default address
119 * type for the instruction, but we never use anything
120 * but 32-bit flat model addressing in our code.
123 result->oprs[operand].type |= BITS8;
126 result->oprs[operand].type |= BITS16;
130 result->oprs[operand].type |= BITS32;
133 result->oprs[operand].type |= BITS64;
136 result->oprs[operand].type |= BITS80;
139 result->oprs[operand].type |= BITS128;
142 nasm_error(ERR_NONFATAL,
143 "invalid operand size specification");
147 /* Standard NASM compatible syntax */
148 switch ((int)tokval.t_integer) {
150 result->oprs[operand].eaflags |= EAF_TIMESTWO;
153 result->oprs[operand].eaflags |= EAF_REL;
156 result->oprs[operand].eaflags |= EAF_ABS;
159 result->oprs[operand].disp_size = 8;
160 result->oprs[operand].eaflags |= EAF_BYTEOFFS;
165 if (result->prefixes[PPS_ASIZE] &&
166 result->prefixes[PPS_ASIZE] != tokval.t_integer)
167 nasm_error(ERR_NONFATAL,
168 "conflicting address size specifications");
170 result->prefixes[PPS_ASIZE] = tokval.t_integer;
173 result->oprs[operand].disp_size = 16;
174 result->oprs[operand].eaflags |= EAF_WORDOFFS;
178 result->oprs[operand].disp_size = 32;
179 result->oprs[operand].eaflags |= EAF_WORDOFFS;
182 result->oprs[operand].disp_size = 64;
183 result->oprs[operand].eaflags |= EAF_WORDOFFS;
186 nasm_error(ERR_NONFATAL, "invalid size specification in"
187 " effective address");
193 insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef)
195 bool insn_is_label = false;
196 struct eval_hints hints;
205 result->forw_ref = false;
209 i = stdscan(NULL, &tokval);
211 result->label = NULL; /* Assume no label */
212 result->eops = NULL; /* must do this, whatever happens */
213 result->operands = 0; /* must initialize this */
215 /* Ignore blank lines */
216 if (i == TOKEN_EOS) {
217 result->opcode = I_none;
224 (i != TOKEN_REG || !IS_SREG(tokval.t_integer))) {
225 nasm_error(ERR_NONFATAL,
226 "label or instruction expected at start of line");
227 result->opcode = I_none;
231 if (i == TOKEN_ID || (insn_is_label && i == TOKEN_INSN)) {
232 /* there's a label here */
234 result->label = tokval.t_charptr;
235 i = stdscan(NULL, &tokval);
236 if (i == ':') { /* skip over the optional colon */
237 i = stdscan(NULL, &tokval);
239 nasm_error(ERR_WARNING | ERR_WARN_OL | ERR_PASS1,
240 "label alone on a line without a colon might be in error");
242 if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
244 * FIXME: location->segment could be NO_SEG, in which case
245 * it is possible we should be passing 'abs_seg'. Look into this.
246 * Work out whether that is *really* what we should be doing.
247 * Generally fix things. I think this is right as it is, but
248 * am still not certain.
250 ldef(result->label, in_abs_seg ? abs_seg : location->segment,
251 location->offset, NULL, true, false);
255 /* Just a label here */
256 if (i == TOKEN_EOS) {
257 result->opcode = I_none;
261 for (j = 0; j < MAXPREFIX; j++)
262 result->prefixes[j] = P_none;
265 while (i == TOKEN_PREFIX ||
266 (i == TOKEN_REG && IS_SREG(tokval.t_integer))) {
270 * Handle special case: the TIMES prefix.
272 if (i == TOKEN_PREFIX && tokval.t_integer == P_TIMES) {
275 i = stdscan(NULL, &tokval);
276 value = evaluate(stdscan, NULL, &tokval, NULL, pass0, nasm_error, NULL);
278 if (!value) { /* but, error in evaluator */
279 result->opcode = I_none; /* unrecoverable parse error: */
280 return result; /* ignore this instruction */
282 if (!is_simple(value)) {
283 nasm_error(ERR_NONFATAL,
284 "non-constant argument supplied to TIMES");
287 result->times = value->value;
288 if (value->value < 0 && pass0 == 2) {
289 nasm_error(ERR_NONFATAL, "TIMES value %"PRId64" is negative",
295 int slot = prefix_slot(tokval.t_integer);
296 if (result->prefixes[slot]) {
297 if (result->prefixes[slot] == tokval.t_integer)
298 nasm_error(ERR_WARNING | ERR_PASS1,
299 "instruction has redundant prefixes");
301 nasm_error(ERR_NONFATAL,
302 "instruction has conflicting prefixes");
304 result->prefixes[slot] = tokval.t_integer;
305 i = stdscan(NULL, &tokval);
309 if (i != TOKEN_INSN) {
313 for (j = 0; j < MAXPREFIX; j++) {
314 if ((pfx = result->prefixes[j]) != P_none)
318 if (i == 0 && pfx != P_none) {
320 * Instruction prefixes are present, but no actual
321 * instruction. This is allowed: at this point we
322 * invent a notional instruction of RESB 0.
324 result->opcode = I_RESB;
325 result->operands = 1;
326 result->oprs[0].type = IMMEDIATE;
327 result->oprs[0].offset = 0L;
328 result->oprs[0].segment = result->oprs[0].wrt = NO_SEG;
331 nasm_error(ERR_NONFATAL, "parser: instruction expected");
332 result->opcode = I_none;
337 result->opcode = tokval.t_integer;
338 result->condition = tokval.t_inttwo;
341 * INCBIN cannot be satisfied with incorrectly
342 * evaluated operands, since the correct values _must_ be known
343 * on the first pass. Hence, even in pass one, we set the
344 * `critical' flag on calling evaluate(), so that it will bomb
345 * out on undefined symbols.
347 if (result->opcode == I_INCBIN) {
348 critical = (pass0 < 2 ? 1 : 2);
351 critical = (pass == 2 ? 2 : 0);
353 if (result->opcode == I_DB || result->opcode == I_DW ||
354 result->opcode == I_DD || result->opcode == I_DQ ||
355 result->opcode == I_DT || result->opcode == I_DO ||
356 result->opcode == I_DY || result->opcode == I_INCBIN) {
357 extop *eop, **tail = &result->eops, **fixptr;
361 result->eops_float = false;
364 * Begin to read the DB/DW/DD/DQ/DT/DO/INCBIN operands.
367 i = stdscan(NULL, &tokval);
370 else if (first && i == ':') {
371 insn_is_label = true;
376 eop = *tail = nasm_malloc(sizeof(extop));
379 eop->type = EOT_NOTHING;
384 * is_comma_next() here is to distinguish this from
385 * a string used as part of an expression...
387 if (i == TOKEN_STR && is_comma_next()) {
388 eop->type = EOT_DB_STRING;
389 eop->stringval = tokval.t_charptr;
390 eop->stringlen = tokval.t_inttwo;
391 i = stdscan(NULL, &tokval); /* eat the comma */
392 } else if (i == TOKEN_STRFUNC) {
394 const char *funcname = tokval.t_charptr;
395 enum strfunc func = tokval.t_integer;
396 i = stdscan(NULL, &tokval);
399 i = stdscan(NULL, &tokval);
401 if (i != TOKEN_STR) {
402 nasm_error(ERR_NONFATAL,
403 "%s must be followed by a string constant",
405 eop->type = EOT_NOTHING;
407 eop->type = EOT_DB_STRING_FREE;
409 string_transform(tokval.t_charptr, tokval.t_inttwo,
410 &eop->stringval, func);
411 if (eop->stringlen == (size_t)-1) {
412 nasm_error(ERR_NONFATAL, "invalid string for transform");
413 eop->type = EOT_NOTHING;
416 if (parens && i && i != ')') {
417 i = stdscan(NULL, &tokval);
419 nasm_error(ERR_NONFATAL, "unterminated %s function",
424 i = stdscan(NULL, &tokval);
425 } else if (i == '-' || i == '+') {
426 char *save = stdscan_get();
428 sign = (i == '-') ? -1 : 1;
429 i = stdscan(NULL, &tokval);
430 if (i != TOKEN_FLOAT) {
432 i = tokval.t_type = token;
437 } else if (i == TOKEN_FLOAT) {
439 eop->type = EOT_DB_STRING;
440 result->eops_float = true;
442 eop->stringlen = idata_bytes(result->opcode);
443 if (eop->stringlen > 16) {
444 nasm_error(ERR_NONFATAL, "floating-point constant"
445 " encountered in DY instruction");
447 } else if (eop->stringlen < 1) {
448 nasm_error(ERR_NONFATAL, "floating-point constant"
449 " encountered in unknown instruction");
451 * fix suggested by Pedro Gimeno... original line was:
452 * eop->type = EOT_NOTHING;
457 eop = nasm_realloc(eop, sizeof(extop) + eop->stringlen);
460 eop->stringval = (char *)eop + sizeof(extop);
461 if (!eop->stringlen ||
462 !float_const(tokval.t_charptr, sign,
463 (uint8_t *)eop->stringval,
464 eop->stringlen, nasm_error))
465 eop->type = EOT_NOTHING;
466 i = stdscan(NULL, &tokval); /* eat the comma */
468 /* anything else, assume it is an expression */
472 value = evaluate(stdscan, NULL, &tokval, NULL,
473 critical, nasm_error, NULL);
475 if (!value) { /* error in evaluator */
476 result->opcode = I_none; /* unrecoverable parse error: */
477 return result; /* ignore this instruction */
479 if (is_unknown(value)) {
480 eop->type = EOT_DB_NUMBER;
481 eop->offset = 0; /* doesn't matter what we put */
482 eop->segment = eop->wrt = NO_SEG; /* likewise */
483 } else if (is_reloc(value)) {
484 eop->type = EOT_DB_NUMBER;
485 eop->offset = reloc_value(value);
486 eop->segment = reloc_seg(value);
487 eop->wrt = reloc_wrt(value);
489 nasm_error(ERR_NONFATAL,
490 "operand %d: expression is not simple"
491 " or relocatable", oper_num);
496 * We're about to call stdscan(), which will eat the
497 * comma that we're currently sitting on between
498 * arguments. However, we'd better check first that it
501 if (i == TOKEN_EOS) /* also could be EOL */
504 nasm_error(ERR_NONFATAL, "comma expected after operand %d",
506 result->opcode = I_none;/* unrecoverable parse error: */
507 return result; /* ignore this instruction */
511 if (result->opcode == I_INCBIN) {
513 * Correct syntax for INCBIN is that there should be
514 * one string operand, followed by one or two numeric
517 if (!result->eops || result->eops->type != EOT_DB_STRING)
518 nasm_error(ERR_NONFATAL, "`incbin' expects a file name");
519 else if (result->eops->next &&
520 result->eops->next->type != EOT_DB_NUMBER)
521 nasm_error(ERR_NONFATAL, "`incbin': second parameter is"
523 else if (result->eops->next && result->eops->next->next &&
524 result->eops->next->next->type != EOT_DB_NUMBER)
525 nasm_error(ERR_NONFATAL, "`incbin': third parameter is"
527 else if (result->eops->next && result->eops->next->next &&
528 result->eops->next->next->next)
529 nasm_error(ERR_NONFATAL,
530 "`incbin': more than three parameters");
534 * If we reach here, one of the above errors happened.
535 * Throw the instruction away.
537 result->opcode = I_none;
539 } else /* DB ... */ if (oper_num == 0)
540 nasm_error(ERR_WARNING | ERR_PASS1,
541 "no operand for data declaration");
543 result->operands = oper_num;
549 * Now we begin to parse the operands. There may be up to four
550 * of these, separated by commas, and terminated by a zero token.
553 for (operand = 0; operand < MAX_OPERANDS; operand++) {
554 expr *value; /* used most of the time */
555 int mref; /* is this going to be a memory ref? */
556 int bracket; /* is it a [] mref, or a & mref? */
559 result->oprs[operand].disp_size = 0; /* have to zero this whatever */
560 result->oprs[operand].eaflags = 0; /* and this */
561 result->oprs[operand].opflags = 0;
563 i = stdscan(NULL, &tokval);
565 break; /* end of operands: get out of here */
566 else if (first && i == ':') {
567 insn_is_label = true;
571 result->oprs[operand].type = 0; /* so far, no override */
572 while (i == TOKEN_SPECIAL) { /* size specifiers */
573 switch ((int)tokval.t_integer) {
575 if (!setsize) /* we want to use only the first */
576 result->oprs[operand].type |= BITS8;
581 result->oprs[operand].type |= BITS16;
587 result->oprs[operand].type |= BITS32;
592 result->oprs[operand].type |= BITS64;
597 result->oprs[operand].type |= BITS80;
602 result->oprs[operand].type |= BITS128;
607 result->oprs[operand].type |= BITS256;
611 result->oprs[operand].type |= TO;
614 result->oprs[operand].type |= STRICT;
617 result->oprs[operand].type |= FAR;
620 result->oprs[operand].type |= NEAR;
623 result->oprs[operand].type |= SHORT;
626 nasm_error(ERR_NONFATAL, "invalid operand size specification");
628 i = stdscan(NULL, &tokval);
631 if (i == '[' || i == '&') { /* memory reference */
633 bracket = (i == '[');
634 i = stdscan(NULL, &tokval); /* then skip the colon */
635 while (i == TOKEN_SPECIAL || i == TOKEN_PREFIX) {
636 process_size_override(result, operand);
637 i = stdscan(NULL, &tokval);
639 } else { /* immediate operand, or register */
641 bracket = false; /* placate optimisers */
644 if ((result->oprs[operand].type & FAR) && !mref &&
645 result->opcode != I_JMP && result->opcode != I_CALL) {
646 nasm_error(ERR_NONFATAL, "invalid use of FAR operand specifier");
649 value = evaluate(stdscan, NULL, &tokval,
650 &result->oprs[operand].opflags,
651 critical, nasm_error, &hints);
653 if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
654 result->forw_ref = true;
656 if (!value) { /* nasm_error in evaluator */
657 result->opcode = I_none; /* unrecoverable parse error: */
658 return result; /* ignore this instruction */
660 if (i == ':' && mref) { /* it was seg:offset */
662 * Process the segment override.
664 if (value[1].type != 0 ||
666 !IS_SREG(value->type))
667 nasm_error(ERR_NONFATAL, "invalid segment override");
668 else if (result->prefixes[PPS_SEG])
669 nasm_error(ERR_NONFATAL,
670 "instruction has conflicting segment overrides");
672 result->prefixes[PPS_SEG] = value->type;
673 if (IS_FSGS(value->type))
674 result->oprs[operand].eaflags |= EAF_FSGS;
677 i = stdscan(NULL, &tokval); /* then skip the colon */
678 while (i == TOKEN_SPECIAL || i == TOKEN_PREFIX) {
679 process_size_override(result, operand);
680 i = stdscan(NULL, &tokval);
682 value = evaluate(stdscan, NULL, &tokval,
683 &result->oprs[operand].opflags,
684 critical, nasm_error, &hints);
686 if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
687 result->forw_ref = true;
689 /* and get the offset */
690 if (!value) { /* but, error in evaluator */
691 result->opcode = I_none; /* unrecoverable parse error: */
692 return result; /* ignore this instruction */
697 if (mref && bracket) { /* find ] at the end */
699 nasm_error(ERR_NONFATAL, "parser: expecting ]");
701 } else { /* we got the required ] */
702 i = stdscan(NULL, &tokval);
703 if (i != 0 && i != ',') {
704 nasm_error(ERR_NONFATAL, "comma or end of line expected");
708 } else { /* immediate operand */
709 if (i != 0 && i != ',' && i != ':') {
710 nasm_error(ERR_NONFATAL, "comma, colon or end of line expected");
712 } else if (i == ':') {
713 result->oprs[operand].type |= COLON;
717 do { /* error recovery */
718 i = stdscan(NULL, &tokval);
719 } while (i != 0 && i != ',');
723 * now convert the exprs returned from evaluate()
724 * into operand descriptions...
727 if (mref) { /* it's a memory reference */
729 int b, i, s; /* basereg, indexreg, scale */
730 int64_t o; /* offset */
732 b = i = -1, o = s = 0;
733 result->oprs[operand].hintbase = hints.base;
734 result->oprs[operand].hinttype = hints.type;
736 if (e->type && e->type <= EXPR_REG_END) { /* this bit's a register */
737 if (e->value == 1) /* in fact it can be basereg */
739 else /* no, it has to be indexreg */
740 i = e->type, s = e->value;
743 if (e->type && e->type <= EXPR_REG_END) { /* it's a 2nd register */
744 if (b != -1) /* If the first was the base, ... */
745 i = e->type, s = e->value; /* second has to be indexreg */
747 else if (e->value != 1) { /* If both want to be index */
748 nasm_error(ERR_NONFATAL,
749 "beroset-p-592-invalid effective address");
750 result->opcode = I_none;
756 if (e->type != 0) { /* is there an offset? */
757 if (e->type <= EXPR_REG_END) { /* in fact, is there an error? */
758 nasm_error(ERR_NONFATAL,
759 "beroset-p-603-invalid effective address");
760 result->opcode = I_none;
763 if (e->type == EXPR_UNKNOWN) {
764 result->oprs[operand].opflags |= OPFLAG_UNKNOWN;
765 o = 0; /* doesn't matter what */
766 result->oprs[operand].wrt = NO_SEG; /* nor this */
767 result->oprs[operand].segment = NO_SEG; /* or this */
769 e++; /* go to the end of the line */
771 if (e->type == EXPR_SIMPLE) {
775 if (e->type == EXPR_WRT) {
776 result->oprs[operand].wrt = e->value;
779 result->oprs[operand].wrt = NO_SEG;
781 * Look for a segment base type.
783 if (e->type && e->type < EXPR_SEGBASE) {
784 nasm_error(ERR_NONFATAL,
785 "beroset-p-630-invalid effective address");
786 result->opcode = I_none;
789 while (e->type && e->value == 0)
791 if (e->type && e->value != 1) {
792 nasm_error(ERR_NONFATAL,
793 "beroset-p-637-invalid effective address");
794 result->opcode = I_none;
798 result->oprs[operand].segment =
799 e->type - EXPR_SEGBASE;
802 result->oprs[operand].segment = NO_SEG;
803 while (e->type && e->value == 0)
806 nasm_error(ERR_NONFATAL,
807 "beroset-p-650-invalid effective address");
808 result->opcode = I_none;
815 result->oprs[operand].wrt = NO_SEG;
816 result->oprs[operand].segment = NO_SEG;
819 if (e->type != 0) { /* there'd better be nothing left! */
820 nasm_error(ERR_NONFATAL,
821 "beroset-p-663-invalid effective address");
822 result->opcode = I_none;
826 /* It is memory, but it can match any r/m operand */
827 result->oprs[operand].type |= MEMORY_ANY;
829 if (b == -1 && (i == -1 || s == 0)) {
830 int is_rel = globalbits == 64 &&
831 !(result->oprs[operand].eaflags & EAF_ABS) &&
833 !(result->oprs[operand].eaflags & EAF_FSGS)) ||
834 (result->oprs[operand].eaflags & EAF_REL));
836 result->oprs[operand].type |= is_rel ? IP_REL : MEM_OFFS;
838 result->oprs[operand].basereg = b;
839 result->oprs[operand].indexreg = i;
840 result->oprs[operand].scale = s;
841 result->oprs[operand].offset = o;
842 } else { /* it's not a memory reference */
843 if (is_just_unknown(value)) { /* it's immediate but unknown */
844 result->oprs[operand].type |= IMMEDIATE;
845 result->oprs[operand].opflags |= OPFLAG_UNKNOWN;
846 result->oprs[operand].offset = 0; /* don't care */
847 result->oprs[operand].segment = NO_SEG; /* don't care again */
848 result->oprs[operand].wrt = NO_SEG; /* still don't care */
850 if(optimizing >= 0 && !(result->oprs[operand].type & STRICT)) {
852 result->oprs[operand].type |=
853 SBYTE16 | SBYTE32 | SBYTE64 | UDWORD64 | SDWORD64;
855 } else if (is_reloc(value)) { /* it's immediate */
856 result->oprs[operand].type |= IMMEDIATE;
857 result->oprs[operand].offset = reloc_value(value);
858 result->oprs[operand].segment = reloc_seg(value);
859 result->oprs[operand].wrt = reloc_wrt(value);
861 if (is_simple(value)) {
862 if (reloc_value(value) == 1)
863 result->oprs[operand].type |= UNITY;
864 if (optimizing >= 0 &&
865 !(result->oprs[operand].type & STRICT)) {
866 int64_t v64 = reloc_value(value);
867 int32_t v32 = (int32_t)v64;
868 int16_t v16 = (int16_t)v32;
870 if (v64 >= -128 && v64 <= 127)
871 result->oprs[operand].type |= SBYTE64;
872 if (v32 >= -128 && v32 <= 127)
873 result->oprs[operand].type |= SBYTE32;
874 if (v16 >= -128 && v16 <= 127)
875 result->oprs[operand].type |= SBYTE16;
876 if ((uint64_t)v64 <= UINT64_C(0xffffffff))
877 result->oprs[operand].type |= UDWORD64;
878 if (v64 >= -INT64_C(0x80000000) &&
879 v64 <= INT64_C(0x7fffffff))
880 result->oprs[operand].type |= SDWORD64;
883 } else { /* it's a register */
886 if (value->type >= EXPR_SIMPLE || value->value != 1) {
887 nasm_error(ERR_NONFATAL, "invalid operand type");
888 result->opcode = I_none;
893 * check that its only 1 register, not an expression...
895 for (i = 1; value[i].type; i++)
896 if (value[i].value) {
897 nasm_error(ERR_NONFATAL, "invalid operand type");
898 result->opcode = I_none;
902 /* clear overrides, except TO which applies to FPU regs */
903 if (result->oprs[operand].type & ~TO) {
905 * we want to produce a warning iff the specified size
906 * is different from the register size
908 rs = result->oprs[operand].type & SIZE_MASK;
912 result->oprs[operand].type &= TO;
913 result->oprs[operand].type |= REGISTER;
914 result->oprs[operand].type |= nasm_reg_flags[value->type];
915 result->oprs[operand].basereg = value->type;
917 if (rs && (result->oprs[operand].type & SIZE_MASK) != rs)
918 nasm_error(ERR_WARNING | ERR_PASS1,
919 "register size specification ignored");
924 result->operands = operand; /* set operand count */
926 /* clear remaining operands */
927 while (operand < MAX_OPERANDS)
928 result->oprs[operand++].type = 0;
931 * Transform RESW, RESD, RESQ, REST, RESO, RESY into RESB.
933 switch (result->opcode) {
935 result->opcode = I_RESB;
936 result->oprs[0].offset *= 2;
939 result->opcode = I_RESB;
940 result->oprs[0].offset *= 4;
943 result->opcode = I_RESB;
944 result->oprs[0].offset *= 8;
947 result->opcode = I_RESB;
948 result->oprs[0].offset *= 10;
951 result->opcode = I_RESB;
952 result->oprs[0].offset *= 16;
955 result->opcode = I_RESB;
956 result->oprs[0].offset *= 32;
965 static int is_comma_next(void)
972 i = stdscan(NULL, &tv);
975 return (i == ',' || i == ';' || !i);
978 void cleanup_insn(insn * i)
982 while ((e = i->eops)) {
984 if (e->type == EOT_DB_STRING_FREE)
985 nasm_free(e->stringval);