github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/src/cmd/8a/lex.c (about)

     1  // Inferno utils/8a/lex.c
     2  // http://code.google.com/p/inferno-os/source/browse/utils/8a/lex.c
     3  //
     4  //	Copyright © 1994-1999 Lucent Technologies Inc.	All rights reserved.
     5  //	Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
     6  //	Portions Copyright © 1997-1999 Vita Nuova Limited
     7  //	Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
     8  //	Portions Copyright © 2004,2006 Bruce Ellis
     9  //	Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
    10  //	Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
    11  //	Portions Copyright © 2009 The Go Authors.  All rights reserved.
    12  //
    13  // Permission is hereby granted, free of charge, to any person obtaining a copy
    14  // of this software and associated documentation files (the "Software"), to deal
    15  // in the Software without restriction, including without limitation the rights
    16  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    17  // copies of the Software, and to permit persons to whom the Software is
    18  // furnished to do so, subject to the following conditions:
    19  //
    20  // The above copyright notice and this permission notice shall be included in
    21  // all copies or substantial portions of the Software.
    22  //
    23  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    24  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    25  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    26  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    27  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    28  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    29  // THE SOFTWARE.
    30  
    31  #define	EXTERN
    32  #include <u.h>
    33  #include <libc.h>
    34  #include "a.h"
    35  #include "y.tab.h"
    36  
    37  enum
    38  {
    39  	Plan9	= 1<<0,
    40  	Unix	= 1<<1,
    41  	Windows	= 1<<2,
    42  };
    43  
    44  int
    45  systemtype(int sys)
    46  {
    47  #ifdef _WIN32
    48  	return sys&Windows;
    49  #else
    50  	return sys&Plan9;
    51  #endif
    52  }
    53  
    54  int
    55  pathchar(void)
    56  {
    57  	return '/';
    58  }
    59  
    60  int
    61  Lconv(Fmt *fp)
    62  {
    63  	return linklinefmt(ctxt, fp);
    64  }
    65  
    66  void
    67  dodef(char *p)
    68  {
    69  	if(nDlist%8 == 0)
    70  		Dlist = allocn(Dlist, nDlist*sizeof(char *),
    71  			8*sizeof(char *));
    72  	Dlist[nDlist++] = p;
    73  }
    74  
    75  void
    76  usage(void)
    77  {
    78  	print("usage: %ca [options] file.c...\n", thechar);
    79  	flagprint(1);
    80  	errorexit();
    81  }
    82  void
    83  main(int argc, char *argv[])
    84  {
    85  	char *p;
    86  
    87  	thechar = '8';
    88  	thestring = "386";
    89  
    90  	ctxt = linknew(&link386);
    91  	ctxt->diag = yyerror;
    92  	ctxt->bso = &bstdout;
    93  	ctxt->enforce_data_order = 1;
    94  	Binit(&bstdout, 1, OWRITE);
    95  	listinit8();
    96  	fmtinstall('L', Lconv);
    97  
    98  	// Allow GOARCH=thestring or GOARCH=thestringsuffix,
    99  	// but not other values.	
   100  	p = getgoarch();
   101  	if(strncmp(p, thestring, strlen(thestring)) != 0)
   102  		sysfatal("cannot use %cc with GOARCH=%s", thechar, p);
   103  
   104  	ensuresymb(NSYMB);
   105  	memset(debug, 0, sizeof(debug));
   106  	cinit();
   107  	outfile = 0;
   108  	setinclude(".");
   109  	
   110  	flagfn1("D", "name[=value]: add #define", dodef);
   111  	flagfn1("I", "dir: add dir to include path", setinclude);
   112  	flagcount("S", "print assembly and machine code", &debug['S']);
   113  	flagcount("m", "debug preprocessor macros", &debug['m']);
   114  	flagstr("o", "file: set output file", &outfile);
   115  	flagstr("trimpath", "prefix: remove prefix from recorded source file paths", &ctxt->trimpath);
   116  
   117  	flagparse(&argc, &argv, usage);
   118  	ctxt->debugasm = debug['S'];
   119  
   120  	if(argc < 1)
   121  		usage();
   122  	if(argc > 1){
   123  		print("can't assemble multiple files\n");
   124  		errorexit();
   125  	}
   126  
   127  	if(assemble(argv[0]))
   128  		errorexit();
   129  	Bflush(&bstdout);
   130  	exits(0);
   131  }
   132  
   133  int
   134  assemble(char *file)
   135  {
   136  	char *ofile, *p;
   137  	int i, of;
   138  
   139  	ofile = alloc(strlen(file)+3); // +3 for .x\0 (x=thechar)
   140  	strcpy(ofile, file);
   141  	p = utfrrune(ofile, pathchar());
   142  	if(p) {
   143  		include[0] = ofile;
   144  		*p++ = 0;
   145  	} else
   146  		p = ofile;
   147  	if(outfile == 0) {
   148  		outfile = p;
   149  		if(outfile){
   150  			p = utfrrune(outfile, '.');
   151  			if(p)
   152  				if(p[1] == 's' && p[2] == 0)
   153  					p[0] = 0;
   154  			p = utfrune(outfile, 0);
   155  			p[0] = '.';
   156  			p[1] = thechar;
   157  			p[2] = 0;
   158  		} else
   159  			outfile = "/dev/null";
   160  	}
   161  
   162  	of = create(outfile, OWRITE, 0664);
   163  	if(of < 0) {
   164  		yyerror("%ca: cannot create %s", thechar, outfile);
   165  		errorexit();
   166  	}
   167  	Binit(&obuf, of, OWRITE);
   168  	Bprint(&obuf, "go object %s %s %s\n", getgoos(), getgoarch(), getgoversion());
   169  	Bprint(&obuf, "!\n");
   170  
   171  	for(pass = 1; pass <= 2; pass++) {
   172  		pinit(file);
   173  		for(i=0; i<nDlist; i++)
   174  			dodefine(Dlist[i]);
   175  		yyparse();
   176  		cclean();
   177  		if(nerrors)
   178  			return nerrors;
   179  	}
   180  
   181  	writeobj(ctxt, &obuf);
   182  	Bflush(&obuf);
   183  	return 0;
   184  }
   185  
   186  struct
   187  {
   188  	char	*name;
   189  	ushort	type;
   190  	ushort	value;
   191  } itab[] =
   192  {
   193  	"SP",		LSP,	D_AUTO,
   194  	"SB",		LSB,	D_EXTERN,
   195  	"FP",		LFP,	D_PARAM,
   196  	"PC",		LPC,	D_BRANCH,
   197  
   198  	"AL",		LBREG,	D_AL,
   199  	"CL",		LBREG,	D_CL,
   200  	"DL",		LBREG,	D_DL,
   201  	"BL",		LBREG,	D_BL,
   202  	"AH",		LBREG,	D_AH,
   203  	"CH",		LBREG,	D_CH,
   204  	"DH",		LBREG,	D_DH,
   205  	"BH",		LBREG,	D_BH,
   206  
   207  	"AX",		LLREG,	D_AX,
   208  	"CX",		LLREG,	D_CX,
   209  	"DX",		LLREG,	D_DX,
   210  	"BX",		LLREG,	D_BX,
   211  /*	"SP",		LLREG,	D_SP,	*/
   212  	"BP",		LLREG,	D_BP,
   213  	"SI",		LLREG,	D_SI,
   214  	"DI",		LLREG,	D_DI,
   215  
   216  	"F0",		LFREG,	D_F0+0,
   217  	"F1",		LFREG,	D_F0+1,
   218  	"F2",		LFREG,	D_F0+2,
   219  	"F3",		LFREG,	D_F0+3,
   220  	"F4",		LFREG,	D_F0+4,
   221  	"F5",		LFREG,	D_F0+5,
   222  	"F6",		LFREG,	D_F0+6,
   223  	"F7",		LFREG,	D_F0+7,
   224  
   225  	"X0",		LXREG,	D_X0+0,
   226  	"X1",		LXREG,	D_X0+1,
   227  	"X2",		LXREG,	D_X0+2,
   228  	"X3",		LXREG,	D_X0+3,
   229  	"X4",		LXREG,	D_X0+4,
   230  	"X5",		LXREG,	D_X0+5,
   231  	"X6",		LXREG,	D_X0+6,
   232  	"X7",		LXREG,	D_X0+7,
   233  
   234  	"CS",		LSREG,	D_CS,
   235  	"SS",		LSREG,	D_SS,
   236  	"DS",		LSREG,	D_DS,
   237  	"ES",		LSREG,	D_ES,
   238  	"FS",		LSREG,	D_FS,
   239  	"GS",		LSREG,	D_GS,
   240  	"TLS",		LSREG,	D_TLS,
   241  
   242  	"GDTR",		LBREG,	D_GDTR,
   243  	"IDTR",		LBREG,	D_IDTR,
   244  	"LDTR",		LBREG,	D_LDTR,
   245  	"MSW",		LBREG,	D_MSW,
   246  	"TASK",		LBREG,	D_TASK,
   247  
   248  	"CR0",		LBREG,	D_CR+0,
   249  	"CR1",		LBREG,	D_CR+1,
   250  	"CR2",		LBREG,	D_CR+2,
   251  	"CR3",		LBREG,	D_CR+3,
   252  	"CR4",		LBREG,	D_CR+4,
   253  	"CR5",		LBREG,	D_CR+5,
   254  	"CR6",		LBREG,	D_CR+6,
   255  	"CR7",		LBREG,	D_CR+7,
   256  
   257  	"DR0",		LBREG,	D_DR+0,
   258  	"DR1",		LBREG,	D_DR+1,
   259  	"DR2",		LBREG,	D_DR+2,
   260  	"DR3",		LBREG,	D_DR+3,
   261  	"DR4",		LBREG,	D_DR+4,
   262  	"DR5",		LBREG,	D_DR+5,
   263  	"DR6",		LBREG,	D_DR+6,
   264  	"DR7",		LBREG,	D_DR+7,
   265  
   266  	"TR0",		LBREG,	D_TR+0,
   267  	"TR1",		LBREG,	D_TR+1,
   268  	"TR2",		LBREG,	D_TR+2,
   269  	"TR3",		LBREG,	D_TR+3,
   270  	"TR4",		LBREG,	D_TR+4,
   271  	"TR5",		LBREG,	D_TR+5,
   272  	"TR6",		LBREG,	D_TR+6,
   273  	"TR7",		LBREG,	D_TR+7,
   274  
   275  	"AAA",		LTYPE0,	AAAA,
   276  	"AAD",		LTYPE0,	AAAD,
   277  	"AAM",		LTYPE0,	AAAM,
   278  	"AAS",		LTYPE0,	AAAS,
   279  	"ADCB",		LTYPE3,	AADCB,
   280  	"ADCL",		LTYPE3,	AADCL,
   281  	"ADCW",		LTYPE3,	AADCW,
   282  	"ADDB",		LTYPE3,	AADDB,
   283  	"ADDL",		LTYPE3,	AADDL,
   284  	"ADDW",		LTYPE3,	AADDW,
   285  	"ADJSP",	LTYPE2,	AADJSP,
   286  	"ANDB",		LTYPE3,	AANDB,
   287  	"ANDL",		LTYPE3,	AANDL,
   288  	"ANDW",		LTYPE3,	AANDW,
   289  	"ARPL",		LTYPE3,	AARPL,
   290  	"BOUNDL",	LTYPE3,	ABOUNDL,
   291  	"BOUNDW",	LTYPE3,	ABOUNDW,
   292  	"BSFL",		LTYPE3,	ABSFL,
   293  	"BSFW",		LTYPE3,	ABSFW,
   294  	"BSRL",		LTYPE3,	ABSRL,
   295  	"BSRW",		LTYPE3,	ABSRW,
   296  	"BSWAPL",	LTYPE1,	ABSWAPL,
   297  	"BTCL",		LTYPE3,	ABTCL,
   298  	"BTCW",		LTYPE3,	ABTCW,
   299  	"BTL",		LTYPE3,	ABTL,
   300  	"BTRL",		LTYPE3,	ABTRL,
   301  	"BTRW",		LTYPE3,	ABTRW,
   302  	"BTSL",		LTYPE3,	ABTSL,
   303  	"BTSW",		LTYPE3,	ABTSW,
   304  	"BTW",		LTYPE3,	ABTW,
   305  	"BYTE",		LTYPE2,	ABYTE,
   306  	"CALL",		LTYPEC,	ACALL,
   307  	"CLC",		LTYPE0,	ACLC,
   308  	"CLD",		LTYPE0,	ACLD,
   309  	"CLI",		LTYPE0,	ACLI,
   310  	"CLTS",		LTYPE0,	ACLTS,
   311  	"CMC",		LTYPE0,	ACMC,
   312  	"CMPB",		LTYPE4,	ACMPB,
   313  	"CMPL",		LTYPE4,	ACMPL,
   314  	"CMPW",		LTYPE4,	ACMPW,
   315  	"CMPSB",	LTYPE0,	ACMPSB,
   316  	"CMPSL",	LTYPE0,	ACMPSL,
   317  	"CMPSW",	LTYPE0,	ACMPSW,
   318  	"CMPXCHG8B",	LTYPE1,	ACMPXCHG8B,
   319  	"CMPXCHGB",	LTYPE3,	ACMPXCHGB,
   320  	"CMPXCHGL",	LTYPE3,	ACMPXCHGL,
   321  	"CMPXCHGW",	LTYPE3,	ACMPXCHGW,
   322  	"CPUID",	LTYPE0,	ACPUID,
   323  	"DAA",		LTYPE0,	ADAA,
   324  	"DAS",		LTYPE0,	ADAS,
   325  	"DATA",		LTYPED,	ADATA,
   326  	"DECB",		LTYPE1,	ADECB,
   327  	"DECL",		LTYPE1,	ADECL,
   328  	"DECW",		LTYPE1,	ADECW,
   329  	"DIVB",		LTYPE2,	ADIVB,
   330  	"DIVL",		LTYPE2,	ADIVL,
   331  	"DIVW",		LTYPE2,	ADIVW,
   332  	"END",		LTYPE0,	AEND,
   333  	"ENTER",	LTYPE2,	AENTER,
   334  	"GLOBL",	LTYPEG,	AGLOBL,
   335  	"HLT",		LTYPE0,	AHLT,
   336  	"IDIVB",	LTYPE2,	AIDIVB,
   337  	"IDIVL",	LTYPE2,	AIDIVL,
   338  	"IDIVW",	LTYPE2,	AIDIVW,
   339  	"IMULB",	LTYPE2,	AIMULB,
   340  	"IMULL",	LTYPEI,	AIMULL,
   341  	"IMULW",	LTYPEI,	AIMULW,
   342  	"INB",		LTYPE0,	AINB,
   343  	"INL",		LTYPE0,	AINL,
   344  	"INW",		LTYPE0,	AINW,
   345  	"INCB",		LTYPE1,	AINCB,
   346  	"INCL",		LTYPE1,	AINCL,
   347  	"INCW",		LTYPE1,	AINCW,
   348  	"INSB",		LTYPE0,	AINSB,
   349  	"INSL",		LTYPE0,	AINSL,
   350  	"INSW",		LTYPE0,	AINSW,
   351  	"INT",		LTYPE2,	AINT,
   352  	"INTO",		LTYPE0,	AINTO,
   353  	"IRETL",	LTYPE0,	AIRETL,
   354  	"IRETW",	LTYPE0,	AIRETW,
   355  
   356  	"JOS",		LTYPER,	AJOS,	/* overflow set (OF = 1) */
   357  	"JO",		LTYPER,	AJOS,	/* alternate */
   358  	"JOC",		LTYPER,	AJOC,	/* overflow clear (OF = 0) */
   359  	"JNO",		LTYPER,	AJOC,	/* alternate */
   360  	"JCS",		LTYPER,	AJCS,	/* carry set (CF = 1) */
   361  	"JB",		LTYPER,	AJCS,	/* alternate */
   362  	"JC",		LTYPER,	AJCS,	/* alternate */
   363  	"JNAE",		LTYPER,	AJCS,	/* alternate */
   364  	"JLO",		LTYPER,	AJCS,	/* alternate */
   365  	"JCC",		LTYPER,	AJCC,	/* carry clear (CF = 0) */
   366  	"JAE",		LTYPER,	AJCC,	/* alternate */
   367  	"JNB",		LTYPER,	AJCC,	/* alternate */
   368  	"JNC",		LTYPER,	AJCC,	/* alternate */
   369  	"JHS",		LTYPER,	AJCC,	/* alternate */
   370  	"JEQ",		LTYPER,	AJEQ,	/* equal (ZF = 1) */
   371  	"JE",		LTYPER,	AJEQ,	/* alternate */
   372  	"JZ",		LTYPER,	AJEQ,	/* alternate */
   373  	"JNE",		LTYPER,	AJNE,	/* not equal (ZF = 0) */
   374  	"JNZ",		LTYPER,	AJNE,	/* alternate */
   375  	"JLS",		LTYPER,	AJLS,	/* lower or same (unsigned) (CF = 1 || ZF = 1) */
   376  	"JBE",		LTYPER,	AJLS,	/* alternate */
   377  	"JNA",		LTYPER,	AJLS,	/* alternate */
   378  	"JHI",		LTYPER,	AJHI,	/* higher (unsigned) (CF = 0 && ZF = 0) */
   379  	"JA",		LTYPER,	AJHI,	/* alternate */
   380  	"JNBE",		LTYPER,	AJHI,	/* alternate */
   381  	"JMI",		LTYPER,	AJMI,	/* negative (minus) (SF = 1) */
   382  	"JS",		LTYPER,	AJMI,	/* alternate */
   383  	"JPL",		LTYPER,	AJPL,	/* non-negative (plus) (SF = 0) */
   384  	"JNS",		LTYPER,	AJPL,	/* alternate */
   385  	"JPS",		LTYPER,	AJPS,	/* parity set (PF = 1) */
   386  	"JP",		LTYPER,	AJPS,	/* alternate */
   387  	"JPE",		LTYPER,	AJPS,	/* alternate */
   388  	"JPC",		LTYPER,	AJPC,	/* parity clear (PF = 0) */
   389  	"JNP",		LTYPER,	AJPC,	/* alternate */
   390  	"JPO",		LTYPER,	AJPC,	/* alternate */
   391  	"JLT",		LTYPER,	AJLT,	/* less than (signed) (SF != OF) */
   392  	"JL",		LTYPER,	AJLT,	/* alternate */
   393  	"JNGE",		LTYPER,	AJLT,	/* alternate */
   394  	"JGE",		LTYPER,	AJGE,	/* greater than or equal (signed) (SF = OF) */
   395  	"JNL",		LTYPER,	AJGE,	/* alternate */
   396  	"JLE",		LTYPER,	AJLE,	/* less than or equal (signed) (ZF = 1 || SF != OF) */
   397  	"JNG",		LTYPER,	AJLE,	/* alternate */
   398  	"JGT",		LTYPER,	AJGT,	/* greater than (signed) (ZF = 0 && SF = OF) */
   399  	"JG",		LTYPER,	AJGT,	/* alternate */
   400  	"JNLE",		LTYPER,	AJGT,	/* alternate */
   401  
   402  	"JCXZL",	LTYPER,	AJCXZL,
   403  	"JCXZW",	LTYPER,	AJCXZW,
   404  	"JMP",		LTYPEC,	AJMP,
   405  	"LAHF",		LTYPE0,	ALAHF,
   406  	"LARL",		LTYPE3,	ALARL,
   407  	"LARW",		LTYPE3,	ALARW,
   408  	"LEAL",		LTYPE3,	ALEAL,
   409  	"LEAW",		LTYPE3,	ALEAW,
   410  	"LEAVEL",	LTYPE0,	ALEAVEL,
   411  	"LEAVEW",	LTYPE0,	ALEAVEW,
   412  	"LOCK",		LTYPE0,	ALOCK,
   413  	"LODSB",	LTYPE0,	ALODSB,
   414  	"LODSL",	LTYPE0,	ALODSL,
   415  	"LODSW",	LTYPE0,	ALODSW,
   416  	"LONG",		LTYPE2,	ALONG,
   417  	"LOOP",		LTYPER,	ALOOP,
   418  	"LOOPEQ",	LTYPER,	ALOOPEQ,
   419  	"LOOPNE",	LTYPER,	ALOOPNE,
   420  	"LSLL",		LTYPE3,	ALSLL,
   421  	"LSLW",		LTYPE3,	ALSLW,
   422  	"MOVB",		LTYPE3,	AMOVB,
   423  	"MOVL",		LTYPEM,	AMOVL,
   424  	"MOVW",		LTYPEM,	AMOVW,
   425  	"MOVQ",		LTYPEM, AMOVQ,
   426  	"MOVBLSX",	LTYPE3, AMOVBLSX,
   427  	"MOVBLZX",	LTYPE3, AMOVBLZX,
   428  	"MOVBWSX",	LTYPE3, AMOVBWSX,
   429  	"MOVBWZX",	LTYPE3, AMOVBWZX,
   430  	"MOVWLSX",	LTYPE3, AMOVWLSX,
   431  	"MOVWLZX",	LTYPE3, AMOVWLZX,
   432  	"MOVSB",	LTYPE0,	AMOVSB,
   433  	"MOVSL",	LTYPE0,	AMOVSL,
   434  	"MOVSW",	LTYPE0,	AMOVSW,
   435  	"MULB",		LTYPE2,	AMULB,
   436  	"MULL",		LTYPE2,	AMULL,
   437  	"MULW",		LTYPE2,	AMULW,
   438  	"NEGB",		LTYPE1,	ANEGB,
   439  	"NEGL",		LTYPE1,	ANEGL,
   440  	"NEGW",		LTYPE1,	ANEGW,
   441  	"NOP",		LTYPEN,	ANOP,
   442  	"NOTB",		LTYPE1,	ANOTB,
   443  	"NOTL",		LTYPE1,	ANOTL,
   444  	"NOTW",		LTYPE1,	ANOTW,
   445  	"ORB",		LTYPE3,	AORB,
   446  	"ORL",		LTYPE3,	AORL,
   447  	"ORW",		LTYPE3,	AORW,
   448  	"OUTB",		LTYPE0,	AOUTB,
   449  	"OUTL",		LTYPE0,	AOUTL,
   450  	"OUTW",		LTYPE0,	AOUTW,
   451  	"OUTSB",	LTYPE0,	AOUTSB,
   452  	"OUTSL",	LTYPE0,	AOUTSL,
   453  	"OUTSW",	LTYPE0,	AOUTSW,
   454  	"PAUSE",	LTYPEN,	APAUSE,
   455  	"PINSRD",	LTYPEX,	APINSRD,
   456  	"POPAL",	LTYPE0,	APOPAL,
   457  	"POPAW",	LTYPE0,	APOPAW,
   458  	"POPFL",	LTYPE0,	APOPFL,
   459  	"POPFW",	LTYPE0,	APOPFW,
   460  	"POPL",		LTYPE1,	APOPL,
   461  	"POPW",		LTYPE1,	APOPW,
   462  	"PUSHAL",	LTYPE0,	APUSHAL,
   463  	"PUSHAW",	LTYPE0,	APUSHAW,
   464  	"PUSHFL",	LTYPE0,	APUSHFL,
   465  	"PUSHFW",	LTYPE0,	APUSHFW,
   466  	"PUSHL",	LTYPE2,	APUSHL,
   467  	"PUSHW",	LTYPE2,	APUSHW,
   468  	"RCLB",		LTYPE3,	ARCLB,
   469  	"RCLL",		LTYPE3,	ARCLL,
   470  	"RCLW",		LTYPE3,	ARCLW,
   471  	"RCRB",		LTYPE3,	ARCRB,
   472  	"RCRL",		LTYPE3,	ARCRL,
   473  	"RCRW",		LTYPE3,	ARCRW,
   474  	"RDTSC",	LTYPE0,	ARDTSC,
   475  	"REP",		LTYPE0,	AREP,
   476  	"REPN",		LTYPE0,	AREPN,
   477  	"RET",		LTYPE0,	ARET,
   478  	"ROLB",		LTYPE3,	AROLB,
   479  	"ROLL",		LTYPE3,	AROLL,
   480  	"ROLW",		LTYPE3,	AROLW,
   481  	"RORB",		LTYPE3,	ARORB,
   482  	"RORL",		LTYPE3,	ARORL,
   483  	"RORW",		LTYPE3,	ARORW,
   484  	"SAHF",		LTYPE0,	ASAHF,
   485  	"SALB",		LTYPE3,	ASALB,
   486  	"SALL",		LTYPE3,	ASALL,
   487  	"SALW",		LTYPE3,	ASALW,
   488  	"SARB",		LTYPE3,	ASARB,
   489  	"SARL",		LTYPE3,	ASARL,
   490  	"SARW",		LTYPE3,	ASARW,
   491  	"SBBB",		LTYPE3,	ASBBB,
   492  	"SBBL",		LTYPE3,	ASBBL,
   493  	"SBBW",		LTYPE3,	ASBBW,
   494  	"SCASB",	LTYPE0,	ASCASB,
   495  	"SCASL",	LTYPE0,	ASCASL,
   496  	"SCASW",	LTYPE0,	ASCASW,
   497  	"SETCC",	LTYPE1,	ASETCC,	/* see JCC etc above for condition codes */
   498  	"SETCS",	LTYPE1,	ASETCS,
   499  	"SETEQ",	LTYPE1,	ASETEQ,
   500  	"SETGE",	LTYPE1,	ASETGE,
   501  	"SETGT",	LTYPE1,	ASETGT,
   502  	"SETHI",	LTYPE1,	ASETHI,
   503  	"SETLE",	LTYPE1,	ASETLE,
   504  	"SETLS",	LTYPE1,	ASETLS,
   505  	"SETLT",	LTYPE1,	ASETLT,
   506  	"SETMI",	LTYPE1,	ASETMI,
   507  	"SETNE",	LTYPE1,	ASETNE,
   508  	"SETOC",	LTYPE1,	ASETOC,
   509  	"SETOS",	LTYPE1,	ASETOS,
   510  	"SETPC",	LTYPE1,	ASETPC,
   511  	"SETPL",	LTYPE1,	ASETPL,
   512  	"SETPS",	LTYPE1,	ASETPS,
   513  	"CDQ",		LTYPE0,	ACDQ,
   514  	"CWD",		LTYPE0,	ACWD,
   515  	"SHLB",		LTYPE3,	ASHLB,
   516  	"SHLL",		LTYPES,	ASHLL,
   517  	"SHLW",		LTYPES,	ASHLW,
   518  	"SHRB",		LTYPE3,	ASHRB,
   519  	"SHRL",		LTYPES,	ASHRL,
   520  	"SHRW",		LTYPES,	ASHRW,
   521  	"STC",		LTYPE0,	ASTC,
   522  	"STD",		LTYPE0,	ASTD,
   523  	"STI",		LTYPE0,	ASTI,
   524  	"STOSB",	LTYPE0,	ASTOSB,
   525  	"STOSL",	LTYPE0,	ASTOSL,
   526  	"STOSW",	LTYPE0,	ASTOSW,
   527  	"SUBB",		LTYPE3,	ASUBB,
   528  	"SUBL",		LTYPE3,	ASUBL,
   529  	"SUBW",		LTYPE3,	ASUBW,
   530  	"SYSCALL",	LTYPE0,	ASYSCALL,
   531  	"TESTB",	LTYPE3,	ATESTB,
   532  	"TESTL",	LTYPE3,	ATESTL,
   533  	"TESTW",	LTYPE3,	ATESTW,
   534  	"TEXT",		LTYPET,	ATEXT,
   535  	"VERR",		LTYPE2,	AVERR,
   536  	"VERW",		LTYPE2,	AVERW,
   537  	"WAIT",		LTYPE0,	AWAIT,
   538  	"WORD",		LTYPE2,	AWORD,
   539  	"XADDB",	LTYPE3,	AXADDB,
   540  	"XADDL",	LTYPE3,	AXADDL,
   541  	"XADDW",	LTYPE3,	AXADDW,
   542  	"XCHGB",	LTYPE3,	AXCHGB,
   543  	"XCHGL",	LTYPE3,	AXCHGL,
   544  	"XCHGW",	LTYPE3,	AXCHGW,
   545  	"XLAT",		LTYPE2,	AXLAT,
   546  	"XORB",		LTYPE3,	AXORB,
   547  	"XORL",		LTYPE3,	AXORL,
   548  	"XORW",		LTYPE3,	AXORW,
   549  
   550  	"CMOVLCC",	LTYPE3,	ACMOVLCC,
   551  	"CMOVLCS",	LTYPE3,	ACMOVLCS,
   552  	"CMOVLEQ",	LTYPE3,	ACMOVLEQ,
   553  	"CMOVLGE",	LTYPE3,	ACMOVLGE,
   554  	"CMOVLGT",	LTYPE3,	ACMOVLGT,
   555  	"CMOVLHI",	LTYPE3,	ACMOVLHI,
   556  	"CMOVLLE",	LTYPE3,	ACMOVLLE,
   557  	"CMOVLLS",	LTYPE3,	ACMOVLLS,
   558  	"CMOVLLT",	LTYPE3,	ACMOVLLT,
   559  	"CMOVLMI",	LTYPE3,	ACMOVLMI,
   560  	"CMOVLNE",	LTYPE3,	ACMOVLNE,
   561  	"CMOVLOC",	LTYPE3,	ACMOVLOC,
   562  	"CMOVLOS",	LTYPE3,	ACMOVLOS,
   563  	"CMOVLPC",	LTYPE3,	ACMOVLPC,
   564  	"CMOVLPL",	LTYPE3,	ACMOVLPL,
   565  	"CMOVLPS",	LTYPE3,	ACMOVLPS,
   566  	"CMOVWCC",	LTYPE3,	ACMOVWCC,
   567  	"CMOVWCS",	LTYPE3,	ACMOVWCS,
   568  	"CMOVWEQ",	LTYPE3,	ACMOVWEQ,
   569  	"CMOVWGE",	LTYPE3,	ACMOVWGE,
   570  	"CMOVWGT",	LTYPE3,	ACMOVWGT,
   571  	"CMOVWHI",	LTYPE3,	ACMOVWHI,
   572  	"CMOVWLE",	LTYPE3,	ACMOVWLE,
   573  	"CMOVWLS",	LTYPE3,	ACMOVWLS,
   574  	"CMOVWLT",	LTYPE3,	ACMOVWLT,
   575  	"CMOVWMI",	LTYPE3,	ACMOVWMI,
   576  	"CMOVWNE",	LTYPE3,	ACMOVWNE,
   577  	"CMOVWOC",	LTYPE3,	ACMOVWOC,
   578  	"CMOVWOS",	LTYPE3,	ACMOVWOS,
   579  	"CMOVWPC",	LTYPE3,	ACMOVWPC,
   580  	"CMOVWPL",	LTYPE3,	ACMOVWPL,
   581  	"CMOVWPS",	LTYPE3,	ACMOVWPS,
   582  
   583  	"FMOVB",	LTYPE3, AFMOVB,
   584  	"FMOVBP",	LTYPE3, AFMOVBP,
   585  	"FMOVD",	LTYPE3, AFMOVD,
   586  	"FMOVDP",	LTYPE3, AFMOVDP,
   587  	"FMOVF",	LTYPE3, AFMOVF,
   588  	"FMOVFP",	LTYPE3, AFMOVFP,
   589  	"FMOVL",	LTYPE3, AFMOVL,
   590  	"FMOVLP",	LTYPE3, AFMOVLP,
   591  	"FMOVV",	LTYPE3, AFMOVV,
   592  	"FMOVVP",	LTYPE3, AFMOVVP,
   593  	"FMOVW",	LTYPE3, AFMOVW,
   594  	"FMOVWP",	LTYPE3, AFMOVWP,
   595  	"FMOVX",	LTYPE3, AFMOVX,
   596  	"FMOVXP",	LTYPE3, AFMOVXP,
   597  	"FCMOVCC",	LTYPE3, AFCMOVCC,
   598  	"FCMOVCS",	LTYPE3, AFCMOVCS,
   599  	"FCMOVEQ",	LTYPE3, AFCMOVEQ,
   600  	"FCMOVHI",	LTYPE3, AFCMOVHI,
   601  	"FCMOVLS",	LTYPE3, AFCMOVLS,
   602  	"FCMOVNE",	LTYPE3, AFCMOVNE,
   603  	"FCMOVNU",	LTYPE3, AFCMOVNU,
   604  	"FCMOVUN",	LTYPE3, AFCMOVUN,
   605  	"FCOMB",	LTYPE3, AFCOMB,
   606  	"FCOMBP",	LTYPE3, AFCOMBP,
   607  	"FCOMD",	LTYPE3, AFCOMD,
   608  	"FCOMDP",	LTYPE3, AFCOMDP,
   609  	"FCOMDPP",	LTYPE3, AFCOMDPP,
   610  	"FCOMF",	LTYPE3, AFCOMF,
   611  	"FCOMFP",	LTYPE3, AFCOMFP,
   612  	"FCOMI",	LTYPE3, AFCOMI,
   613  	"FCOMIP",	LTYPE3, AFCOMIP,
   614  	"FCOML",	LTYPE3, AFCOML,
   615  	"FCOMLP",	LTYPE3, AFCOMLP,
   616  	"FCOMW",	LTYPE3, AFCOMW,
   617  	"FCOMWP",	LTYPE3, AFCOMWP,
   618  	"FUCOM",	LTYPE3, AFUCOM,
   619  	"FUCOMI",	LTYPE3, AFUCOMI,
   620  	"FUCOMIP",	LTYPE3, AFUCOMIP,
   621  	"FUCOMP",	LTYPE3, AFUCOMP,
   622  	"FUCOMPP",	LTYPE3, AFUCOMPP,
   623  	"FADDW",	LTYPE3, AFADDW,
   624  	"FADDL",	LTYPE3, AFADDL,
   625  	"FADDF",	LTYPE3, AFADDF,
   626  	"FADDD",	LTYPE3, AFADDD,
   627  	"FADDDP",	LTYPE3, AFADDDP,
   628  	"FSUBDP",	LTYPE3, AFSUBDP,
   629  	"FSUBW",	LTYPE3, AFSUBW,
   630  	"FSUBL",	LTYPE3, AFSUBL,
   631  	"FSUBF",	LTYPE3, AFSUBF,
   632  	"FSUBD",	LTYPE3, AFSUBD,
   633  	"FSUBRDP",	LTYPE3, AFSUBRDP,
   634  	"FSUBRW",	LTYPE3, AFSUBRW,
   635  	"FSUBRL",	LTYPE3, AFSUBRL,
   636  	"FSUBRF",	LTYPE3, AFSUBRF,
   637  	"FSUBRD",	LTYPE3, AFSUBRD,
   638  	"FMULDP",	LTYPE3, AFMULDP,
   639  	"FMULW",	LTYPE3, AFMULW,
   640  	"FMULL",	LTYPE3, AFMULL,
   641  	"FMULF",	LTYPE3, AFMULF,
   642  	"FMULD",	LTYPE3, AFMULD,
   643  	"FDIVDP",	LTYPE3, AFDIVDP,
   644  	"FDIVW",	LTYPE3, AFDIVW,
   645  	"FDIVL",	LTYPE3, AFDIVL,
   646  	"FDIVF",	LTYPE3, AFDIVF,
   647  	"FDIVD",	LTYPE3, AFDIVD,
   648  	"FDIVRDP",	LTYPE3, AFDIVRDP,
   649  	"FDIVRW",	LTYPE3, AFDIVRW,
   650  	"FDIVRL",	LTYPE3, AFDIVRL,
   651  	"FDIVRF",	LTYPE3, AFDIVRF,
   652  	"FDIVRD",	LTYPE3, AFDIVRD,
   653  	"FXCHD",	LTYPE3, AFXCHD,
   654  	"FFREE",	LTYPE1, AFFREE,
   655  	"FLDCW",	LTYPE2, AFLDCW,
   656  	"FLDENV",	LTYPE1, AFLDENV,
   657  	"FRSTOR",	LTYPE2, AFRSTOR,
   658  	"FSAVE",	LTYPE1, AFSAVE,
   659  	"FSTCW",	LTYPE1, AFSTCW,
   660  	"FSTENV",	LTYPE1, AFSTENV,
   661  	"FSTSW",	LTYPE1, AFSTSW,
   662  	"F2XM1",	LTYPE0, AF2XM1,
   663  	"FABS",		LTYPE0, AFABS,
   664  	"FCHS",		LTYPE0, AFCHS,
   665  	"FCLEX",	LTYPE0, AFCLEX,
   666  	"FCOS",		LTYPE0, AFCOS,
   667  	"FDECSTP",	LTYPE0, AFDECSTP,
   668  	"FINCSTP",	LTYPE0, AFINCSTP,
   669  	"FINIT",	LTYPE0, AFINIT,
   670  	"FLD1",		LTYPE0, AFLD1,
   671  	"FLDL2E",	LTYPE0, AFLDL2E,
   672  	"FLDL2T",	LTYPE0, AFLDL2T,
   673  	"FLDLG2",	LTYPE0, AFLDLG2,
   674  	"FLDLN2",	LTYPE0, AFLDLN2,
   675  	"FLDPI",	LTYPE0, AFLDPI,
   676  	"FLDZ",		LTYPE0, AFLDZ,
   677  	"FNOP",		LTYPE0, AFNOP,
   678  	"FPATAN",	LTYPE0, AFPATAN,
   679  	"FPREM",	LTYPE0, AFPREM,
   680  	"FPREM1",	LTYPE0, AFPREM1,
   681  	"FPTAN",	LTYPE0, AFPTAN,
   682  	"FRNDINT",	LTYPE0, AFRNDINT,
   683  	"FSCALE",	LTYPE0, AFSCALE,
   684  	"FSIN",		LTYPE0, AFSIN,
   685  	"FSINCOS",	LTYPE0, AFSINCOS,
   686  	"FSQRT",	LTYPE0, AFSQRT,
   687  	"FTST",		LTYPE0, AFTST,
   688  	"FXAM",		LTYPE0, AFXAM,
   689  	"FXTRACT",	LTYPE0, AFXTRACT,
   690  	"FYL2X",	LTYPE0, AFYL2X,
   691  	"FYL2XP1",	LTYPE0, AFYL2XP1,
   692  	"LFENCE",	LTYPE0, ALFENCE,
   693  	"MFENCE",	LTYPE0, AMFENCE,
   694  	"SFENCE",	LTYPE0, ASFENCE,
   695  	"EMMS",		LTYPE0, AEMMS,
   696  	"PREFETCHT0",		LTYPE2,	APREFETCHT0,
   697  	"PREFETCHT1",		LTYPE2,	APREFETCHT1,
   698  	"PREFETCHT2",		LTYPE2,	APREFETCHT2,
   699  	"PREFETCHNTA",		LTYPE2,	APREFETCHNTA,
   700  	"UNDEF",	LTYPE0,	AUNDEF,
   701  
   702  	"ADDPD",	LTYPE3,	AADDPD,
   703  	"ADDPS",	LTYPE3,	AADDPS,
   704  	"ADDSD",	LTYPE3,	AADDSD,
   705  	"ADDSS",	LTYPE3,	AADDSS,
   706  	"AESENC",	LTYPE3,	AAESENC,
   707  	"ANDNPD",	LTYPE3,	AANDNPD,
   708  	"ANDNPS",	LTYPE3,	AANDNPS,
   709  	"ANDPD",	LTYPE3,	AANDPD,
   710  	"ANDPS",	LTYPE3,	AANDPS,
   711  	"CMPPD",	LTYPEXC,ACMPPD,
   712  	"CMPPS",	LTYPEXC,ACMPPS,
   713  	"CMPSD",	LTYPEXC,ACMPSD,
   714  	"CMPSS",	LTYPEXC,ACMPSS,
   715  	"COMISD",	LTYPE3,	ACOMISD,
   716  	"COMISS",	LTYPE3,	ACOMISS,
   717  	"CVTPL2PD",	LTYPE3,	ACVTPL2PD,
   718  	"CVTPL2PS",	LTYPE3,	ACVTPL2PS,
   719  	"CVTPD2PL",	LTYPE3,	ACVTPD2PL,
   720  	"CVTPD2PS",	LTYPE3,	ACVTPD2PS,
   721  	"CVTPS2PL",	LTYPE3,	ACVTPS2PL,
   722  	"CVTPS2PD",	LTYPE3,	ACVTPS2PD,
   723  	"CVTSD2SL",	LTYPE3,	ACVTSD2SL,
   724  	"CVTSD2SS",	LTYPE3,	ACVTSD2SS,
   725  	"CVTSL2SD",	LTYPE3,	ACVTSL2SD,
   726  	"CVTSL2SS",	LTYPE3,	ACVTSL2SS,
   727  	"CVTSS2SD",	LTYPE3,	ACVTSS2SD,
   728  	"CVTSS2SL",	LTYPE3,	ACVTSS2SL,
   729  	"CVTTPD2PL",	LTYPE3,	ACVTTPD2PL,
   730  	"CVTTPS2PL",	LTYPE3,	ACVTTPS2PL,
   731  	"CVTTSD2SL",	LTYPE3,	ACVTTSD2SL,
   732  	"CVTTSS2SL",	LTYPE3,	ACVTTSS2SL,
   733  	"DIVPD",	LTYPE3,	ADIVPD,
   734  	"DIVPS",	LTYPE3,	ADIVPS,
   735  	"DIVSD",	LTYPE3,	ADIVSD,
   736  	"DIVSS",	LTYPE3,	ADIVSS,
   737  	"MASKMOVOU",	LTYPE3,	AMASKMOVOU,
   738  	"MASKMOVDQU",	LTYPE3,	AMASKMOVOU,	/* syn */
   739  	"MAXPD",	LTYPE3,	AMAXPD,
   740  	"MAXPS",	LTYPE3,	AMAXPS,
   741  	"MAXSD",	LTYPE3,	AMAXSD,
   742  	"MAXSS",	LTYPE3,	AMAXSS,
   743  	"MINPD",	LTYPE3,	AMINPD,
   744  	"MINPS",	LTYPE3,	AMINPS,
   745  	"MINSD",	LTYPE3,	AMINSD,
   746  	"MINSS",	LTYPE3,	AMINSS,
   747  	"MOVAPD",	LTYPE3,	AMOVAPD,
   748  	"MOVAPS",	LTYPE3,	AMOVAPS,
   749  	"MOVO",		LTYPE3,	AMOVO,
   750  	"MOVOA",	LTYPE3,	AMOVO,	/* syn */
   751  	"MOVOU",	LTYPE3,	AMOVOU,
   752  	"MOVHLPS",	LTYPE3,	AMOVHLPS,
   753  	"MOVHPD",	LTYPE3,	AMOVHPD,
   754  	"MOVHPS",	LTYPE3,	AMOVHPS,
   755  	"MOVLHPS",	LTYPE3,	AMOVLHPS,
   756  	"MOVLPD",	LTYPE3,	AMOVLPD,
   757  	"MOVLPS",	LTYPE3,	AMOVLPS,
   758  	"MOVMSKPD",	LTYPE3,	AMOVMSKPD,
   759  	"MOVMSKPS",	LTYPE3,	AMOVMSKPS,
   760  	"MOVNTO",	LTYPE3,	AMOVNTO,
   761  	"MOVNTDQ",	LTYPE3,	AMOVNTO,	/* syn */
   762  	"MOVNTPD",	LTYPE3,	AMOVNTPD,
   763  	"MOVNTPS",	LTYPE3,	AMOVNTPS,
   764  	"MOVSD",	LTYPE3,	AMOVSD,
   765  	"MOVSS",	LTYPE3,	AMOVSS,
   766  	"MOVUPD",	LTYPE3,	AMOVUPD,
   767  	"MOVUPS",	LTYPE3,	AMOVUPS,
   768  	"MULPD",	LTYPE3,	AMULPD,
   769  	"MULPS",	LTYPE3,	AMULPS,
   770  	"MULSD",	LTYPE3,	AMULSD,
   771  	"MULSS",	LTYPE3,	AMULSS,
   772  	"ORPD",		LTYPE3,	AORPD,
   773  	"ORPS",		LTYPE3,	AORPS,
   774  	"PADDQ",	LTYPE3,	APADDQ,
   775  	"PAND",		LTYPE3,	APAND,
   776  	"PCMPEQB",	LTYPE3,	APCMPEQB,
   777  	"PMAXSW",	LTYPE3,	APMAXSW,
   778  	"PMAXUB",	LTYPE3,	APMAXUB,
   779  	"PMINSW",	LTYPE3,	APMINSW,
   780  	"PMINUB",	LTYPE3,	APMINUB,
   781  	"PMOVMSKB",	LTYPE3,	APMOVMSKB,
   782  	"PSADBW",	LTYPE3,	APSADBW,
   783  	"PSHUFB",	LTYPE3, APSHUFB,
   784  	"PSUBB",	LTYPE3,	APSUBB,
   785  	"PSUBL",	LTYPE3,	APSUBL,
   786  	"PSUBQ",	LTYPE3,	APSUBQ,
   787  	"PSUBSB",	LTYPE3,	APSUBSB,
   788  	"PSUBSW",	LTYPE3,	APSUBSW,
   789  	"PSUBUSB",	LTYPE3,	APSUBUSB,
   790  	"PSUBUSW",	LTYPE3,	APSUBUSW,
   791  	"PSUBW",	LTYPE3,	APSUBW,
   792  	"PUNPCKHQDQ",	LTYPE3,	APUNPCKHQDQ,
   793  	"PUNPCKLQDQ",	LTYPE3,	APUNPCKLQDQ,
   794  	"PXOR",		LTYPE3, APXOR,
   795  	"RCPPS",	LTYPE3,	ARCPPS,
   796  	"RCPSS",	LTYPE3,	ARCPSS,
   797  	"RSQRTPS",	LTYPE3,	ARSQRTPS,
   798  	"RSQRTSS",	LTYPE3,	ARSQRTSS,
   799  	"SQRTPD",	LTYPE3,	ASQRTPD,
   800  	"SQRTPS",	LTYPE3,	ASQRTPS,
   801  	"SQRTSD",	LTYPE3,	ASQRTSD,
   802  	"SQRTSS",	LTYPE3,	ASQRTSS,
   803  	"SUBPD",	LTYPE3,	ASUBPD,
   804  	"SUBPS",	LTYPE3,	ASUBPS,
   805  	"SUBSD",	LTYPE3,	ASUBSD,
   806  	"SUBSS",	LTYPE3,	ASUBSS,
   807  	"UCOMISD",	LTYPE3,	AUCOMISD,
   808  	"UCOMISS",	LTYPE3,	AUCOMISS,
   809  	"UNPCKHPD",	LTYPE3,	AUNPCKHPD,
   810  	"UNPCKHPS",	LTYPE3,	AUNPCKHPS,
   811  	"UNPCKLPD",	LTYPE3,	AUNPCKLPD,
   812  	"UNPCKLPS",	LTYPE3,	AUNPCKLPS,
   813  	"XORPD",	LTYPE3,	AXORPD,
   814  	"XORPS",	LTYPE3,	AXORPS,
   815  	"USEFIELD",	LTYPEN, AUSEFIELD,
   816  	"PCDATA",	LTYPEPC,	APCDATA,
   817  	"FUNCDATA",	LTYPEF,	AFUNCDATA,
   818  	0
   819  };
   820  
   821  void
   822  cinit(void)
   823  {
   824  	Sym *s;
   825  	int i;
   826  
   827  	nullgen.type = D_NONE;
   828  	nullgen.index = D_NONE;
   829  
   830  	nerrors = 0;
   831  	iostack = I;
   832  	iofree = I;
   833  	peekc = IGN;
   834  	nhunk = 0;
   835  	for(i=0; i<NHASH; i++)
   836  		hash[i] = S;
   837  	for(i=0; itab[i].name; i++) {
   838  		s = slookup(itab[i].name);
   839  		if(s->type != LNAME)
   840  			yyerror("double initialization %s", itab[i].name);
   841  		s->type = itab[i].type;
   842  		s->value = itab[i].value;
   843  	}
   844  }
   845  
   846  void
   847  checkscale(int scale)
   848  {
   849  
   850  	switch(scale) {
   851  	case 1:
   852  	case 2:
   853  	case 4:
   854  	case 8:
   855  		return;
   856  	}
   857  	yyerror("scale must be 1248: %d", scale);
   858  }
   859  
   860  void
   861  syminit(Sym *s)
   862  {
   863  
   864  	s->type = LNAME;
   865  	s->value = 0;
   866  }
   867  
   868  void
   869  cclean(void)
   870  {
   871  	Addr2 g2;
   872  
   873  	g2.from = nullgen;
   874  	g2.to = nullgen;
   875  	outcode(AEND, &g2);
   876  }
   877  
   878  static Prog *lastpc;
   879  
   880  void
   881  outcode(int a, Addr2 *g2)
   882  {
   883  	Prog *p;
   884  	Plist *pl;
   885  	
   886  	if(pass == 1)
   887  		goto out;
   888  
   889  	p = malloc(sizeof *p);
   890  	memset(p, 0, sizeof *p);
   891  	p->as = a;
   892  	p->lineno = stmtline;
   893  	p->from = g2->from;
   894  	p->to = g2->to;
   895  	p->pc = pc;
   896  
   897  	if(lastpc == nil) {
   898  		pl = linknewplist(ctxt);
   899  		pl->firstpc = p;
   900  	} else
   901  		lastpc->link = p;
   902  	lastpc = p;	
   903  
   904  out:
   905  	if(a != AGLOBL && a != ADATA)
   906  		pc++;
   907  }
   908  
   909  #include "../cc/lexbody"
   910  #include "../cc/macbody"