Fix some MMX/SSE irregularities which interact with the 64-bit support
[nasm/avx512.git] / parser.c
blob7e99ba4ca3ae3ab7d1cc12124218ac0c6513574c
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 licence given in the file "Licence"
6 * distributed in the NASM archive.
8 * initial version 27/iii/95 by Simon Tatham
9 */
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <stddef.h>
14 #include <string.h>
15 #include <ctype.h>
16 #include <inttypes.h>
18 #include "nasm.h"
19 #include "insns.h"
20 #include "nasmlib.h"
21 #include "stdscan.h"
22 #include "parser.h"
23 #include "float.h"
25 extern int in_abs_seg; /* ABSOLUTE segment flag */
26 extern int32_t abs_seg; /* ABSOLUTE segment */
27 extern int32_t abs_offset; /* ABSOLUTE segment offset */
29 #include "regflags.c" /* List of register flags */
31 static int is_comma_next(void);
33 static int i;
34 static struct tokenval tokval;
35 static efunc error;
36 static struct ofmt *outfmt; /* Structure of addresses of output routines */
37 static loc_t *location; /* Pointer to current line's segment,offset */
39 void parser_global_info(struct ofmt *output, loc_t * locp)
41 outfmt = output;
42 location = locp;
45 insn *parse_line(int pass, char *buffer, insn * result,
46 efunc errfunc, evalfunc evaluate, ldfunc ldef)
48 int operand;
49 int critical;
50 struct eval_hints hints;
52 result->forw_ref = FALSE;
53 error = errfunc;
55 stdscan_reset();
56 stdscan_bufptr = buffer;
57 i = stdscan(NULL, &tokval);
59 result->label = NULL; /* Assume no label */
60 result->eops = NULL; /* must do this, whatever happens */
61 result->operands = 0; /* must initialize this */
63 if (i == 0) { /* blank line - ignore */
64 result->opcode = -1; /* and no instruction either */
65 return result;
67 if (i != TOKEN_ID && i != TOKEN_INSN && i != TOKEN_PREFIX &&
68 (i != TOKEN_REG || (REG_SREG & ~reg_flags[tokval.t_integer]))) {
69 error(ERR_NONFATAL, "label or instruction expected"
70 " at start of line");
71 result->opcode = -1;
72 return result;
75 if (i == TOKEN_ID) { /* there's a label here */
76 result->label = tokval.t_charptr;
77 i = stdscan(NULL, &tokval);
78 if (i == ':') { /* skip over the optional colon */
79 i = stdscan(NULL, &tokval);
80 } else if (i == 0) {
81 error(ERR_WARNING | ERR_WARN_OL | ERR_PASS1,
82 "label alone on a line without a colon might be in error");
84 if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
86 * FIXME: location->segment could be NO_SEG, in which case
87 * it is possible we should be passing 'abs_seg'. Look into this.
88 * Work out whether that is *really* what we should be doing.
89 * Generally fix things. I think this is right as it is, but
90 * am still not certain.
92 ldef(result->label, in_abs_seg ? abs_seg : location->segment,
93 location->offset, NULL, TRUE, FALSE, outfmt, errfunc);
97 if (i == 0) {
98 result->opcode = -1; /* this line contains just a label */
99 return result;
102 result->nprefix = 0;
103 result->times = 1L;
105 while (i == TOKEN_PREFIX ||
106 (i == TOKEN_REG && !(REG_SREG & ~reg_flags[tokval.t_integer])))
109 * Handle special case: the TIMES prefix.
111 if (i == TOKEN_PREFIX && tokval.t_integer == P_TIMES) {
112 expr *value;
114 i = stdscan(NULL, &tokval);
115 value =
116 evaluate(stdscan, NULL, &tokval, NULL, pass0, error, NULL);
117 i = tokval.t_type;
118 if (!value) { /* but, error in evaluator */
119 result->opcode = -1; /* unrecoverable parse error: */
120 return result; /* ignore this instruction */
122 if (!is_simple(value)) {
123 error(ERR_NONFATAL,
124 "non-constant argument supplied to TIMES");
125 result->times = 1L;
126 } else {
127 result->times = value->value;
128 if (value->value < 0) {
129 error(ERR_NONFATAL, "TIMES value %d is negative",
130 value->value);
131 result->times = 0;
134 } else {
135 if (result->nprefix == MAXPREFIX)
136 error(ERR_NONFATAL,
137 "instruction has more than %d prefixes", MAXPREFIX);
138 else
139 result->prefixes[result->nprefix++] = tokval.t_integer;
140 i = stdscan(NULL, &tokval);
144 if (i != TOKEN_INSN) {
145 if (result->nprefix > 0 && i == 0) {
147 * Instruction prefixes are present, but no actual
148 * instruction. This is allowed: at this point we
149 * invent a notional instruction of RESB 0.
151 result->opcode = I_RESB;
152 result->operands = 1;
153 result->oprs[0].type = IMMEDIATE;
154 result->oprs[0].offset = 0L;
155 result->oprs[0].segment = result->oprs[0].wrt = NO_SEG;
156 return result;
157 } else {
158 error(ERR_NONFATAL, "parser: instruction expected");
159 result->opcode = -1;
160 return result;
164 result->opcode = tokval.t_integer;
165 result->condition = tokval.t_inttwo;
168 * RESB, RESW and RESD cannot be satisfied with incorrectly
169 * evaluated operands, since the correct values _must_ be known
170 * on the first pass. Hence, even in pass one, we set the
171 * `critical' flag on calling evaluate(), so that it will bomb
172 * out on undefined symbols. Nasty, but there's nothing we can
173 * do about it.
175 * For the moment, EQU has the same difficulty, so we'll
176 * include that.
178 if (result->opcode == I_RESB || result->opcode == I_RESW || result->opcode == I_RESD || result->opcode == I_RESQ || result->opcode == I_REST || result->opcode == I_EQU || result->opcode == I_INCBIN) { /* fbk */
179 critical = pass0;
180 } else
181 critical = (pass == 2 ? 2 : 0);
183 if (result->opcode == I_DB ||
184 result->opcode == I_DW ||
185 result->opcode == I_DD ||
186 result->opcode == I_DQ ||
187 result->opcode == I_DT || result->opcode == I_INCBIN) {
188 extop *eop, **tail = &result->eops, **fixptr;
189 int oper_num = 0;
191 result->eops_float = FALSE;
194 * Begin to read the DB/DW/DD/DQ/DT/INCBIN operands.
196 while (1) {
197 i = stdscan(NULL, &tokval);
198 if (i == 0)
199 break;
200 fixptr = tail;
201 eop = *tail = nasm_malloc(sizeof(extop));
202 tail = &eop->next;
203 eop->next = NULL;
204 eop->type = EOT_NOTHING;
205 oper_num++;
207 if (i == TOKEN_NUM && tokval.t_charptr && is_comma_next()) {
208 eop->type = EOT_DB_STRING;
209 eop->stringval = tokval.t_charptr;
210 eop->stringlen = tokval.t_inttwo;
211 i = stdscan(NULL, &tokval); /* eat the comma */
212 continue;
215 if ((i == TOKEN_FLOAT && is_comma_next()) || i == '-') {
216 int32_t sign = +1L;
218 if (i == '-') {
219 char *save = stdscan_bufptr;
220 i = stdscan(NULL, &tokval);
221 sign = -1L;
222 if (i != TOKEN_FLOAT || !is_comma_next()) {
223 stdscan_bufptr = save;
224 i = tokval.t_type = '-';
228 if (i == TOKEN_FLOAT) {
229 eop->type = EOT_DB_STRING;
230 result->eops_float = TRUE;
231 if (result->opcode == I_DD)
232 eop->stringlen = 4;
233 else if (result->opcode == I_DQ)
234 eop->stringlen = 8;
235 else if (result->opcode == I_DT)
236 eop->stringlen = 10;
237 else {
238 error(ERR_NONFATAL, "floating-point constant"
239 " encountered in `D%c' instruction",
240 result->opcode == I_DW ? 'W' : 'B');
242 * fix suggested by Pedro Gimeno... original line
243 * was:
244 * eop->type = EOT_NOTHING;
246 eop->stringlen = 0;
248 eop =
249 nasm_realloc(eop, sizeof(extop) + eop->stringlen);
250 tail = &eop->next;
251 *fixptr = eop;
252 eop->stringval = (char *)eop + sizeof(extop);
253 if (eop->stringlen < 4 ||
254 !float_const(tokval.t_charptr, sign,
255 (uint8_t *)eop->stringval,
256 eop->stringlen, error))
257 eop->type = EOT_NOTHING;
258 i = stdscan(NULL, &tokval); /* eat the comma */
259 continue;
263 /* anything else */
265 expr *value;
266 value = evaluate(stdscan, NULL, &tokval, NULL,
267 critical, error, NULL);
268 i = tokval.t_type;
269 if (!value) { /* error in evaluator */
270 result->opcode = -1; /* unrecoverable parse error: */
271 return result; /* ignore this instruction */
273 if (is_unknown(value)) {
274 eop->type = EOT_DB_NUMBER;
275 eop->offset = 0; /* doesn't matter what we put */
276 eop->segment = eop->wrt = NO_SEG; /* likewise */
277 } else if (is_reloc(value)) {
278 eop->type = EOT_DB_NUMBER;
279 eop->offset = reloc_value(value);
280 eop->segment = reloc_seg(value);
281 eop->wrt = reloc_wrt(value);
282 } else {
283 error(ERR_NONFATAL,
284 "operand %d: expression is not simple"
285 " or relocatable", oper_num);
290 * We're about to call stdscan(), which will eat the
291 * comma that we're currently sitting on between
292 * arguments. However, we'd better check first that it
293 * _is_ a comma.
295 if (i == 0) /* also could be EOL */
296 break;
297 if (i != ',') {
298 error(ERR_NONFATAL, "comma expected after operand %d",
299 oper_num);
300 result->opcode = -1; /* unrecoverable parse error: */
301 return result; /* ignore this instruction */
305 if (result->opcode == I_INCBIN) {
307 * Correct syntax for INCBIN is that there should be
308 * one string operand, followed by one or two numeric
309 * operands.
311 if (!result->eops || result->eops->type != EOT_DB_STRING)
312 error(ERR_NONFATAL, "`incbin' expects a file name");
313 else if (result->eops->next &&
314 result->eops->next->type != EOT_DB_NUMBER)
315 error(ERR_NONFATAL, "`incbin': second parameter is",
316 " non-numeric");
317 else if (result->eops->next && result->eops->next->next &&
318 result->eops->next->next->type != EOT_DB_NUMBER)
319 error(ERR_NONFATAL, "`incbin': third parameter is",
320 " non-numeric");
321 else if (result->eops->next && result->eops->next->next &&
322 result->eops->next->next->next)
323 error(ERR_NONFATAL,
324 "`incbin': more than three parameters");
325 else
326 return result;
328 * If we reach here, one of the above errors happened.
329 * Throw the instruction away.
331 result->opcode = -1;
332 return result;
333 } else /* DB ... */ if (oper_num == 0)
334 error(ERR_WARNING | ERR_PASS1,
335 "no operand for data declaration");
336 else
337 result->operands = oper_num;
339 return result;
342 /* right. Now we begin to parse the operands. There may be up to three
343 * of these, separated by commas, and terminated by a zero token. */
345 for (operand = 0; operand < 3; operand++) {
346 expr *value; /* used most of the time */
347 int mref; /* is this going to be a memory ref? */
348 int bracket; /* is it a [] mref, or a & mref? */
349 int setsize = 0;
351 result->oprs[operand].addr_size = 0; /* have to zero this whatever */
352 result->oprs[operand].eaflags = 0; /* and this */
353 result->oprs[operand].opflags = 0;
355 i = stdscan(NULL, &tokval);
356 if (i == 0)
357 break; /* end of operands: get out of here */
358 result->oprs[operand].type = 0; /* so far, no override */
359 while (i == TOKEN_SPECIAL) { /* size specifiers */
360 switch ((int)tokval.t_integer) {
361 case S_BYTE:
362 if (!setsize) /* we want to use only the first */
363 result->oprs[operand].type |= BITS8;
364 setsize = 1;
365 break;
366 case S_WORD:
367 if (!setsize)
368 result->oprs[operand].type |= BITS16;
369 setsize = 1;
370 break;
371 case S_DWORD:
372 case S_LONG:
373 if (!setsize)
374 result->oprs[operand].type |= BITS32;
375 setsize = 1;
376 break;
377 case S_QWORD:
378 if (!setsize)
379 result->oprs[operand].type |= BITS64;
380 setsize = 1;
381 break;
382 case S_TWORD:
383 if (!setsize)
384 result->oprs[operand].type |= BITS80;
385 setsize = 1;
386 break;
387 case S_TO:
388 result->oprs[operand].type |= TO;
389 break;
390 case S_STRICT:
391 result->oprs[operand].type |= STRICT;
392 break;
393 case S_FAR:
394 result->oprs[operand].type |= FAR;
395 break;
396 case S_NEAR:
397 result->oprs[operand].type |= NEAR;
398 break;
399 case S_SHORT:
400 result->oprs[operand].type |= SHORT;
401 break;
402 default:
403 error(ERR_NONFATAL, "invalid operand size specification");
405 i = stdscan(NULL, &tokval);
408 if (i == '[' || i == '&') { /* memory reference */
409 mref = TRUE;
410 bracket = (i == '[');
411 while ((i = stdscan(NULL, &tokval)) == TOKEN_SPECIAL) {
412 /* check for address directives */
413 if (tasm_compatible_mode) {
414 switch ((int)tokval.t_integer) {
415 /* For TASM compatibility a size override inside the
416 * brackets changes the size of the operand, not the
417 * address type of the operand as it does in standard
418 * NASM syntax. Hence:
420 * mov eax,[DWORD val]
422 * is valid syntax in TASM compatibility mode. Note that
423 * you lose the ability to override the default address
424 * type for the instruction, but we never use anything
425 * but 32-bit flat model addressing in our code.
427 case S_BYTE:
428 result->oprs[operand].type |= BITS8;
429 break;
430 case S_WORD:
431 result->oprs[operand].type |= BITS16;
432 break;
433 case S_DWORD:
434 case S_LONG:
435 result->oprs[operand].type |= BITS32;
436 break;
437 case S_QWORD:
438 result->oprs[operand].type |= BITS64;
439 break;
440 case S_TWORD:
441 result->oprs[operand].type |= BITS80;
442 break;
443 default:
444 error(ERR_NONFATAL,
445 "invalid operand size specification");
447 } else {
448 /* Standard NASM compatible syntax */
449 switch ((int)tokval.t_integer) {
450 case S_NOSPLIT:
451 result->oprs[operand].eaflags |= EAF_TIMESTWO;
452 break;
453 case S_REL:
454 result->oprs[operand].eaflags |= EAF_REL;
455 break;
456 case S_ABS:
457 result->oprs[operand].eaflags |= EAF_ABS;
458 break;
459 case S_BYTE:
460 result->oprs[operand].eaflags |= EAF_BYTEOFFS;
461 break;
462 case S_WORD:
463 result->oprs[operand].addr_size = 16;
464 result->oprs[operand].eaflags |= EAF_WORDOFFS;
465 break;
466 case S_DWORD:
467 case S_LONG:
468 result->oprs[operand].addr_size = 32;
469 result->oprs[operand].eaflags |= EAF_WORDOFFS;
470 break;
471 case S_QWORD:
472 result->oprs[operand].addr_size = 64;
473 result->oprs[operand].eaflags |= EAF_WORDOFFS;
474 break;
475 default:
476 error(ERR_NONFATAL, "invalid size specification in"
477 " effective address");
481 } else { /* immediate operand, or register */
482 mref = FALSE;
483 bracket = FALSE; /* placate optimisers */
486 if ((result->oprs[operand].type & FAR) && !mref &&
487 result->opcode != I_JMP && result->opcode != I_CALL) {
488 error(ERR_NONFATAL, "invalid use of FAR operand specifier");
491 value = evaluate(stdscan, NULL, &tokval,
492 &result->oprs[operand].opflags,
493 critical, error, &hints);
494 i = tokval.t_type;
495 if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
496 result->forw_ref = TRUE;
498 if (!value) { /* error in evaluator */
499 result->opcode = -1; /* unrecoverable parse error: */
500 return result; /* ignore this instruction */
502 if (i == ':' && mref) { /* it was seg:offset */
504 * Process the segment override.
506 if (value[1].type != 0 || value->value != 1 ||
507 REG_SREG & ~reg_flags[value->type])
508 error(ERR_NONFATAL, "invalid segment override");
509 else if (result->nprefix == MAXPREFIX)
510 error(ERR_NONFATAL,
511 "instruction has more than %d prefixes", MAXPREFIX);
512 else {
513 result->prefixes[result->nprefix++] = value->type;
514 if (!(REG_FSGS & ~reg_flags[value->type]))
515 result->oprs[operand].eaflags |= EAF_FSGS;
518 i = stdscan(NULL, &tokval); /* then skip the colon */
519 if (i == TOKEN_SPECIAL) { /* another check for size override */
520 switch ((int)tokval.t_integer) {
521 case S_WORD:
522 result->oprs[operand].addr_size = 16;
523 break;
524 case S_DWORD:
525 case S_LONG:
526 result->oprs[operand].addr_size = 32;
527 break;
528 case S_QWORD:
529 result->oprs[operand].addr_size = 64;
530 break;
531 default:
532 error(ERR_NONFATAL, "invalid size specification in"
533 " effective address");
535 i = stdscan(NULL, &tokval);
537 value = evaluate(stdscan, NULL, &tokval,
538 &result->oprs[operand].opflags,
539 critical, error, &hints);
540 i = tokval.t_type;
541 if (result->oprs[operand].opflags & OPFLAG_FORWARD) {
542 result->forw_ref = TRUE;
544 /* and get the offset */
545 if (!value) { /* but, error in evaluator */
546 result->opcode = -1; /* unrecoverable parse error: */
547 return result; /* ignore this instruction */
550 if (mref && bracket) { /* find ] at the end */
551 if (i != ']') {
552 error(ERR_NONFATAL, "parser: expecting ]");
553 do { /* error recovery again */
554 i = stdscan(NULL, &tokval);
555 } while (i != 0 && i != ',');
556 } else /* we got the required ] */
557 i = stdscan(NULL, &tokval);
558 } else { /* immediate operand */
559 if (i != 0 && i != ',' && i != ':') {
560 error(ERR_NONFATAL, "comma or end of line expected");
561 do { /* error recovery */
562 i = stdscan(NULL, &tokval);
563 } while (i != 0 && i != ',');
564 } else if (i == ':') {
565 result->oprs[operand].type |= COLON;
569 /* now convert the exprs returned from evaluate() into operand
570 * descriptions... */
572 if (mref) { /* it's a memory reference */
573 expr *e = value;
574 int b, i, s; /* basereg, indexreg, scale */
575 int64_t o; /* offset */
577 b = i = -1, o = s = 0;
578 result->oprs[operand].hintbase = hints.base;
579 result->oprs[operand].hinttype = hints.type;
581 if (e->type && e->type <= EXPR_REG_END) { /* this bit's a register */
582 if (e->value == 1) /* in fact it can be basereg */
583 b = e->type;
584 else /* no, it has to be indexreg */
585 i = e->type, s = e->value;
586 e++;
588 if (e->type && e->type <= EXPR_REG_END) { /* it's a 2nd register */
589 if (b != -1) /* If the first was the base, ... */
590 i = e->type, s = e->value; /* second has to be indexreg */
592 else if (e->value != 1) { /* If both want to be index */
593 error(ERR_NONFATAL,
594 "beroset-p-592-invalid effective address");
595 result->opcode = -1;
596 return result;
597 } else
598 b = e->type;
599 e++;
601 if (e->type != 0) { /* is there an offset? */
602 if (e->type <= EXPR_REG_END) { /* in fact, is there an error? */
603 error(ERR_NONFATAL,
604 "beroset-p-603-invalid effective address");
605 result->opcode = -1;
606 return result;
607 } else {
608 if (e->type == EXPR_UNKNOWN) {
609 o = 0; /* doesn't matter what */
610 result->oprs[operand].wrt = NO_SEG; /* nor this */
611 result->oprs[operand].segment = NO_SEG; /* or this */
612 while (e->type)
613 e++; /* go to the end of the line */
614 } else {
615 if (e->type == EXPR_SIMPLE) {
616 o = e->value;
617 e++;
619 if (e->type == EXPR_WRT) {
620 result->oprs[operand].wrt = e->value;
621 e++;
622 } else
623 result->oprs[operand].wrt = NO_SEG;
625 * Look for a segment base type.
627 if (e->type && e->type < EXPR_SEGBASE) {
628 error(ERR_NONFATAL,
629 "beroset-p-630-invalid effective address");
630 result->opcode = -1;
631 return result;
633 while (e->type && e->value == 0)
634 e++;
635 if (e->type && e->value != 1) {
636 error(ERR_NONFATAL,
637 "beroset-p-637-invalid effective address");
638 result->opcode = -1;
639 return result;
641 if (e->type) {
642 result->oprs[operand].segment =
643 e->type - EXPR_SEGBASE;
644 e++;
645 } else
646 result->oprs[operand].segment = NO_SEG;
647 while (e->type && e->value == 0)
648 e++;
649 if (e->type) {
650 error(ERR_NONFATAL,
651 "beroset-p-650-invalid effective address");
652 result->opcode = -1;
653 return result;
657 } else {
658 o = 0;
659 result->oprs[operand].wrt = NO_SEG;
660 result->oprs[operand].segment = NO_SEG;
663 if (e->type != 0) { /* there'd better be nothing left! */
664 error(ERR_NONFATAL,
665 "beroset-p-663-invalid effective address");
666 result->opcode = -1;
667 return result;
670 result->oprs[operand].type |= MEMORY;
672 if (b == -1 && (i == -1 || s == 0)) {
673 int is_rel = globalbits == 64 &&
674 !(result->oprs[operand].eaflags & EAF_ABS) &&
675 ((globalrel &&
676 !(result->oprs[operand].eaflags & EAF_FSGS)) ||
677 (result->oprs[operand].eaflags & EAF_REL));
679 result->oprs[operand].type |= is_rel ? IP_REL : MEM_OFFS;
681 result->oprs[operand].basereg = b;
682 result->oprs[operand].indexreg = i;
683 result->oprs[operand].scale = s;
684 result->oprs[operand].offset = o;
685 } else { /* it's not a memory reference */
687 if (is_just_unknown(value)) { /* it's immediate but unknown */
688 result->oprs[operand].type |= IMMEDIATE;
689 result->oprs[operand].offset = 0; /* don't care */
690 result->oprs[operand].segment = NO_SEG; /* don't care again */
691 result->oprs[operand].wrt = NO_SEG; /* still don't care */
692 } else if (is_reloc(value)) { /* it's immediate */
693 result->oprs[operand].type |= IMMEDIATE;
694 result->oprs[operand].offset = reloc_value(value);
695 result->oprs[operand].segment = reloc_seg(value);
696 result->oprs[operand].wrt = reloc_wrt(value);
697 if (is_simple(value)) {
698 if (reloc_value(value) == 1)
699 result->oprs[operand].type |= UNITY;
700 if (optimizing >= 0 &&
701 !(result->oprs[operand].type & STRICT)) {
702 if (reloc_value(value) >= -128 &&
703 reloc_value(value) <= 127)
704 result->oprs[operand].type |= SBYTE;
707 } else { /* it's a register */
709 if (value->type >= EXPR_SIMPLE || value->value != 1) {
710 error(ERR_NONFATAL, "invalid operand type");
711 result->opcode = -1;
712 return result;
716 * check that its only 1 register, not an expression...
718 for (i = 1; value[i].type; i++)
719 if (value[i].value) {
720 error(ERR_NONFATAL, "invalid operand type");
721 result->opcode = -1;
722 return result;
725 /* clear overrides, except TO which applies to FPU regs */
726 if (result->oprs[operand].type & ~TO) {
728 * we want to produce a warning iff the specified size
729 * is different from the register size
731 i = result->oprs[operand].type & SIZE_MASK;
732 } else
733 i = 0;
735 result->oprs[operand].type &= TO;
736 result->oprs[operand].type |= REGISTER;
737 result->oprs[operand].type |= reg_flags[value->type];
738 result->oprs[operand].basereg = value->type;
740 if (i && (result->oprs[operand].type & SIZE_MASK) != i)
741 error(ERR_WARNING | ERR_PASS1,
742 "register size specification ignored");
747 result->operands = operand; /* set operand count */
749 while (operand < 3) /* clear remaining operands */
750 result->oprs[operand++].type = 0;
753 * Transform RESW, RESD, RESQ, REST into RESB.
755 switch (result->opcode) {
756 case I_RESW:
757 result->opcode = I_RESB;
758 result->oprs[0].offset *= 2;
759 break;
760 case I_RESD:
761 result->opcode = I_RESB;
762 result->oprs[0].offset *= 4;
763 break;
764 case I_RESQ:
765 result->opcode = I_RESB;
766 result->oprs[0].offset *= 8;
767 break;
768 case I_REST:
769 result->opcode = I_RESB;
770 result->oprs[0].offset *= 10;
771 break;
774 return result;
777 static int is_comma_next(void)
779 char *p;
780 int i;
781 struct tokenval tv;
783 p = stdscan_bufptr;
784 i = stdscan(NULL, &tv);
785 stdscan_bufptr = p;
786 return (i == ',' || i == ';' || !i);
789 void cleanup_insn(insn * i)
791 extop *e;
793 while (i->eops) {
794 e = i->eops;
795 i->eops = i->eops->next;
796 nasm_free(e);