1 /* parser.c source line parser for the Netwide Assembler
3 * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
4 * Julian Hall. All rights reserved. The software is
5 * redistributable under the license given in the file "LICENSE"
6 * distributed in the NASM archive.
8 * initial version 27/iii/95 by Simon Tatham
28 extern int in_abs_seg
; /* ABSOLUTE segment flag */
29 extern int32_t abs_seg
; /* ABSOLUTE segment */
30 extern int32_t abs_offset
; /* ABSOLUTE segment offset */
32 static int is_comma_next(void);
35 static struct tokenval tokval
;
37 static struct ofmt
*outfmt
; /* Structure of addresses of output routines */
38 static struct location
*location
; /* Pointer to current line's segment,offset */
40 void parser_global_info(struct ofmt
*output
, struct location
* locp
)
46 static int prefix_slot(enum prefixes prefix
)
74 error(ERR_PANIC
, "Invalid value %d passed to prefix_slot()", prefix
);
79 static void process_size_override(insn
* result
, int operand
)
81 if (tasm_compatible_mode
) {
82 switch ((int)tokval
.t_integer
) {
83 /* For TASM compatibility a size override inside the
84 * brackets changes the size of the operand, not the
85 * address type of the operand as it does in standard
90 * is valid syntax in TASM compatibility mode. Note that
91 * you lose the ability to override the default address
92 * type for the instruction, but we never use anything
93 * but 32-bit flat model addressing in our code.
96 result
->oprs
[operand
].type
|= BITS8
;
99 result
->oprs
[operand
].type
|= BITS16
;
103 result
->oprs
[operand
].type
|= BITS32
;
106 result
->oprs
[operand
].type
|= BITS64
;
109 result
->oprs
[operand
].type
|= BITS80
;
112 result
->oprs
[operand
].type
|= BITS128
;
116 "invalid operand size specification");
120 /* Standard NASM compatible syntax */
121 switch ((int)tokval
.t_integer
) {
123 result
->oprs
[operand
].eaflags
|= EAF_TIMESTWO
;
126 result
->oprs
[operand
].eaflags
|= EAF_REL
;
129 result
->oprs
[operand
].eaflags
|= EAF_ABS
;
132 result
->oprs
[operand
].disp_size
= 8;
133 result
->oprs
[operand
].eaflags
|= EAF_BYTEOFFS
;
138 if (result
->prefixes
[PPS_ASIZE
] &&
139 result
->prefixes
[PPS_ASIZE
] != tokval
.t_integer
)
141 "conflicting address size specifications");
143 result
->prefixes
[PPS_ASIZE
] = tokval
.t_integer
;
146 result
->oprs
[operand
].disp_size
= 16;
147 result
->oprs
[operand
].eaflags
|= EAF_WORDOFFS
;
151 result
->oprs
[operand
].disp_size
= 32;
152 result
->oprs
[operand
].eaflags
|= EAF_WORDOFFS
;
155 result
->oprs
[operand
].disp_size
= 64;
156 result
->oprs
[operand
].eaflags
|= EAF_WORDOFFS
;
159 error(ERR_NONFATAL
, "invalid size specification in"
160 " effective address");
166 insn
*parse_line(int pass
, char *buffer
, insn
* result
,
167 efunc errfunc
, evalfunc evaluate
, ldfunc ldef
)
171 struct eval_hints hints
;
174 bool insn_is_label
= false;
178 result
->forw_ref
= false;
182 stdscan_bufptr
= buffer
;
183 i
= stdscan(NULL
, &tokval
);
185 result
->label
= NULL
; /* Assume no label */
186 result
->eops
= NULL
; /* must do this, whatever happens */
187 result
->operands
= 0; /* must initialize this */
189 if (i
== 0) { /* blank line - ignore */
190 result
->opcode
= -1; /* and no instruction either */
193 if (i
!= TOKEN_ID
&& i
!= TOKEN_INSN
&& i
!= TOKEN_PREFIX
&&
194 (i
!= TOKEN_REG
|| (REG_SREG
& ~nasm_reg_flags
[tokval
.t_integer
]))) {
195 error(ERR_NONFATAL
, "label or instruction expected"
196 " at start of line");
201 if (i
== TOKEN_ID
|| (insn_is_label
&& i
== TOKEN_INSN
)) {
202 /* there's a label here */
204 result
->label
= tokval
.t_charptr
;
205 i
= stdscan(NULL
, &tokval
);
206 if (i
== ':') { /* skip over the optional colon */
207 i
= stdscan(NULL
, &tokval
);
209 error(ERR_WARNING
| ERR_WARN_OL
| ERR_PASS1
,
210 "label alone on a line without a colon might be in error");
212 if (i
!= TOKEN_INSN
|| tokval
.t_integer
!= I_EQU
) {
214 * FIXME: location->segment could be NO_SEG, in which case
215 * it is possible we should be passing 'abs_seg'. Look into this.
216 * Work out whether that is *really* what we should be doing.
217 * Generally fix things. I think this is right as it is, but
218 * am still not certain.
220 ldef(result
->label
, in_abs_seg
? abs_seg
: location
->segment
,
221 location
->offset
, NULL
, true, false, outfmt
, errfunc
);
226 result
->opcode
= -1; /* this line contains just a label */
230 for (j
= 0; j
< MAXPREFIX
; j
++)
231 result
->prefixes
[j
] = P_none
;
234 while (i
== TOKEN_PREFIX
||
235 (i
== TOKEN_REG
&& !(REG_SREG
& ~nasm_reg_flags
[tokval
.t_integer
])))
240 * Handle special case: the TIMES prefix.
242 if (i
== TOKEN_PREFIX
&& tokval
.t_integer
== P_TIMES
) {
245 i
= stdscan(NULL
, &tokval
);
247 evaluate(stdscan
, NULL
, &tokval
, NULL
, pass0
, error
, NULL
);
249 if (!value
) { /* but, error in evaluator */
250 result
->opcode
= -1; /* unrecoverable parse error: */
251 return result
; /* ignore this instruction */
253 if (!is_simple(value
)) {
255 "non-constant argument supplied to TIMES");
258 result
->times
= value
->value
;
259 if (value
->value
< 0 && pass0
== 2) {
260 error(ERR_NONFATAL
, "TIMES value %d is negative",
266 int slot
= prefix_slot(tokval
.t_integer
);
267 if (result
->prefixes
[slot
]) {
268 if (result
->prefixes
[slot
] == tokval
.t_integer
)
270 "instruction has redundant prefixes");
273 "instruction has conflicting prefixes");
275 result
->prefixes
[slot
] = tokval
.t_integer
;
276 i
= stdscan(NULL
, &tokval
);
280 if (i
!= TOKEN_INSN
) {
284 for (j
= 0; j
< MAXPREFIX
; j
++)
285 if ((pfx
= result
->prefixes
[j
]) != P_none
)
288 if (i
== 0 && pfx
!= P_none
) {
290 * Instruction prefixes are present, but no actual
291 * instruction. This is allowed: at this point we
292 * invent a notional instruction of RESB 0.
294 result
->opcode
= I_RESB
;
295 result
->operands
= 1;
296 result
->oprs
[0].type
= IMMEDIATE
;
297 result
->oprs
[0].offset
= 0L;
298 result
->oprs
[0].segment
= result
->oprs
[0].wrt
= NO_SEG
;
301 error(ERR_NONFATAL
, "parser: instruction expected");
307 result
->opcode
= tokval
.t_integer
;
308 result
->condition
= tokval
.t_inttwo
;
311 * INCBIN cannot be satisfied with incorrectly
312 * evaluated operands, since the correct values _must_ be known
313 * on the first pass. Hence, even in pass one, we set the
314 * `critical' flag on calling evaluate(), so that it will bomb
315 * out on undefined symbols.
317 if (result
->opcode
== I_INCBIN
) {
318 critical
= (pass0
< 2 ? 1 : 2);
321 critical
= (pass
== 2 ? 2 : 0);
323 if (result
->opcode
== I_DB
|| result
->opcode
== I_DW
||
324 result
->opcode
== I_DD
|| result
->opcode
== I_DQ
||
325 result
->opcode
== I_DT
|| result
->opcode
== I_DO
||
326 result
->opcode
== I_DY
|| result
->opcode
== I_INCBIN
) {
327 extop
*eop
, **tail
= &result
->eops
, **fixptr
;
331 result
->eops_float
= false;
334 * Begin to read the DB/DW/DD/DQ/DT/DO/INCBIN operands.
337 i
= stdscan(NULL
, &tokval
);
340 else if (first
&& i
== ':') {
341 insn_is_label
= true;
346 eop
= *tail
= nasm_malloc(sizeof(extop
));
349 eop
->type
= EOT_NOTHING
;
353 /* is_comma_next() here is to distinguish this from
354 a string used as part of an expression... */
355 if (i
== TOKEN_STR
&& is_comma_next()) {
356 eop
->type
= EOT_DB_STRING
;
357 eop
->stringval
= tokval
.t_charptr
;
358 eop
->stringlen
= tokval
.t_inttwo
;
359 i
= stdscan(NULL
, &tokval
); /* eat the comma */
360 } else if (i
== TOKEN_STRFUNC
) {
362 const char *funcname
= tokval
.t_charptr
;
363 enum strfunc func
= tokval
.t_integer
;
364 i
= stdscan(NULL
, &tokval
);
367 i
= stdscan(NULL
, &tokval
);
369 if (i
!= TOKEN_STR
) {
371 "%s must be followed by a string constant",
373 eop
->type
= EOT_NOTHING
;
375 eop
->type
= EOT_DB_STRING_FREE
;
377 string_transform(tokval
.t_charptr
, tokval
.t_inttwo
,
378 &eop
->stringval
, func
);
379 if (eop
->stringlen
== (size_t)-1) {
380 error(ERR_NONFATAL
, "invalid string for transform");
381 eop
->type
= EOT_NOTHING
;
384 if (parens
&& i
&& i
!= ')') {
385 i
= stdscan(NULL
, &tokval
);
387 error(ERR_NONFATAL
, "unterminated %s function",
392 i
= stdscan(NULL
, &tokval
);
393 } else if (i
== '-' || i
== '+') {
394 char *save
= stdscan_bufptr
;
396 sign
= (i
== '-') ? -1 : 1;
397 i
= stdscan(NULL
, &tokval
);
398 if (i
!= TOKEN_FLOAT
) {
399 stdscan_bufptr
= save
;
400 i
= tokval
.t_type
= token
;
405 } else if (i
== TOKEN_FLOAT
) {
407 eop
->type
= EOT_DB_STRING
;
408 result
->eops_float
= true;
409 switch (result
->opcode
) {
429 error(ERR_NONFATAL
, "floating-point constant"
430 " encountered in DY instruction");
434 error(ERR_NONFATAL
, "floating-point constant"
435 " encountered in unknown instruction");
437 * fix suggested by Pedro Gimeno... original line
439 * eop->type = EOT_NOTHING;
444 eop
= nasm_realloc(eop
, sizeof(extop
) + eop
->stringlen
);
447 eop
->stringval
= (char *)eop
+ sizeof(extop
);
448 if (!eop
->stringlen
||
449 !float_const(tokval
.t_charptr
, sign
,
450 (uint8_t *)eop
->stringval
,
451 eop
->stringlen
, error
))
452 eop
->type
= EOT_NOTHING
;
453 i
= stdscan(NULL
, &tokval
); /* eat the comma */
455 /* anything else, assume it is an expression */
459 value
= evaluate(stdscan
, NULL
, &tokval
, NULL
,
460 critical
, error
, NULL
);
462 if (!value
) { /* error in evaluator */
463 result
->opcode
= -1; /* unrecoverable parse error: */
464 return result
; /* ignore this instruction */
466 if (is_unknown(value
)) {
467 eop
->type
= EOT_DB_NUMBER
;
468 eop
->offset
= 0; /* doesn't matter what we put */
469 eop
->segment
= eop
->wrt
= NO_SEG
; /* likewise */
470 } else if (is_reloc(value
)) {
471 eop
->type
= EOT_DB_NUMBER
;
472 eop
->offset
= reloc_value(value
);
473 eop
->segment
= reloc_seg(value
);
474 eop
->wrt
= reloc_wrt(value
);
477 "operand %d: expression is not simple"
478 " or relocatable", oper_num
);
483 * We're about to call stdscan(), which will eat the
484 * comma that we're currently sitting on between
485 * arguments. However, we'd better check first that it
488 if (i
== 0) /* also could be EOL */
491 error(ERR_NONFATAL
, "comma expected after operand %d",
493 result
->opcode
= -1; /* unrecoverable parse error: */
494 return result
; /* ignore this instruction */
498 if (result
->opcode
== I_INCBIN
) {
500 * Correct syntax for INCBIN is that there should be
501 * one string operand, followed by one or two numeric
504 if (!result
->eops
|| result
->eops
->type
!= EOT_DB_STRING
)
505 error(ERR_NONFATAL
, "`incbin' expects a file name");
506 else if (result
->eops
->next
&&
507 result
->eops
->next
->type
!= EOT_DB_NUMBER
)
508 error(ERR_NONFATAL
, "`incbin': second parameter is",
510 else if (result
->eops
->next
&& result
->eops
->next
->next
&&
511 result
->eops
->next
->next
->type
!= EOT_DB_NUMBER
)
512 error(ERR_NONFATAL
, "`incbin': third parameter is",
514 else if (result
->eops
->next
&& result
->eops
->next
->next
&&
515 result
->eops
->next
->next
->next
)
517 "`incbin': more than three parameters");
521 * If we reach here, one of the above errors happened.
522 * Throw the instruction away.
526 } else /* DB ... */ if (oper_num
== 0)
527 error(ERR_WARNING
| ERR_PASS1
,
528 "no operand for data declaration");
530 result
->operands
= oper_num
;
535 /* right. Now we begin to parse the operands. There may be up to four
536 * of these, separated by commas, and terminated by a zero token. */
538 for (operand
= 0; operand
< MAX_OPERANDS
; operand
++) {
539 expr
*value
; /* used most of the time */
540 int mref
; /* is this going to be a memory ref? */
541 int bracket
; /* is it a [] mref, or a & mref? */
544 result
->oprs
[operand
].disp_size
= 0; /* have to zero this whatever */
545 result
->oprs
[operand
].eaflags
= 0; /* and this */
546 result
->oprs
[operand
].opflags
= 0;
548 i
= stdscan(NULL
, &tokval
);
550 break; /* end of operands: get out of here */
551 else if (first
&& i
== ':') {
552 insn_is_label
= true;
556 result
->oprs
[operand
].type
= 0; /* so far, no override */
557 while (i
== TOKEN_SPECIAL
) { /* size specifiers */
558 switch ((int)tokval
.t_integer
) {
560 if (!setsize
) /* we want to use only the first */
561 result
->oprs
[operand
].type
|= BITS8
;
566 result
->oprs
[operand
].type
|= BITS16
;
572 result
->oprs
[operand
].type
|= BITS32
;
577 result
->oprs
[operand
].type
|= BITS64
;
582 result
->oprs
[operand
].type
|= BITS80
;
587 result
->oprs
[operand
].type
|= BITS128
;
592 result
->oprs
[operand
].type
|= BITS256
;
596 result
->oprs
[operand
].type
|= TO
;
599 result
->oprs
[operand
].type
|= STRICT
;
602 result
->oprs
[operand
].type
|= FAR
;
605 result
->oprs
[operand
].type
|= NEAR
;
608 result
->oprs
[operand
].type
|= SHORT
;
611 error(ERR_NONFATAL
, "invalid operand size specification");
613 i
= stdscan(NULL
, &tokval
);
616 if (i
== '[' || i
== '&') { /* memory reference */
618 bracket
= (i
== '[');
619 i
= stdscan(NULL
, &tokval
); /* then skip the colon */
620 while (i
== TOKEN_SPECIAL
|| i
== TOKEN_PREFIX
) {
621 process_size_override(result
, operand
);
622 i
= stdscan(NULL
, &tokval
);
624 } else { /* immediate operand, or register */
626 bracket
= false; /* placate optimisers */
629 if ((result
->oprs
[operand
].type
& FAR
) && !mref
&&
630 result
->opcode
!= I_JMP
&& result
->opcode
!= I_CALL
) {
631 error(ERR_NONFATAL
, "invalid use of FAR operand specifier");
634 value
= evaluate(stdscan
, NULL
, &tokval
,
635 &result
->oprs
[operand
].opflags
,
636 critical
, error
, &hints
);
638 if (result
->oprs
[operand
].opflags
& OPFLAG_FORWARD
) {
639 result
->forw_ref
= true;
641 if (!value
) { /* error in evaluator */
642 result
->opcode
= -1; /* unrecoverable parse error: */
643 return result
; /* ignore this instruction */
645 if (i
== ':' && mref
) { /* it was seg:offset */
647 * Process the segment override.
649 if (value
[1].type
!= 0 || value
->value
!= 1 ||
650 REG_SREG
& ~nasm_reg_flags
[value
->type
])
651 error(ERR_NONFATAL
, "invalid segment override");
652 else if (result
->prefixes
[PPS_SEG
])
654 "instruction has conflicting segment overrides");
656 result
->prefixes
[PPS_SEG
] = value
->type
;
657 if (!(REG_FSGS
& ~nasm_reg_flags
[value
->type
]))
658 result
->oprs
[operand
].eaflags
|= EAF_FSGS
;
661 i
= stdscan(NULL
, &tokval
); /* then skip the colon */
662 while (i
== TOKEN_SPECIAL
|| i
== TOKEN_PREFIX
) {
663 process_size_override(result
, operand
);
664 i
= stdscan(NULL
, &tokval
);
666 value
= evaluate(stdscan
, NULL
, &tokval
,
667 &result
->oprs
[operand
].opflags
,
668 critical
, error
, &hints
);
670 if (result
->oprs
[operand
].opflags
& OPFLAG_FORWARD
) {
671 result
->forw_ref
= true;
673 /* and get the offset */
674 if (!value
) { /* but, error in evaluator */
675 result
->opcode
= -1; /* unrecoverable parse error: */
676 return result
; /* ignore this instruction */
679 if (mref
&& bracket
) { /* find ] at the end */
681 error(ERR_NONFATAL
, "parser: expecting ]");
682 do { /* error recovery again */
683 i
= stdscan(NULL
, &tokval
);
684 } while (i
!= 0 && i
!= ',');
685 } else /* we got the required ] */
686 i
= stdscan(NULL
, &tokval
);
687 } else { /* immediate operand */
688 if (i
!= 0 && i
!= ',' && i
!= ':') {
689 error(ERR_NONFATAL
, "comma or end of line expected");
690 do { /* error recovery */
691 i
= stdscan(NULL
, &tokval
);
692 } while (i
!= 0 && i
!= ',');
693 } else if (i
== ':') {
694 result
->oprs
[operand
].type
|= COLON
;
698 /* now convert the exprs returned from evaluate() into operand
701 if (mref
) { /* it's a memory reference */
703 int b
, i
, s
; /* basereg, indexreg, scale */
704 int64_t o
; /* offset */
706 b
= i
= -1, o
= s
= 0;
707 result
->oprs
[operand
].hintbase
= hints
.base
;
708 result
->oprs
[operand
].hinttype
= hints
.type
;
710 if (e
->type
&& e
->type
<= EXPR_REG_END
) { /* this bit's a register */
711 if (e
->value
== 1) /* in fact it can be basereg */
713 else /* no, it has to be indexreg */
714 i
= e
->type
, s
= e
->value
;
717 if (e
->type
&& e
->type
<= EXPR_REG_END
) { /* it's a 2nd register */
718 if (b
!= -1) /* If the first was the base, ... */
719 i
= e
->type
, s
= e
->value
; /* second has to be indexreg */
721 else if (e
->value
!= 1) { /* If both want to be index */
723 "beroset-p-592-invalid effective address");
730 if (e
->type
!= 0) { /* is there an offset? */
731 if (e
->type
<= EXPR_REG_END
) { /* in fact, is there an error? */
733 "beroset-p-603-invalid effective address");
737 if (e
->type
== EXPR_UNKNOWN
) {
738 o
= 0; /* doesn't matter what */
739 result
->oprs
[operand
].wrt
= NO_SEG
; /* nor this */
740 result
->oprs
[operand
].segment
= NO_SEG
; /* or this */
742 e
++; /* go to the end of the line */
744 if (e
->type
== EXPR_SIMPLE
) {
748 if (e
->type
== EXPR_WRT
) {
749 result
->oprs
[operand
].wrt
= e
->value
;
752 result
->oprs
[operand
].wrt
= NO_SEG
;
754 * Look for a segment base type.
756 if (e
->type
&& e
->type
< EXPR_SEGBASE
) {
758 "beroset-p-630-invalid effective address");
762 while (e
->type
&& e
->value
== 0)
764 if (e
->type
&& e
->value
!= 1) {
766 "beroset-p-637-invalid effective address");
771 result
->oprs
[operand
].segment
=
772 e
->type
- EXPR_SEGBASE
;
775 result
->oprs
[operand
].segment
= NO_SEG
;
776 while (e
->type
&& e
->value
== 0)
780 "beroset-p-650-invalid effective address");
788 result
->oprs
[operand
].wrt
= NO_SEG
;
789 result
->oprs
[operand
].segment
= NO_SEG
;
792 if (e
->type
!= 0) { /* there'd better be nothing left! */
794 "beroset-p-663-invalid effective address");
799 /* It is memory, but it can match any r/m operand */
800 result
->oprs
[operand
].type
|= MEMORY_ANY
;
802 if (b
== -1 && (i
== -1 || s
== 0)) {
803 int is_rel
= globalbits
== 64 &&
804 !(result
->oprs
[operand
].eaflags
& EAF_ABS
) &&
806 !(result
->oprs
[operand
].eaflags
& EAF_FSGS
)) ||
807 (result
->oprs
[operand
].eaflags
& EAF_REL
));
809 result
->oprs
[operand
].type
|= is_rel
? IP_REL
: MEM_OFFS
;
811 result
->oprs
[operand
].basereg
= b
;
812 result
->oprs
[operand
].indexreg
= i
;
813 result
->oprs
[operand
].scale
= s
;
814 result
->oprs
[operand
].offset
= o
;
815 } else { /* it's not a memory reference */
817 if (is_just_unknown(value
)) { /* it's immediate but unknown */
818 result
->oprs
[operand
].type
|= IMMEDIATE
;
819 result
->oprs
[operand
].offset
= 0; /* don't care */
820 result
->oprs
[operand
].segment
= NO_SEG
; /* don't care again */
821 result
->oprs
[operand
].wrt
= NO_SEG
; /* still don't care */
822 } else if (is_reloc(value
)) { /* it's immediate */
823 result
->oprs
[operand
].type
|= IMMEDIATE
;
824 result
->oprs
[operand
].offset
= reloc_value(value
);
825 result
->oprs
[operand
].segment
= reloc_seg(value
);
826 result
->oprs
[operand
].wrt
= reloc_wrt(value
);
827 if (is_simple(value
)) {
828 if (reloc_value(value
) == 1)
829 result
->oprs
[operand
].type
|= UNITY
;
830 if (optimizing
>= 0 &&
831 !(result
->oprs
[operand
].type
& STRICT
)) {
832 int64_t v64
= reloc_value(value
);
833 int32_t v32
= (int32_t)v64
;
834 int16_t v16
= (int16_t)v32
;
836 if (v64
>= -128 && v64
<= 127)
837 result
->oprs
[operand
].type
|= SBYTE64
;
838 if (v32
>= -128 && v32
<= 127)
839 result
->oprs
[operand
].type
|= SBYTE32
;
840 if (v16
>= -128 && v16
<= 127)
841 result
->oprs
[operand
].type
|= SBYTE16
;
844 } else { /* it's a register */
847 if (value
->type
>= EXPR_SIMPLE
|| value
->value
!= 1) {
848 error(ERR_NONFATAL
, "invalid operand type");
854 * check that its only 1 register, not an expression...
856 for (i
= 1; value
[i
].type
; i
++)
857 if (value
[i
].value
) {
858 error(ERR_NONFATAL
, "invalid operand type");
863 /* clear overrides, except TO which applies to FPU regs */
864 if (result
->oprs
[operand
].type
& ~TO
) {
866 * we want to produce a warning iff the specified size
867 * is different from the register size
869 rs
= result
->oprs
[operand
].type
& SIZE_MASK
;
873 result
->oprs
[operand
].type
&= TO
;
874 result
->oprs
[operand
].type
|= REGISTER
;
875 result
->oprs
[operand
].type
|= nasm_reg_flags
[value
->type
];
876 result
->oprs
[operand
].basereg
= value
->type
;
878 if (rs
&& (result
->oprs
[operand
].type
& SIZE_MASK
) != rs
)
879 error(ERR_WARNING
| ERR_PASS1
,
880 "register size specification ignored");
885 result
->operands
= operand
; /* set operand count */
887 /* clear remaining operands */
888 while (operand
< MAX_OPERANDS
)
889 result
->oprs
[operand
++].type
= 0;
892 * Transform RESW, RESD, RESQ, REST, RESO, RESY into RESB.
894 switch (result
->opcode
) {
896 result
->opcode
= I_RESB
;
897 result
->oprs
[0].offset
*= 2;
900 result
->opcode
= I_RESB
;
901 result
->oprs
[0].offset
*= 4;
904 result
->opcode
= I_RESB
;
905 result
->oprs
[0].offset
*= 8;
908 result
->opcode
= I_RESB
;
909 result
->oprs
[0].offset
*= 10;
912 result
->opcode
= I_RESB
;
913 result
->oprs
[0].offset
*= 16;
916 result
->opcode
= I_RESB
;
917 result
->oprs
[0].offset
*= 32;
926 static int is_comma_next(void)
933 i
= stdscan(NULL
, &tv
);
935 return (i
== ',' || i
== ';' || !i
);
938 void cleanup_insn(insn
* i
)
942 while ((e
= i
->eops
)) {
944 if (e
->type
== EOT_DB_STRING_FREE
)
945 nasm_free(e
->stringval
);