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(int prefix)
104 nasm_error(ERR_PANIC, "Invalid value %d passed to prefix_slot()", prefix);
109 static void process_size_override(insn *result, int operand)
111 if (tasm_compatible_mode) {
112 switch ((int)tokval.t_integer) {
113 /* For TASM compatibility a size override inside the
114 * brackets changes the size of the operand, not the
115 * address type of the operand as it does in standard
116 * NASM syntax. Hence:
118 * mov eax,[DWORD val]
120 * is valid syntax in TASM compatibility mode. Note that
121 * you lose the ability to override the default address
122 * type for the instruction, but we never use anything
123 * but 32-bit flat model addressing in our code.
126 result->oprs[operand].type |= BITS8;
129 result->oprs[operand].type |= BITS16;
133 result->oprs[operand].type |= BITS32;
136 result->oprs[operand].type |= BITS64;
139 result->oprs[operand].type |= BITS80;
142 result->oprs[operand].type |= BITS128;
145 nasm_error(ERR_NONFATAL,
146 "invalid operand size specification");
150 /* Standard NASM compatible syntax */
151 switch ((int)tokval.t_integer) {
153 result->oprs[operand].eaflags |= EAF_TIMESTWO;
156 result->oprs[operand].eaflags |= EAF_REL;
159 result->oprs[operand].eaflags |= EAF_ABS;
162 result->oprs[operand].disp_size = 8;
163 result->oprs[operand].eaflags |= EAF_BYTEOFFS;
168 if (result->prefixes[PPS_ASIZE] &&
169 result->prefixes[PPS_ASIZE] != tokval.t_integer)
170 nasm_error(ERR_NONFATAL,
171 "conflicting address size specifications");
173 result->prefixes[PPS_ASIZE] = tokval.t_integer;
176 result->oprs[operand].disp_size = 16;
177 result->oprs[operand].eaflags |= EAF_WORDOFFS;
181 result->oprs[operand].disp_size = 32;
182 result->oprs[operand].eaflags |= EAF_WORDOFFS;
185 result->oprs[operand].disp_size = 64;
186 result->oprs[operand].eaflags |= EAF_WORDOFFS;
189 nasm_error(ERR_NONFATAL, "invalid size specification in"
190 " effective address");
196 insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef)
198 bool insn_is_label = false;
199 struct eval_hints hints;
207 result->forw_ref = false;
211 i = stdscan(NULL, &tokval);
213 result->label = NULL; /* Assume no label */
214 result->eops = NULL; /* must do this, whatever happens */
215 result->operands = 0; /* must initialize this */
217 /* Ignore blank lines */
218 if (i == TOKEN_EOS) {
219 result->opcode = I_none;
226 (i != TOKEN_REG || !IS_SREG(tokval.t_integer))) {
227 nasm_error(ERR_NONFATAL,
228 "label or instruction expected at start of line");
229 result->opcode = I_none;
233 if (i == TOKEN_ID || (insn_is_label && i == TOKEN_INSN)) {
234 /* there's a label here */
236 result->label = tokval.t_charptr;
237 i = stdscan(NULL, &tokval);
238 if (i == ':') { /* skip over the optional colon */
239 i = stdscan(NULL, &tokval);
241 nasm_error(ERR_WARNING | ERR_WARN_OL | ERR_PASS1,
242 "label alone on a line without a colon might be in error");
244 if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
246 * FIXME: location->segment could be NO_SEG, in which case
247 * it is possible we should be passing 'abs_seg'. Look into this.
248 * Work out whether that is *really* what we should be doing.
249 * Generally fix things. I think this is right as it is, but
250 * am still not certain.
252 ldef(result->label, in_abs_seg ? abs_seg : location->segment,
253 location->offset, NULL, true, false);
257 /* Just a label here */
258 if (i == TOKEN_EOS) {
259 result->opcode = I_none;
263 nasm_build_assert(P_none != 0);
264 memset(result->prefixes, P_none, sizeof(result->prefixes));
267 while (i == TOKEN_PREFIX ||
268 (i == TOKEN_REG && IS_SREG(tokval.t_integer))) {
272 * Handle special case: the TIMES prefix.
274 if (i == TOKEN_PREFIX && tokval.t_integer == P_TIMES) {
277 i = stdscan(NULL, &tokval);
278 value = evaluate(stdscan, NULL, &tokval, NULL, pass0, nasm_error, NULL);
280 if (!value) { /* but, error in evaluator */
281 result->opcode = I_none; /* unrecoverable parse error: */
282 return result; /* ignore this instruction */
284 if (!is_simple(value)) {
285 nasm_error(ERR_NONFATAL,
286 "non-constant argument supplied to TIMES");
289 result->times = value->value;
290 if (value->value < 0 && pass0 == 2) {
291 nasm_error(ERR_NONFATAL, "TIMES value %"PRId64" is negative",
297 int slot = prefix_slot(tokval.t_integer);
298 if (result->prefixes[slot]) {
299 if (result->prefixes[slot] == tokval.t_integer)
300 nasm_error(ERR_WARNING | ERR_PASS1,
301 "instruction has redundant prefixes");
303 nasm_error(ERR_NONFATAL,
304 "instruction has conflicting prefixes");
306 result->prefixes[slot] = tokval.t_integer;
307 i = stdscan(NULL, &tokval);
311 if (i != TOKEN_INSN) {
315 for (j = 0; j < MAXPREFIX; j++) {
316 if ((pfx = result->prefixes[j]) != P_none)
320 if (i == 0 && pfx != P_none) {
322 * Instruction prefixes are present, but no actual
323 * instruction. This is allowed: at this point we
324 * invent a notional instruction of RESB 0.
326 result->opcode = I_RESB;
327 result->operands = 1;
328 result->oprs[0].type = IMMEDIATE;
329 result->oprs[0].offset = 0L;
330 result->oprs[0].segment = result->oprs[0].wrt = NO_SEG;
333 nasm_error(ERR_NONFATAL, "parser: instruction expected");
334 result->opcode = I_none;
339 result->opcode = tokval.t_integer;
340 result->condition = tokval.t_inttwo;
343 * INCBIN cannot be satisfied with incorrectly
344 * evaluated operands, since the correct values _must_ be known
345 * on the first pass. Hence, even in pass one, we set the
346 * `critical' flag on calling evaluate(), so that it will bomb
347 * out on undefined symbols.
349 if (result->opcode == I_INCBIN) {
350 critical = (pass0 < 2 ? 1 : 2);
353 critical = (pass == 2 ? 2 : 0);
355 if (result->opcode == I_DB || result->opcode == I_DW ||
356 result->opcode == I_DD || result->opcode == I_DQ ||
357 result->opcode == I_DT || result->opcode == I_DO ||
358 result->opcode == I_DY || result->opcode == I_INCBIN) {
359 extop *eop, **tail = &result->eops, **fixptr;
363 result->eops_float = false;
366 * Begin to read the DB/DW/DD/DQ/DT/DO/INCBIN operands.
369 i = stdscan(NULL, &tokval);
372 else if (first && i == ':') {
373 insn_is_label = true;
378 eop = *tail = nasm_malloc(sizeof(extop));
381 eop->type = EOT_NOTHING;
386 * is_comma_next() here is to distinguish this from
387 * a string used as part of an expression...
389 if (i == TOKEN_STR && is_comma_next()) {
390 eop->type = EOT_DB_STRING;
391 eop->stringval = tokval.t_charptr;
392 eop->stringlen = tokval.t_inttwo;
393 i = stdscan(NULL, &tokval); /* eat the comma */
394 } else if (i == TOKEN_STRFUNC) {
396 const char *funcname = tokval.t_charptr;
397 enum strfunc func = tokval.t_integer;
398 i = stdscan(NULL, &tokval);
401 i = stdscan(NULL, &tokval);
403 if (i != TOKEN_STR) {
404 nasm_error(ERR_NONFATAL,
405 "%s must be followed by a string constant",
407 eop->type = EOT_NOTHING;
409 eop->type = EOT_DB_STRING_FREE;
411 string_transform(tokval.t_charptr, tokval.t_inttwo,
412 &eop->stringval, func);
413 if (eop->stringlen == (size_t)-1) {
414 nasm_error(ERR_NONFATAL, "invalid string for transform");
415 eop->type = EOT_NOTHING;
418 if (parens && i && i != ')') {
419 i = stdscan(NULL, &tokval);
421 nasm_error(ERR_NONFATAL, "unterminated %s function",
426 i = stdscan(NULL, &tokval);
427 } else if (i == '-' || i == '+') {
428 char *save = stdscan_get();
430 sign = (i == '-') ? -1 : 1;
431 i = stdscan(NULL, &tokval);
432 if (i != TOKEN_FLOAT) {
434 i = tokval.t_type = token;
439 } else if (i == TOKEN_FLOAT) {
441 eop->type = EOT_DB_STRING;
442 result->eops_float = true;
444 eop->stringlen = idata_bytes(result->opcode);
445 if (eop->stringlen > 16) {
446 nasm_error(ERR_NONFATAL, "floating-point constant"
447 " encountered in DY instruction");
449 } else if (eop->stringlen < 1) {
450 nasm_error(ERR_NONFATAL, "floating-point constant"
451 " encountered in unknown instruction");
453 * fix suggested by Pedro Gimeno... original line was:
454 * eop->type = EOT_NOTHING;
459 eop = nasm_realloc(eop, sizeof(extop) + eop->stringlen);
462 eop->stringval = (char *)eop + sizeof(extop);
463 if (!eop->stringlen ||
464 !float_const(tokval.t_charptr, sign,
465 (uint8_t *)eop->stringval,
466 eop->stringlen, nasm_error))
467 eop->type = EOT_NOTHING;
468 i = stdscan(NULL, &tokval); /* eat the comma */
470 /* anything else, assume it is an expression */
474 value = evaluate(stdscan, NULL, &tokval, NULL,
475 critical, nasm_error, NULL);
477 if (!value) { /* error in evaluator */
478 result->opcode = I_none; /* unrecoverable parse error: */
479 return result; /* ignore this instruction */
481 if (is_unknown(value)) {
482 eop->type = EOT_DB_NUMBER;
483 eop->offset = 0; /* doesn't matter what we put */
484 eop->segment = eop->wrt = NO_SEG; /* likewise */
485 } else if (is_reloc(value)) {
486 eop->type = EOT_DB_NUMBER;
487 eop->offset = reloc_value(value);
488 eop->segment = reloc_seg(value);
489 eop->wrt = reloc_wrt(value);
491 nasm_error(ERR_NONFATAL,
492 "operand %d: expression is not simple"
493 " or relocatable", oper_num);
498 * We're about to call stdscan(), which will eat the
499 * comma that we're currently sitting on between
500 * arguments. However, we'd better check first that it
503 if (i == TOKEN_EOS) /* also could be EOL */
506 nasm_error(ERR_NONFATAL, "comma expected after operand %d",
508 result->opcode = I_none;/* unrecoverable parse error: */
509 return result; /* ignore this instruction */
513 if (result->opcode == I_INCBIN) {
515 * Correct syntax for INCBIN is that there should be
516 * one string operand, followed by one or two numeric
519 if (!result->eops || result->eops->type != EOT_DB_STRING)
520 nasm_error(ERR_NONFATAL, "`incbin' expects a file name");
521 else if (result->eops->next &&
522 result->eops->next->type != EOT_DB_NUMBER)
523 nasm_error(ERR_NONFATAL, "`incbin': second parameter is"
525 else if (result->eops->next && result->eops->next->next &&
526 result->eops->next->next->type != EOT_DB_NUMBER)
527 nasm_error(ERR_NONFATAL, "`incbin': third parameter is"
529 else if (result->eops->next && result->eops->next->next &&
530 result->eops->next->next->next)
531 nasm_error(ERR_NONFATAL,
532 "`incbin': more than three parameters");
536 * If we reach here, one of the above errors happened.
537 * Throw the instruction away.
539 result->opcode = I_none;
541 } else /* DB ... */ if (oper_num == 0)
542 nasm_error(ERR_WARNING | ERR_PASS1,
543 "no operand for data declaration");
545 result->operands = oper_num;
551 * Now we begin to parse the operands. There may be up to four
552 * of these, separated by commas, and terminated by a zero token.
555 for (operand = 0; operand < MAX_OPERANDS; operand++) {
556 expr *value; /* used most of the time */
557 int mref; /* is this going to be a memory ref? */
558 int bracket; /* is it a [] mref, or a & mref? */
561 result->oprs[operand].disp_size = 0; /* have to zero this whatever */
562 result->oprs[operand].eaflags = 0; /* and this */
563 result->oprs[operand].opflags = 0;
565 i = stdscan(NULL, &tokval);
567 break; /* end of operands: get out of here */
568 else if (first && i == ':') {
569 insn_is_label = true;
573 result->oprs[operand].type = 0; /* so far, no override */
574 while (i == TOKEN_SPECIAL) { /* size specifiers */
575 switch ((int)tokval.t_integer) {
577 if (!setsize) /* we want to use only the first */
578 result->oprs[operand].type |= BITS8;
583 result->oprs[operand].type |= BITS16;
589 result->oprs[operand].type |= BITS32;
594 result->oprs[operand].type |= BITS64;
599 result->oprs[operand].type |= BITS80;
604 result->oprs[operand].type |= BITS128;
609 result->oprs[operand].type |= BITS256;
613 result->oprs[operand].type |= TO;
616 result->oprs[operand].type |= STRICT;
619 result->oprs[operand].type |= FAR;
622 result->oprs[operand].type |= NEAR;
625 result->oprs[operand].type |= SHORT;
628 nasm_error(ERR_NONFATAL, "invalid operand size specification");
630 i = stdscan(NULL, &tokval);
633 if (i == '[' || i == '&') { /* memory reference */
635 bracket = (i == '[');
636 i = stdscan(NULL, &tokval); /* then skip the colon */
637 while (i == TOKEN_SPECIAL || i == TOKEN_PREFIX) {
638 process_size_override(result, operand);
639 i = stdscan(NULL, &tokval);
641 } else { /* immediate operand, or register */
643 bracket = false; /* placate optimisers */
646 if ((result->oprs[operand].type & FAR) && !mref &&
647 result->opcode != I_JMP && result->opcode != I_CALL) {
648 nasm_error(ERR_NONFATAL, "invalid use of FAR operand specifier");
651 value = evaluate(stdscan, NULL, &tokval,
652 &result->oprs[operand].opflags,
653 critical, nasm_error, &hints);
655 if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
656 result->forw_ref = true;
658 if (!value) { /* nasm_error in evaluator */
659 result->opcode = I_none; /* unrecoverable parse error: */
660 return result; /* ignore this instruction */
662 if (i == ':' && mref) { /* it was seg:offset */
664 * Process the segment override.
666 if (value[1].type != 0 ||
668 !IS_SREG(value->type))
669 nasm_error(ERR_NONFATAL, "invalid segment override");
670 else if (result->prefixes[PPS_SEG])
671 nasm_error(ERR_NONFATAL,
672 "instruction has conflicting segment overrides");
674 result->prefixes[PPS_SEG] = value->type;
675 if (IS_FSGS(value->type))
676 result->oprs[operand].eaflags |= EAF_FSGS;
679 i = stdscan(NULL, &tokval); /* then skip the colon */
680 while (i == TOKEN_SPECIAL || i == TOKEN_PREFIX) {
681 process_size_override(result, operand);
682 i = stdscan(NULL, &tokval);
684 value = evaluate(stdscan, NULL, &tokval,
685 &result->oprs[operand].opflags,
686 critical, nasm_error, &hints);
688 if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
689 result->forw_ref = true;
691 /* and get the offset */
692 if (!value) { /* but, error in evaluator */
693 result->opcode = I_none; /* unrecoverable parse error: */
694 return result; /* ignore this instruction */
699 if (mref && bracket) { /* find ] at the end */
701 nasm_error(ERR_NONFATAL, "parser: expecting ]");
703 } else { /* we got the required ] */
704 i = stdscan(NULL, &tokval);
705 if (i != 0 && i != ',') {
706 nasm_error(ERR_NONFATAL, "comma or end of line expected");
710 } else { /* immediate operand */
711 if (i != 0 && i != ',' && i != ':') {
712 nasm_error(ERR_NONFATAL, "comma, colon or end of line expected");
714 } else if (i == ':') {
715 result->oprs[operand].type |= COLON;
719 do { /* error recovery */
720 i = stdscan(NULL, &tokval);
721 } while (i != 0 && i != ',');
725 * now convert the exprs returned from evaluate()
726 * into operand descriptions...
729 if (mref) { /* it's a memory reference */
731 int b, i, s; /* basereg, indexreg, scale */
732 int64_t o; /* offset */
734 b = i = -1, o = s = 0;
735 result->oprs[operand].hintbase = hints.base;
736 result->oprs[operand].hinttype = hints.type;
738 if (e->type && e->type <= EXPR_REG_END) { /* this bit's a register */
739 if (e->value == 1) /* in fact it can be basereg */
741 else /* no, it has to be indexreg */
742 i = e->type, s = e->value;
745 if (e->type && e->type <= EXPR_REG_END) { /* it's a 2nd register */
746 if (b != -1) /* If the first was the base, ... */
747 i = e->type, s = e->value; /* second has to be indexreg */
749 else if (e->value != 1) { /* If both want to be index */
750 nasm_error(ERR_NONFATAL,
751 "beroset-p-592-invalid effective address");
752 result->opcode = I_none;
758 if (e->type != 0) { /* is there an offset? */
759 if (e->type <= EXPR_REG_END) { /* in fact, is there an error? */
760 nasm_error(ERR_NONFATAL,
761 "beroset-p-603-invalid effective address");
762 result->opcode = I_none;
765 if (e->type == EXPR_UNKNOWN) {
766 result->oprs[operand].opflags |= OPFLAG_UNKNOWN;
767 o = 0; /* doesn't matter what */
768 result->oprs[operand].wrt = NO_SEG; /* nor this */
769 result->oprs[operand].segment = NO_SEG; /* or this */
771 e++; /* go to the end of the line */
773 if (e->type == EXPR_SIMPLE) {
777 if (e->type == EXPR_WRT) {
778 result->oprs[operand].wrt = e->value;
781 result->oprs[operand].wrt = NO_SEG;
783 * Look for a segment base type.
785 if (e->type && e->type < EXPR_SEGBASE) {
786 nasm_error(ERR_NONFATAL,
787 "beroset-p-630-invalid effective address");
788 result->opcode = I_none;
791 while (e->type && e->value == 0)
793 if (e->type && e->value != 1) {
794 nasm_error(ERR_NONFATAL,
795 "beroset-p-637-invalid effective address");
796 result->opcode = I_none;
800 result->oprs[operand].segment =
801 e->type - EXPR_SEGBASE;
804 result->oprs[operand].segment = NO_SEG;
805 while (e->type && e->value == 0)
808 nasm_error(ERR_NONFATAL,
809 "beroset-p-650-invalid effective address");
810 result->opcode = I_none;
817 result->oprs[operand].wrt = NO_SEG;
818 result->oprs[operand].segment = NO_SEG;
821 if (e->type != 0) { /* there'd better be nothing left! */
822 nasm_error(ERR_NONFATAL,
823 "beroset-p-663-invalid effective address");
824 result->opcode = I_none;
828 /* It is memory, but it can match any r/m operand */
829 result->oprs[operand].type |= MEMORY_ANY;
831 if (b == -1 && (i == -1 || s == 0)) {
832 int is_rel = globalbits == 64 &&
833 !(result->oprs[operand].eaflags & EAF_ABS) &&
835 !(result->oprs[operand].eaflags & EAF_FSGS)) ||
836 (result->oprs[operand].eaflags & EAF_REL));
838 result->oprs[operand].type |= is_rel ? IP_REL : MEM_OFFS;
840 result->oprs[operand].basereg = b;
841 result->oprs[operand].indexreg = i;
842 result->oprs[operand].scale = s;
843 result->oprs[operand].offset = o;
844 } else { /* it's not a memory reference */
845 if (is_just_unknown(value)) { /* it's immediate but unknown */
846 result->oprs[operand].type |= IMMEDIATE;
847 result->oprs[operand].opflags |= OPFLAG_UNKNOWN;
848 result->oprs[operand].offset = 0; /* don't care */
849 result->oprs[operand].segment = NO_SEG; /* don't care again */
850 result->oprs[operand].wrt = NO_SEG; /* still don't care */
852 if(optimizing >= 0 && !(result->oprs[operand].type & STRICT)) {
854 result->oprs[operand].type |=
855 UNITY | SBYTEWORD | SBYTEDWORD | UDWORD | SDWORD;
857 } else if (is_reloc(value)) { /* it's immediate */
858 result->oprs[operand].type |= IMMEDIATE;
859 result->oprs[operand].offset = reloc_value(value);
860 result->oprs[operand].segment = reloc_seg(value);
861 result->oprs[operand].wrt = reloc_wrt(value);
863 if (is_simple(value)) {
864 uint64_t n = reloc_value(value);
866 result->oprs[operand].type |= UNITY;
867 if (optimizing >= 0 &&
868 !(result->oprs[operand].type & STRICT)) {
869 if ((uint32_t) (n + 128) <= 255)
870 result->oprs[operand].type |= SBYTEDWORD;
871 if ((uint16_t) (n + 128) <= 255)
872 result->oprs[operand].type |= SBYTEWORD;
874 result->oprs[operand].type |= UDWORD;
875 if (n + 0x80000000 <= 0xFFFFFFFF)
876 result->oprs[operand].type |= SDWORD;
879 } else { /* it's a register */
882 if (value->type >= EXPR_SIMPLE || value->value != 1) {
883 nasm_error(ERR_NONFATAL, "invalid operand type");
884 result->opcode = I_none;
889 * check that its only 1 register, not an expression...
891 for (i = 1; value[i].type; i++)
892 if (value[i].value) {
893 nasm_error(ERR_NONFATAL, "invalid operand type");
894 result->opcode = I_none;
898 /* clear overrides, except TO which applies to FPU regs */
899 if (result->oprs[operand].type & ~TO) {
901 * we want to produce a warning iff the specified size
902 * is different from the register size
904 rs = result->oprs[operand].type & SIZE_MASK;
908 result->oprs[operand].type &= TO;
909 result->oprs[operand].type |= REGISTER;
910 result->oprs[operand].type |= nasm_reg_flags[value->type];
911 result->oprs[operand].basereg = value->type;
913 if (rs && (result->oprs[operand].type & SIZE_MASK) != rs)
914 nasm_error(ERR_WARNING | ERR_PASS1,
915 "register size specification ignored");
920 result->operands = operand; /* set operand count */
922 /* clear remaining operands */
923 while (operand < MAX_OPERANDS)
924 result->oprs[operand++].type = 0;
927 * Transform RESW, RESD, RESQ, REST, RESO, RESY into RESB.
929 switch (result->opcode) {
931 result->opcode = I_RESB;
932 result->oprs[0].offset *= 2;
935 result->opcode = I_RESB;
936 result->oprs[0].offset *= 4;
939 result->opcode = I_RESB;
940 result->oprs[0].offset *= 8;
943 result->opcode = I_RESB;
944 result->oprs[0].offset *= 10;
947 result->opcode = I_RESB;
948 result->oprs[0].offset *= 16;
951 result->opcode = I_RESB;
952 result->oprs[0].offset *= 32;
961 static int is_comma_next(void)
968 i = stdscan(NULL, &tv);
971 return (i == ',' || i == ';' || !i);
974 void cleanup_insn(insn * i)
978 while ((e = i->eops)) {
980 if (e->type == EOT_DB_STRING_FREE)
981 nasm_free(e->stringval);