#include <perms.h>
int _imp_mainep(int _imp_argc, char **_imp_argv) {
  static _imp_string Copyright =
      _imp_str_literal("Motorola M6809 Assembler. Copyright M.R.King, 26/3/1984. All rights reserved.");
  static const int Names = 1023;
  static const int Linewidth = 78;
  static const int Linesonpage = 66;
  static const int Maxline = 512;
  static const int Insertlimit = 10;
  static const int Xentries = 4096;
  static const int Ihash = 59;
  static const unsigned char Hilink[59 /*0:58*/] = {
      46,  80, 28,  43, 71, 51,  11,  73, 106, 96,  22, 122, 2,  5,   97, 6, 33, 30,  19, 20,
      138, 42, 3,   4,  75, 45,  124, 76, 77,  108, 7,  27,  8,  111, 32, 9, 10, 143, 57, 134,
      153, 47, 158, 29, 59, 150, 0,   78, 119, 26,  36, 23,  21, 35,  12, 1, 49, 16,  31};
  static const unsigned char Ilink[198 /*1:198*/] = {
      15,  34,  13,  14,  17,  18,  114, 37,  40,  24,  82,  39,  74,  50,  68,  69,  38,  48,  25,  99,  61,  121,
      115, 92,  54,  117, 66,  65,  44,  41,  63,  162, 88,  62,  0,   70,  0,   60,  67,  198, 94,  84,  58,  120,
      147, 55,  52,  87,  56,  53,  72,  188, 110, 98,  64,  140, 133, 81,  85,  0,   116, 137, 100, 102, 90,  160,
      186, 89,  154, 0,   112, 113, 83,  109, 126, 123, 79,  86,  0,   101, 91,  105, 170, 146, 151, 118, 128, 93,
      139, 104, 0,   142, 193, 95,  164, 107, 127, 141, 166, 185, 103, 155, 0,   167, 0,   0,   0,   0,   144, 0,
      0,   129, 0,   132, 163, 183, 131, 161, 130, 149, 175, 136, 125, 148, 184, 0,   177, 135, 156, 0,   0,   0,
      157, 152, 159, 187, 145, 176, 169, 0,   165, 168, 179, 171, 181, 174, 0,   0,   0,   0,   197, 0,   172, 0,
      0,   0,   0,   0,   0,   0,   194, 0,   196, 190, 0,   178, 0,   0,   192, 173, 0,   180, 189, 182, 0,   0,
      0,   0,   0,   0,   0,   195, 0,   0,   0,   0,   0,   191, 0,   0,   0,   0,   0,   0,   0,   0,   0,   0};
  static const _imp_string Instr[198 /*1:198*/] = {
      _imp_str_literal("LD"),    _imp_str_literal("LDA"),   _imp_str_literal("LDAA"), _imp_str_literal("LDAB"),
      _imp_str_literal("LDB"),   _imp_str_literal("LDD"),   _imp_str_literal("LDS"),  _imp_str_literal("LDU"),
      _imp_str_literal("LDX"),   _imp_str_literal("LDY"),   _imp_str_literal("ST"),   _imp_str_literal("STA"),
      _imp_str_literal("STAA"),  _imp_str_literal("STAB"),  _imp_str_literal("STB"),  _imp_str_literal("STD"),
      _imp_str_literal("STS"),   _imp_str_literal("STU"),   _imp_str_literal("STX"),  _imp_str_literal("STY"),
      _imp_str_literal("JSR"),   _imp_str_literal("BSR"),   _imp_str_literal("LBSR"), _imp_str_literal("BRA"),
      _imp_str_literal("LBRA"),  _imp_str_literal("BRN"),   _imp_str_literal("LBRN"), _imp_str_literal("BHI"),
      _imp_str_literal("LBHI"),  _imp_str_literal("BLS"),   _imp_str_literal("LBLS"), _imp_str_literal("BCC"),
      _imp_str_literal("LBCC"),  _imp_str_literal("BHS"),   _imp_str_literal("LBHS"), _imp_str_literal("BCS"),
      _imp_str_literal("LBCS"),  _imp_str_literal("BLO"),   _imp_str_literal("LBLO"), _imp_str_literal("BNE"),
      _imp_str_literal("LBNE"),  _imp_str_literal("BEQ"),   _imp_str_literal("LBEQ"), _imp_str_literal("BVC"),
      _imp_str_literal("LBVC"),  _imp_str_literal("BVS"),   _imp_str_literal("LBVS"), _imp_str_literal("BPL"),
      _imp_str_literal("LBPL"),  _imp_str_literal("BMI"),   _imp_str_literal("LBMI"), _imp_str_literal("BGE"),
      _imp_str_literal("LBGE"),  _imp_str_literal("BLT"),   _imp_str_literal("LBLT"), _imp_str_literal("BGT"),
      _imp_str_literal("LBGT"),  _imp_str_literal("BLE"),   _imp_str_literal("LBLE"), _imp_str_literal("JMP"),
      _imp_str_literal("RTS"),   _imp_str_literal("SUB"),   _imp_str_literal("SUBA"), _imp_str_literal("SUBB"),
      _imp_str_literal("SUBD"),  _imp_str_literal("ADD"),   _imp_str_literal("ADDA"), _imp_str_literal("ADDB"),
      _imp_str_literal("ADDD"),  _imp_str_literal("CMP"),   _imp_str_literal("CMPA"), _imp_str_literal("CMPB"),
      _imp_str_literal("CMPD"),  _imp_str_literal("CMPS"),  _imp_str_literal("CMPU"), _imp_str_literal("CMPX"),
      _imp_str_literal("CMPY"),  _imp_str_literal("CPX"),   _imp_str_literal("LEA"),  _imp_str_literal("LEAS"),
      _imp_str_literal("LEAU"),  _imp_str_literal("LEAX"),  _imp_str_literal("LEAY"), _imp_str_literal("EXG"),
      _imp_str_literal("TFR"),   _imp_str_literal("DEC"),   _imp_str_literal("DECA"), _imp_str_literal("DECB"),
      _imp_str_literal("INC"),   _imp_str_literal("INCA"),  _imp_str_literal("INCB"), _imp_str_literal("CLR"),
      _imp_str_literal("CLRA"),  _imp_str_literal("CLRB"),  _imp_str_literal("INX"),  _imp_str_literal("DEX"),
      _imp_str_literal("AND"),   _imp_str_literal("ANDA"),  _imp_str_literal("ANDB"), _imp_str_literal("OR"),
      _imp_str_literal("ORA"),   _imp_str_literal("ORAA"),  _imp_str_literal("ORAB"), _imp_str_literal("ORB"),
      _imp_str_literal("EOR"),   _imp_str_literal("EORA"),  _imp_str_literal("EORB"), _imp_str_literal("BIT"),
      _imp_str_literal("BITA"),  _imp_str_literal("BITB"),  _imp_str_literal("LSR"),  _imp_str_literal("LSRA"),
      _imp_str_literal("LSRB"),  _imp_str_literal("ROR"),   _imp_str_literal("RORA"), _imp_str_literal("RORB"),
      _imp_str_literal("ASR"),   _imp_str_literal("ASRA"),  _imp_str_literal("ASRB"), _imp_str_literal("ASL"),
      _imp_str_literal("ASLA"),  _imp_str_literal("ASLB"),  _imp_str_literal("LSL"),  _imp_str_literal("LSLA"),
      _imp_str_literal("LSLB"),  _imp_str_literal("ROL"),   _imp_str_literal("ROLA"), _imp_str_literal("ROLB"),
      _imp_str_literal("SBC"),   _imp_str_literal("SBCA"),  _imp_str_literal("SBCB"), _imp_str_literal("ADC"),
      _imp_str_literal("ADCA"),  _imp_str_literal("ADCB"),  _imp_str_literal("NEG"),  _imp_str_literal("NEGA"),
      _imp_str_literal("NEGB"),  _imp_str_literal("COM"),   _imp_str_literal("COMA"), _imp_str_literal("COMB"),
      _imp_str_literal("TST"),   _imp_str_literal("TSTA"),  _imp_str_literal("TSTB"), _imp_str_literal("TSX"),
      _imp_str_literal("INS"),   _imp_str_literal("PUL"),   _imp_str_literal("PULA"), _imp_str_literal("PULB"),
      _imp_str_literal("PULS"),  _imp_str_literal("PULU"),  _imp_str_literal("PSH"),  _imp_str_literal("PSHA"),
      _imp_str_literal("PSHB"),  _imp_str_literal("PSHS"),  _imp_str_literal("PSHU"), _imp_str_literal("DES"),
      _imp_str_literal("TXS"),   _imp_str_literal("RTI"),   _imp_str_literal("WAI"),  _imp_str_literal("CWAI"),
      _imp_str_literal("ANDCC"), _imp_str_literal("ORCC"),  _imp_str_literal("SWI"),  _imp_str_literal("SWI1"),
      _imp_str_literal("SWI2"),  _imp_str_literal("SWI3"),  _imp_str_literal("SBA"),  _imp_str_literal("CBA"),
      _imp_str_literal("ABA"),   _imp_str_literal("TAB"),   _imp_str_literal("TBA"),  _imp_str_literal("DAA"),
      _imp_str_literal("NOP"),   _imp_str_literal("TAP"),   _imp_str_literal("TPA"),  _imp_str_literal("MUL"),
      _imp_str_literal("SEX"),   _imp_str_literal("ABX"),   _imp_str_literal("SYNC"), _imp_str_literal("CLV"),
      _imp_str_literal("SEV"),   _imp_str_literal("CLC"),   _imp_str_literal("SEC"),  _imp_str_literal("CLI"),
      _imp_str_literal("SEI"),   _imp_str_literal("FCB"),   _imp_str_literal("FDB"),  _imp_str_literal("EQU"),
      _imp_str_literal("ORG"),   _imp_str_literal("SETDP"), _imp_str_literal("RMB"),  _imp_str_literal("FCC"),
      _imp_str_literal("NAM"),   _imp_str_literal("OPT"),   _imp_str_literal("PAGE"), _imp_str_literal("SPC"),
      _imp_str_literal("MON"),   _imp_str_literal("END")};
  static const int Icode[198 /*1:198*/] = {
      0x86,   0x86,   0x86,   0xC6,   0xC6,   0xCC,   0x10CE, 0xCE,   0x8E, 0x108E, 0x87,   0x87,   0x87,   0xC7,
      0xC7,   0xCD,   0x10CF, 0xCF,   0x8F,   0x108F, 0x8D,   0x8D,   0x8D, 0x20,   0x20,   0x2100, 0x1021, 0x22,
      0x22,   0x23,   0x23,   0x24,   0x24,   0x24,   0x24,   0x25,   0x25, 0x25,   0x25,   0x26,   0x26,   0x27,
      0x27,   0x28,   0x28,   0x29,   0x29,   0x2A,   0x2A,   0x2B,   0x2B, 0x2C,   0x2C,   0x2D,   0x2D,   0x2E,
      0x2E,   0x2F,   0x2F,   0x0E,   0x39,   0x80,   0x80,   0xC0,   0x83, 0x8B,   0x8B,   0xCB,   0xC3,   0x81,
      0x81,   0xC1,   0x1083, 0x118C, 0x1183, 0x8C,   0x108C, 0x8C,   0x30, 0x32,   0x33,   0x30,   0x31,   0x1E,
      0x1F,   0x0A,   0x4A,   0x5A,   0x0C,   0x4C,   0x5C,   0x0F,   0x4F, 0x5F,   0x3001, 0x301F, 0x84,   0x84,
      0xC4,   0x8A,   0x8A,   0x8A,   0xCa,   0xCa,   0x88,   0x88,   0xC8, 0x85,   0x85,   0xC5,   0x04,   0x44,
      0x54,   0x06,   0x46,   0x56,   0x07,   0x47,   0x57,   0x08,   0x48, 0x58,   0x08,   0x48,   0x58,   0x09,
      0x49,   0x59,   0x82,   0x82,   0xC2,   0x89,   0x89,   0xC9,   0x00, 0x40,   0x50,   0x03,   0x43,   0x53,
      0x0D,   0x4D,   0x5D,   0x1F41, 0x3261, 0x35,   0x3502, 0x3504, 0x35, 0x37,   0x34,   0x3402, 0x3404, 0x34,
      0x36,   0x327F, 0x1F14, 0x3B,   0x3CFF, 0x3C,   0x1C,   0x1A,   0x3F, 0x3F,   0x103F, 0x113F, 0xA0E0, 0xA1E0,
      0xABE0, 0x895D, 0x984D, 0x19,   0x12,   0x1F8A, 0x1FA8, 0x3D,   0x1D, 0x3A,   0x13,   0x1CFD, 0x1A02, 0x1CFE,
      0x1A01, 0x1CEF, 0x1A10, 0x00,   0x00,   0x00,   0x00,   0x00,   0x00, 0x00,   0x00,   0x00,   0x00,   0x00,
      0x00,   0x00};
  static const unsigned char Itype[198 /*1:198*/] = {
      6,  4,  12, 12, 12, 9,  9,  9, 9,  9,  10, 5,  13, 13, 13, 13, 13, 13, 13, 13, 13, 3,  3,  3,  3,  2,  24, 3,  3,
      3,  3,  3,  3,  3,  3,  3,  3, 3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
      3,  14, 1,  8,  12, 12, 9,  8, 12, 12, 9,  7,  12, 12, 9,  9,  9,  9,  9,  9,  16, 17, 17, 17, 17, 18, 18, 15, 1,
      1,  15, 1,  1,  15, 1,  1,  2, 2,  11, 12, 12, 11, 4,  12, 12, 12, 11, 12, 12, 11, 12, 12, 15, 1,  1,  15, 1,  1,
      15, 1,  1,  15, 1,  1,  15, 1, 1,  15, 1,  1,  11, 12, 12, 11, 12, 12, 15, 1,  1,  15, 1,  1,  15, 1,  1,  2,  2,
      19, 2,  2,  20, 20, 19, 2,  2, 20, 20, 2,  2,  1,  2,  21, 21, 21, 23, 1,  1,  1,  25, 25, 25, 22, 22, 1,  1,  2,
      2,  1,  1,  1,  1,  2,  2,  2, 2,  2,  2,  26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37};
  static const int Icycles[198 /*1:198*/] = {
      2,  2,  2,  2,  2, 3, 4, 3, 3, 4, 2,  2, 2, 2, 2, 3, 4, 3, 3, 4, 5, 7, 7, 3, 3, 3,  5,  3,  3, 3, 3,  3,  3,
      3,  3,  3,  3,  3, 3, 3, 3, 3, 3, 3,  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,  1,  5,  2, 2, 2,  4,  2,
      2,  2,  4,  2,  2, 2, 5, 5, 5, 4, 5,  4, 2, 2, 2, 2, 2, 8, 7, 2, 2, 2, 2, 2, 2, 2,  2,  2,  5, 5, 2,  2,  2,
      2,  2,  2,  2,  2, 2, 2, 2, 2, 2, 2,  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,  2,  2,  2, 2, 2,  2,  2,
      2,  2,  2,  2,  2, 2, 2, 2, 2, 2, 2,  6, 5, 5, 6, 6, 5, 5, 5, 6, 6, 5, 5, 5, 6, 15, 21, 21, 3, 3, 19, 19, 20,
      20, 11, 11, 11, 8, 8, 2, 2, 6, 6, 11, 2, 3, 2, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0,  0,  0,  0, 0, 0,  0,  0};
  static const int Nooptions = 51;
  static const _imp_string Optiontext[51 /*1:51*/] = {
      _imp_str_literal("BLANK"),    _imp_str_literal("B"),        _imp_str_literal("NOBLANK"),
      _imp_str_literal("NOB"),      _imp_str_literal("CYCLE"),    _imp_str_literal("C"),
      _imp_str_literal("NOCYCLE"),  _imp_str_literal("NOC"),      _imp_str_literal("DB8"),
      _imp_str_literal("DB10"),     _imp_str_literal("DB16"),     _imp_str_literal("ERROR"),
      _imp_str_literal("E"),        _imp_str_literal("SERROR"),   _imp_str_literal("SER"),
      _imp_str_literal("NOERROR"),  _imp_str_literal("NOE"),      _imp_str_literal("FULL"),
      _imp_str_literal("F"),        _imp_str_literal("NOFULL"),   _imp_str_literal("NOF"),
      _imp_str_literal("GENERATE"), _imp_str_literal("G"),        _imp_str_literal("NOGENERATE"),
      _imp_str_literal("NOG"),      _imp_str_literal("LIST"),     _imp_str_literal("L"),
      _imp_str_literal("SLIST"),    _imp_str_literal("SLIS"),     _imp_str_literal("NOLIST"),
      _imp_str_literal("NOL"),      _imp_str_literal("PAGE"),     _imp_str_literal("P"),
      _imp_str_literal("NOPAGE"),   _imp_str_literal("NOP"),      _imp_str_literal("SYMBOL"),
      _imp_str_literal("S"),        _imp_str_literal("NOSYMBOL"), _imp_str_literal("NOS"),
      _imp_str_literal("TAB"),      _imp_str_literal("T"),        _imp_str_literal("NOTAB"),
      _imp_str_literal("NOT"),      _imp_str_literal("WRAP"),     _imp_str_literal("W"),
      _imp_str_literal("NOWRAP"),   _imp_str_literal("NOW"),      _imp_str_literal("XREF"),
      _imp_str_literal("X"),        _imp_str_literal("NOXREF"),   _imp_str_literal("NOX")};
  auto _imp_string Lc(_imp_string Source);
  auto int /* boolean */ Matches(_imp_string Source, _imp_string Pattern, int Min, int *I);
  auto int /* boolean */ Istyped(_imp_string Source, _imp_string * File);
  auto void Readline(void);
  auto void Nextchar(void);
  auto void Skipblanks(void);
  auto int /* boolean */ Moreitems(void);
  auto int Getname(int *Nid);
  auto int /* boolean */ Getoption(int *Opt);
  auto int /* boolean */ Getinstr(int *Id);
  auto int Getopd(int *Opd);
  auto int Getterm(int *Opd);
  auto int Getexpression(int *Opd);
  auto void Evaluate(int *A, int B, unsigned char Op);
  auto int Getconst(int *Cval);
  auto void Analiseoperand(int Eca, int *Post, int *Opd, int *Type, int *Cycles);
  auto void Outsymbol(unsigned char Char);
  auto void Outtag(int *I, int *J, int Col);
  auto void Instrout(int Op, int Post, int Opd, int B, int Cyc);
  auto void Close(void);
  auto void Fault(_imp_string S);
  auto void Nline(int N);
  auto void Printnumber(int N, int D);
  auto int /* boolean */ Accumulator(void);
  auto int /* boolean */ Acc(unsigned char Accid);
  auto int /* boolean */ Autoindexed(int *Post, int *Cycles);
  auto int /* boolean */ Cc(void);
  auto int /* boolean */ Dp(void);
  auto int /* boolean */ Pc(void);
  auto int /* boolean */ Pcrelative(void);
  auto int /* boolean */ Indexreg(int *Reg);
  auto int /* boolean */ Transferreg(int *Reg);
  auto void Sqs(int L, int R);
  unsigned char Buffer[16 /*1:16*/];
  unsigned char Line[513 /*1:513*/];
  int Ca;
  int Pass;
  int Faults;
  int Lp;
  int Opd;
  int Iid;
  int Lid;
  int Ln;
  int Nnames;
  int I;
  int J;
  int K;
  int Opt;
  int Order;
  int Consistent;
  int Lastconsistent;
  int Headset;
  int Preschar;
  int Delim;
  int Drad;
  int Bchar;
  int Pflag;
  int Sflag;
  int Gflag;
  int Eflag;
  int Lflag;
  int Cflag;
  int Wflag;
  int Tflag;
  int Xflag;
  int Cont;
  int Sp1;
  int Sp2;
  int Sp3;
  int Oldca;
  int Mcycles;
  int Nondense;
  int Accop;
  int Bufferca;
  int Bp;
  int L;
  int Xxentries;
  int Post;
  int Type;
  int Accfault;
  int Dpcontents;
  int Fflag;
  int Ostarted;
  int Eca;
  int Lookahead;
  int Diff;
  int Nolongs;
  int Lastnolongs;
  static const int Nhash = 67;
  int Hnlink[67 /*0:66*/];
  _imp_string Name[1023 /*1:1023*/];
  int Nval[1023 /*1:1023*/];
  int Xhead[1023 /*1:1023*/];
  int Ndiff[1023 /*1:1023*/];
  int Nlink[1023 /*1:1023*/];
  unsigned char Nass[1023 /*1:1023*/];
  int Xentry[4096 /*1:4096*/];
  int Xlink[4096 /*1:4096*/];
  static int Optionaction_sw;
  static void *Optionaction[53 /*-1:51*/] = {
      &&Optionaction_M1, &&Optionaction_0,  &&Optionaction_1,  &&Optionaction_2,  &&Optionaction_3,  &&Optionaction_4,
      &&Optionaction_5,  &&Optionaction_6,  &&Optionaction_7,  &&Optionaction_8,  &&Optionaction_9,  &&Optionaction_10,
      &&Optionaction_11, &&Optionaction_12, &&Optionaction_13, &&Optionaction_14, &&Optionaction_15, &&Optionaction_16,
      &&Optionaction_17, &&Optionaction_18, &&Optionaction_19, &&Optionaction_20, &&Optionaction_21, &&Optionaction_22,
      &&Optionaction_23, &&Optionaction_24, &&Optionaction_25, &&Optionaction_26, &&Optionaction_27, &&Optionaction_28,
      &&Optionaction_29, &&Optionaction_30, &&Optionaction_31, &&Optionaction_32, &&Optionaction_33, &&Optionaction_34,
      &&Optionaction_35, &&Optionaction_36, &&Optionaction_37, &&Optionaction_38, &&Optionaction_39, &&Optionaction_40,
      &&Optionaction_41, &&Optionaction_42, &&Optionaction_43, &&Optionaction_44, &&Optionaction_45, &&Optionaction_46,
      &&Optionaction_47, &&Optionaction_48, &&Optionaction_49, &&Optionaction_50, &&Optionaction_51,
  };
  static int Itype1_sw;
  static void *Itype1[37 /*1:37*/] = {
      &&Itype1_1,  &&Itype1_2,  &&Itype1_3,  &&Itype1_4,  &&Itype1_5,  &&Itype1_6,  &&Itype1_7,  &&Itype1_8,
      &&Itype1_9,  &&Itype1_10, &&Itype1_11, &&Itype1_12, &&Itype1_13, &&Itype1_14, &&Itype1_15, &&Itype1_16,
      &&Itype1_17, &&Itype1_18, &&Itype1_19, &&Itype1_20, &&Itype1_21, &&Itype1_22, &&Itype1_23, &&Itype1_24,
      &&Itype1_25, &&Itype1_26, &&Itype1_27, &&Itype1_28, &&Itype1_29, &&Itype1_30, &&Itype1_31, &&Itype1_32,
      &&Itype1_33, &&Itype1_34, &&Itype1_35, &&Itype1_36, &&Itype1_37,
  };
  static int Itype3_sw;
  static void *Itype3[37 /*1:37*/] = {
      &&Itype3_1,  &&Itype3_2,  &&Itype3_3,  &&Itype3_4,  &&Itype3_5,  &&Itype3_6,  &&Itype3_7,  &&Itype3_8,
      &&Itype3_9,  &&Itype3_10, &&Itype3_11, &&Itype3_12, &&Itype3_13, &&Itype3_14, &&Itype3_15, &&Itype3_16,
      &&Itype3_17, &&Itype3_18, &&Itype3_19, &&Itype3_20, &&Itype3_21, &&Itype3_22, &&Itype3_23, &&Itype3_24,
      &&Itype3_25, &&Itype3_26, &&Itype3_27, &&Itype3_28, &&Itype3_29, &&Itype3_30, &&Itype3_31, &&Itype3_32,
      &&Itype3_33, &&Itype3_34, &&Itype3_35, &&Itype3_36, &&Itype3_37,
  };
  _imp_string Header;
  _imp_string *File;
  _imp_string Params;
  _imp_string Source;
  _imp_string List;
  _imp_string Object;
  _imp_string Dummy;
  if (_imp_on_event(9)) {
    Selectoutput(0);
    Printstring(Event.Message);
    Newline();
    exit(0);
  }
  Params = Lc(Cliparam());
  Source = _imp_str_literal("");
  List = _imp_str_literal(".n");
  Object = _imp_str_literal("");
  Dummy = _imp_str_literal("");
  for (;;) {
    I = 1;
    while (I <= *Length(Params) && *Charno(Params, I) == ' ') I++;
    if (I > *Length(Params)) break;
    Params = Substring(Params, I, *Length(Params));
    if (*Charno(Params, 1) == '/') {
      Params = Substring(Params, 2, *Length(Params));
      if (Matches(Params, _imp_str_literal("list"), 1, I)) {
        List = _imp_str_literal("");
        File = &List;
      } else if (Matches(Params, _imp_str_literal("object"), 1, I)) {
        Object = _imp_str_literal("");
        File = &Object;
      } else if (Matches(Params, _imp_str_literal("nolist"), 3, I)) {
        List = _imp_str_literal(".n");
        File = &Dummy;
      } else if (Matches(Params, _imp_str_literal("noobject"), 3, I)) {
        Object = _imp_str_literal(".n");
        File = &Dummy;
      } else {
        I = 1;
        File = &Dummy;
      }
      if (I > *Length(Params)) break;
      Params = Substring(Params, I, *Length(Params));
      if (*Charno(Params, 1) != '=') continue;
      if (*Length(Params) > 1)
        Params = Substring(Params, 2, *Length(Params));
      else
        Params = _imp_str_literal("");
    } else
      File = &Source;
    I = 1;
    while (I <= *Length(Params) && *Charno(Params, I) != ' ' && *Charno(Params, I) != '/') I++;
    if (I > 1) *File = Substring(Params, 1, I - 1);
    if (I > *Length(Params)) break;
    Params = Substring(Params, I, *Length(Params));
  }
  if (*Length(Source) == 0) {
    Selectoutput(0);
    Printstring(_imp_str_literal("No source file specified."));
    Newline();
    exit(0);
  }
  if (!Istyped(Source, Params)) Source = _imp_join(Source, _imp_str_literal(".asm"));
  if (*Length(List) == 0) List = Params;
  if (*Length(Object) == 0) Object = Params;
  if (!Istyped(List, Dummy)) List = _imp_join(List, _imp_str_literal(".lis"));
  if (!Istyped(Object, Dummy)) Object = _imp_join(Object, _imp_str_literal(".obj"));
  Openinput(1, Source);
  Openoutput(1, Object);
  Openoutput(2, List);
  Selectoutput(2);
  Headset = 0;
  Header = _imp_str_literal("");
  Drad = 8;
  Sp1 = 2;
  Sp2 = 4;
  Pflag = 3;
  Sflag = 0;
  Eflag = 1;
  Gflag = 1;
  Lflag = 2;
  Cflag = 0;
  Wflag = 0;
  Tflag = 1;
  Xflag = 0;
  Sp3 = Linewidth - Sp1 - Sp2 * 3 - Cflag * 3 - Wflag - 11;
  Cont = 0;
  Faults = 0;
  Nnames = 0;
  Xxentries = 0;
  Consistent = 0;
  Lastconsistent = 0;
  Lastnolongs = 0;
  for (I = 0; I <= Nhash - 1; I++) Hnlink[I] = 0;
  Ostarted = 0;
  Bp = 0;
  Lookahead = 0;
  Selectinput(1);
  Pass = 1;
  for (;;) {
    Ln = 0;
    Dpcontents = 0;
    Ca = 0;
    Bchar = -1;
    Fflag = 0;
    Nolongs = 0;
    for (;;) {
      Readline();
      if (Preschar == '*') continue;
      if (!Getname(Lid))
        if (Pass == 1)
          if (!Nass[Lid]) {
            Nval[Lid] = Ca;
            Nass[Lid] = 1;
          } else {
            Nval[Lid] = 0;
            Nass[Lid] = 2;
          }
        else if (Nass[Lid] == 1 && Ca != Nval[Lid]) {
          Diff = Nval[Lid] - Ca;
          Nval[Lid] = Ca;
          if (Pass == 3) {
            for (I = 1; I <= Consistent; I++)
              if (Ndiff[I] == Diff) goto Difffound;
            Consistent++;
            Ndiff[Consistent] = Diff;
          Difffound:;
          }
        } else
          Lid = 0;
      while (Preschar == ' ') Nextchar();
      if (!Getinstr(Iid)) continue;
      while (Preschar == ' ') Nextchar();
      if (Itype[Iid] <= 25)
        if (0 <= Icode[Iid] && Icode[Iid] <= 255)
          Ca++;
        else
          Ca += 2;
      goto *Itype1[Itype1_sw = (Itype[Iid]) - 1];
    Itype1_1:;
    Itype1_2:;
      continue;
    Itype1_3:;
      if (Pass < 3 || Getopd(Opd) != 0 || -128 <= Opd - Ca - 1 && Opd - Ca - 1 <= 127)
        Ca++;
      else if (Icode[Iid] == 0x20 || Icode[Iid] == 0x8D) {
        Ca += 2;
        Nolongs++;
      } else {
        Ca += 3;
        Nolongs++;
      }
      continue;
    Itype1_4:;
      if (Preschar == '#') {
        Ca++;
        continue;
      }
      Analiseoperand(Ca, Post, Opd, Type, Mcycles);
      if (1 <= Type && Type <= 2) {
        Skipblanks();
        goto *Itype1[Itype1_sw = (12) - 1];
      }
      goto Analisedouble;
    Itype1_5:;
      Analiseoperand(Ca, Post, Opd, Type, Mcycles);
      if (1 <= Type && Type <= 2) {
        Skipblanks();
        goto *Itype1[Itype1_sw = (13) - 1];
      }
      goto Analisedouble;
    Itype1_6:;
      if (Accumulator()) {
        Skipblanks();
        goto *Itype1[Itype1_sw = (12) - 1];
      } else if (Acc('S') || Acc('Y'))
        Ca++;
      else if (!(Acc('D') || Acc('U') || Acc('X')))
        goto *Itype1[Itype1_sw = (12) - 1];
      Skipblanks();
      goto *Itype1[Itype1_sw = (9) - 1];
    Itype1_7:;
      if (Accumulator()) {
        Skipblanks();
        goto *Itype1[Itype1_sw = (12) - 1];
      } else if (Acc('D') || Acc('S') || Acc('U') || Acc('Y'))
        Ca++;
      else if (!Acc('X'))
        goto *Itype1[Itype1_sw = (12) - 1];
      Skipblanks();
      goto *Itype1[Itype1_sw = (9) - 1];
    Itype1_8:;
      if (Accumulator()) {
        Skipblanks();
        goto *Itype1[Itype1_sw = (12) - 1];
      } else if (Acc('D'))
        Skipblanks();
      else
        goto *Itype1[Itype1_sw = (12) - 1];
    Itype1_9:;
      if (Preschar == '#') {
        Ca += 2;
        continue;
      }
      goto *Itype1[Itype1_sw = (13) - 1];
    Itype1_10:;
      if (Acc('S') || Acc('Y')) {
        Ca++;
        Skipblanks();
      } else if (Acc('D') || Acc('U') || Acc('X') || Accumulator())
        Skipblanks();
      goto *Itype1[Itype1_sw = (13) - 1];
    Itype1_11:;
      if (Accumulator()) Skipblanks();
    Itype1_12:;
      if (Preschar == '#') {
        Ca++;
        continue;
      }
    Itype1_13:;
    Itype1_14:;
      Analiseoperand(Ca, Post, Opd, Type, Mcycles);
    Analisedouble:;
      if (Type <= 3)
        Ca++;
      else if (Type == 4) {
        Ca += 2;
        Nolongs++;
      } else {
        Ca = Ca + Type - 4;
        Nolongs = Nolongs + Type - 5;
      }
      continue;
    Itype1_15:;
      Analiseoperand(Ca, Post, Opd, Type, Mcycles);
      if (3 <= Type && Type <= 4) {
        Ca = Ca + Type - 2;
        Nolongs = Nolongs + Type - 3;
      } else if (Type >= 5) {
        Ca = Ca + Type - 4;
        Nolongs = Nolongs + Type - 5;
      }
      continue;
    Itype1_16:;
      if (Indexreg(I)) Skipblanks();
    Itype1_17:;
      Analiseoperand(Ca, Post, Opd, Type, Mcycles);
      if (Type <= 5)
        Ca++;
      else {
        Ca = Ca + Type - 4;
        Nolongs = Nolongs + Type - 5;
      }
      continue;
    Itype1_18:;
    Itype1_19:;
    Itype1_20:;
    Itype1_21:;
    Itype1_22:;
      Ca++;
      continue;
    Itype1_23:;
      if (Acc('2') || Acc('3')) Ca++;
      continue;
    Itype1_24:;
    Itype1_25:;
      Ca += 2;
      continue;
    Itype1_26:;
      do {
        Ca++;
        if (Preschar != ',') I = Getopd(Opd);
      } while (Moreitems());
      continue;
    Itype1_27:;
      do {
        Ca += 2;
        if (Preschar != ',') I = Getopd(Opd);
      } while (Moreitems());
      continue;
    Itype1_28:;
      if (Lid)
        if (!Getopd(Opd))
          if (Pass == 1) {
            if (Nass[Lid] == 1) {
              Nval[Lid] = Opd;
              Nass[Lid] = 3;
            }
          } else if (Nass[Lid] == 3 && Opd != Nval[Lid]) {
            Diff = Nval[Lid] - Opd;
            Nval[Lid] = Opd;
            if (Pass == 3) {
              for (I = 1; I <= Consistent; I++)
                if (Ndiff[I] == Diff) goto Equdifffound;
              Consistent++;
              Ndiff[Consistent] = Diff;
            Equdifffound:;
            }
          } else if (Nass[Lid] != 2) {
            Nval[Lid] = 0;
            Nass[Lid] = 4;
          }
      continue;
    Itype1_29:;
      if (Lid) {
        Nval[Lid] = 0;
        Nass[Lid] = 4;
      }
      if (!Getopd(Opd)) Ca = Opd;
      continue;
    Itype1_30:;
      if (Lid) {
        Nval[Lid] = 0;
        Nass[Lid] = 4;
      }
      if (!Getopd(Opd)) Dpcontents = Opd << 8;
      continue;
    Itype1_31:;
      if (!Getopd(Opd)) Ca += Opd;
      continue;
    Itype1_32:;
      if ('0' <= Preschar && Preschar <= '9') {
        I = Lp;
        J = 0;
        do {
          J = J * 10 + Preschar - '0';
          Nextchar();
        } while ('0' <= Preschar && Preschar <= '9');
        if (Preschar == ',') {
          Ca += J;
          continue;
        }
        Lp = I - 1;
        Nextchar();
      }
      if (Preschar < ' ') continue;
      Delim = Preschar;
      Nextchar();
      for (;;) {
        if (Preschar == Nl) break;
        if (Preschar == Delim) {
          Nextchar();
          if (Preschar != Delim) break;
        }
        Nextchar();
        Ca++;
      }
      continue;
    Itype1_33:;
      if (Lid) {
        Nval[Lid] = 0;
        Nass[Lid] = 4;
      }
      if (Headset) continue;
      Headset = 1;
      Header = _imp_str_literal("");
      while (Preschar != Nl) {
        Header = _imp_join(Header, Tostring(Line[Lp]));
        Nextchar();
      }
      continue;
    Itype1_34:;
      do
        if (Getoption(Opt))
          if (1 <= Opt && Opt <= 2)
            Bchar = ' ';
          else if (3 <= Opt && Opt <= 4)
            Bchar = -1;
          else if (18 <= Opt && Opt <= 19)
            Fflag = 1;
          else if (20 <= Opt && Opt <= 21)
            Fflag = 0;
      while (Moreitems());
    Itype1_35:;
    Itype1_36:;
      if (Lid) {
        Nval[Lid] = 0;
        Nass[Lid] = 4;
      }
    }
  Itype1_37:;
    if (Lid) {
      Nval[Lid] = 0;
      Nass[Lid] = 2;
    }
    if (Pass < 3)
      Pass++;
    else {
      if (Consistent == 0 || (Lastconsistent != 0 && Consistent >= Lastconsistent && Nolongs >= Lastnolongs)) break;
      Lastconsistent = Consistent;
    }
    Lastnolongs = Nolongs;
    Consistent = 0;
    Resetinput();
  }
  Nline(0);
  Resetinput();
  Pass = 4;
  Ln = 0;
  Ca = 0;
  Dpcontents = 0;
  Oldca = 0;
  Lid = 0;
  Bchar = -1;
  Fflag = 0;
  for (;;) {
    if (Lid) {
      if (Nass[Lid] == 2) Fault(_imp_str_literal("Multiply defined label"));
      if (Nass[Lid] == 1 && Nval[Lid] != Oldca) {
        Fault(_imp_str_literal("Inconsistent label"));
        Nval[Lid] = Oldca;
      }
    }
    Oldca = Ca;
    Lid = 0;
    Readline();
    Accop = 0;
    Accfault = 0;
    Nondense = 0;
    if (Preschar == '*') {
      Instrout(0, 0, 0, -7, 0);
      continue;
    }
    if (Getname(Lid)) Lid = 0;
    Skipblanks();
    if (Preschar == Nl)
      Instrout(0, 0, 0, -7, 0);
    else if (Getinstr(Iid)) {
      Order = Icode[Iid];
      if (0 <= Order && Order <= 255)
        Eca = Ca + 1;
      else
        Eca = Ca + 2;
      Mcycles = Icycles[Iid];
      Skipblanks();
      goto *Itype3[Itype3_sw = (Itype[Iid]) - 1];
    } else {
      Instrout(0, 0, 0, -7, 0);
      Fault(_imp_str_literal("Unknown operation"));
    }
    continue;
  Itype3_1:;
    Instrout(Order, 0, 0, 1, Mcycles);
    continue;
  Itype3_2:;
    Instrout(((unsigned)Order >> 8) & 255, Order & 255, 0, 2, Mcycles);
    continue;
  Itype3_3:;
    I = Getopd(Opd);
    J = Opd - Eca - 1;
    if (I != 0 || -128 <= J && J <= 127) {
      Instrout(Order, J, 0, 2, Mcycles);
      if (I) Fault(_imp_str_literal("Cannot evaluate operand"));
    } else if (Order == 0x20)
      Instrout(0x16, J - 1, 0, 5, Mcycles + 2);
    else if (Order == 0x8D)
      Instrout(0x17, J - 1, 0, 5, Mcycles + 2);
    else
      Instrout(0x1000 + Order, J - 2, 0, 5, Mcycles + 3);
    continue;
  Itype3_4:;
    if (Preschar == '#') goto *Itype3[Itype3_sw = (12) - 1];
    Analiseoperand(Eca, Post, Opd, Type, Mcycles);
    if (1 <= Type && Type <= 2) {
      if (Type == 2) Order += 0x40;
      Accop = 1;
      Skipblanks();
      goto *Itype3[Itype3_sw = (12) - 1];
    }
    goto Generatedouble;
  Itype3_5:;
    Analiseoperand(Eca, Post, Opd, Type, Mcycles);
    if (1 <= Type && Type <= 2) {
      if (Type == 2) Order += 0x40;
      Accop = 1;
      Skipblanks();
      goto *Itype3[Itype3_sw = (13) - 1];
    }
    goto Generatedouble;
  Itype3_6:;
    Accop = 1;
    if (Acc('A')) {
      Skipblanks();
      goto *Itype3[Itype3_sw = (12) - 1];
    } else if (Acc('B')) {
      Order = 0xC6;
      Skipblanks();
      goto *Itype3[Itype3_sw = (12) - 1];
    } else if (Acc('D'))
      Order = 0xCC;
    else if (Acc('U'))
      Order = 0xCE;
    else if (Acc('X'))
      Order = 0x8E;
    else if (Acc('S')) {
      Order = 0x10CE;
      Mcycles++;
    } else if (Acc('Y')) {
      Order = 0x108E;
      Mcycles++;
    } else {
      Accfault = 2;
      Accop = 0;
      goto *Itype3[Itype3_sw = (12) - 1];
    }
    Skipblanks();
    Mcycles++;
    goto *Itype3[Itype3_sw = (9) - 1];
  Itype3_7:;
    Accop = 1;
    if (Acc('A')) {
      Skipblanks();
      goto *Itype3[Itype3_sw = (12) - 1];
    } else if (Acc('B')) {
      Order = 0xC1;
      Skipblanks();
      goto *Itype3[Itype3_sw = (12) - 1];
    } else if (Acc('D')) {
      Order = 0x1083;
      Mcycles++;
    } else if (Acc('U')) {
      Order = 0x1183;
      Mcycles++;
    } else if (Acc('X'))
      Order = 0x8C;
    else if (Acc('S')) {
      Order = 0x118C;
      Mcycles++;
    } else if (Acc('Y')) {
      Order = 0x108C;
      Mcycles++;
    } else {
      Accfault = 2;
      Accop = 0;
      goto *Itype3[Itype3_sw = (12) - 1];
    }
    Skipblanks();
    Mcycles += 2;
    goto *Itype3[Itype3_sw = (9) - 1];
  Itype3_8:;
    Accop = 1;
    if (Acc('A')) {
      Skipblanks();
      goto *Itype3[Itype3_sw = (12) - 1];
    } else if (Acc('B')) {
      Order += 0x40;
      Skipblanks();
      goto *Itype3[Itype3_sw = (12) - 1];
    } else if (Acc('D'))
      if (Order == 0x80)
        Order = 0x83;
      else
        Order = 0xC3;
    else {
      Accfault = 1;
      Accop = 0;
      goto *Itype3[Itype3_sw = (12) - 1];
    }
    Skipblanks();
    Mcycles += 2;
  Itype3_9:;
    if (Preschar == '#') {
      do
        Nextchar();
      while (Preschar == Bchar);
      I = Getopd(Opd);
      Instrout(Order, Opd, 0, 5, Mcycles);
      if (I) Fault(_imp_str_literal("Cannot evaluate operand"));
      continue;
    }
    goto *Itype3[Itype3_sw = (13) - 1];
  Itype3_10:;
    Accop = 1;
    if (Acc('B'))
      Order = 0xC7;
    else if (Acc('D')) {
      Order = 0xCD;
      Mcycles++;
    } else if (Acc('U')) {
      Order = 0xCF;
      Mcycles++;
    } else if (Acc('X')) {
      Order = 0x8F;
      Mcycles++;
    } else if (Acc('S')) {
      Order = 0x10CF;
      Mcycles += 2;
    } else if (Acc('Y')) {
      Order = 0x108F;
      Mcycles += 2;
    } else if (!Acc('A')) {
      Accfault = 2;
      Accop = 0;
    }
    Skipblanks();
    goto *Itype3[Itype3_sw = (13) - 1];
  Itype3_11:;
    Accop = 1;
    if (Acc('B'))
      Order += 0x40;
    else if (!Acc('A')) {
      Accop = 0;
      Accfault = 1;
    }
    Skipblanks();
  Itype3_12:;
    if (Preschar == '#') {
      do
        Nextchar();
      while (Preschar == Bchar);
      I = Getopd(Opd);
      Instrout(Order, Opd, 0, 2, Mcycles);
      if (I)
        Fault(_imp_str_literal("Cannot evaluate operand"));
      else if (-128 > Opd || Opd > 255)
        Fault(_imp_str_literal("Invalid constant"));
      continue;
    }
  Itype3_13:;
    Analiseoperand(Eca, Post, Opd, Type, Mcycles);
  Generatedouble:;
    if (Type <= 3) {
      Instrout(Order + 0x10, Opd, 0, 2, Mcycles);
      if (!Type)
        Fault(_imp_str_literal("Cannot evaluate operand"));
      else if (Type != 3)
        Fault(_imp_str_literal("Illegal operand"));
    } else if (Type == 4)
      Instrout(Order + 0x30, Opd, 0, 5, Mcycles);
    else
      Instrout(Order + 0x20, Post, Opd, Type - 3, Mcycles);
    if (Accfault == 1) Fault(_imp_str_literal("Accumulator not specified"));
    if (Accfault == 2) Fault(_imp_str_literal("Register not specified"));
    continue;
  Itype3_14:;
    Analiseoperand(Eca, Post, Opd, Type, Mcycles);
    if (Type <= 3) {
      Instrout(Order, Opd, 0, 2, Mcycles);
      if (!Type)
        Fault(_imp_str_literal("Cannot evaluate operand"));
      else if (Type != 3)
        Fault(_imp_str_literal("Illegal operand"));
    } else if (Type == 4)
      Instrout(Order + 0x70, Opd, 0, 5, Mcycles);
    else
      Instrout(Order + 0x60, Post, Opd, Type - 3, Mcycles);
    continue;
  Itype3_15:;
    Analiseoperand(Eca, Post, Opd, Type, Mcycles);
    if (Type <= 1) {
      if (Type == 1) Accop = 1;
      Instrout(Order + 0x40, 0, 0, 1, Mcycles);
      if (!Type) Fault(_imp_str_literal("Cannot evaluate operand"));
    } else if (Type == 2) {
      Accop = 1;
      Instrout(Order + 0x50, 0, 0, 1, Mcycles);
    } else if (Type == 3)
      Instrout(Order, Opd, 0, 2, Mcycles + 2);
    else if (Type == 4)
      Instrout(Order + 0x70, Opd, 0, 5, Mcycles + 2);
    else
      Instrout(Order + 0x60, Post, Opd, Type - 3, Mcycles + 2);
    continue;
  Itype3_16:;
    Accop = 1;
    if (Acc('X'))
      Order = 0x30;
    else if (Acc('Y'))
      Order = 0x31;
    else if (Acc('S'))
      Order = 0x32;
    else if (Acc('U'))
      Order = 0x33;
    else {
      Accfault = 2;
      Accop = 0;
    }
    Skipblanks();
  Itype3_17:;
    Analiseoperand(Eca, Post, Opd, Type, Mcycles);
    if (Type <= 5) {
      Instrout(Order, Post, Opd, 2, Mcycles);
      if (!Type)
        Fault(_imp_str_literal("Cannot evaluate operand"));
      else if (Type != 5)
        Fault(_imp_str_literal("Illegal operand"));
    } else
      Instrout(Order, Post, Opd, Type - 3, Mcycles);
    if (Accfault) Fault(_imp_str_literal("Index register not specified"));
    continue;
  Itype3_18:;
    if (Transferreg(Post)) {
      if (!Moreitems()) Accop = 1;
      if (Transferreg(Opd)) {
        Instrout(Order, (Post << 4) | Opd, 0, 2, Mcycles);
        if ((Post < 8 && 8 <= Opd) || (Opd < 8 && 8 <= Post)) Fault(_imp_str_literal("Different size registers"));
      } else {
        Instrout(Order, Post << 4, 0, 2, Mcycles);
        Fault(_imp_str_literal("Second register not specified"));
      }
    } else {
      Instrout(Order, 0, 0, 2, Mcycles);
      Fault(_imp_str_literal("Registers not specified"));
    }
    continue;
  Itype3_19:;
    Accop = 1;
    if (Acc('A')) {
      Instrout(Order, 2, 0, 2, Mcycles + 1);
      continue;
    } else if (Acc('B')) {
      Instrout(Order, 4, 0, 2, Mcycles + 1);
      continue;
    } else if (Acc('U'))
      Order += 2;
    else if (!Acc('S')) {
      Accop = 0;
      Accfault = 1;
    }
    Skipblanks();
  Itype3_20:;
    Post = 0;
    I = 0;
    J = 0;
    do
      if (Cc()) {
        if (!(Post & 1)) {
          Mcycles++;
          Post = Post | 1;
        }
      } else if (Acc('A')) {
        if (!(Post & 2)) {
          Mcycles++;
          Post = Post | 2;
        }
      } else if (Acc('B')) {
        if (!(Post & 4)) {
          Mcycles++;
          Post = Post | 4;
        }
      } else if (Acc('D')) {
        if (!(Post & 2)) {
          Mcycles++;
          Post = Post | 2;
        }
        if (!(Post & 4)) {
          Mcycles++;
          Post = Post | 4;
        }
      } else if (Dp()) {
        if (!(Post & 8)) {
          Mcycles++;
          Post = Post | 8;
        }
      } else if (Acc('X')) {
        if (!(Post & 16)) {
          Mcycles += 2;
          Post = Post | 16;
        }
      } else if (Acc('Y')) {
        if (!(Post & 32)) {
          Mcycles += 2;
          Post = Post | 32;
        }
      } else if (Acc('S'))
        if (0x36 <= Order && Order <= 0x37) {
          if (!(Post & 64)) {
            Mcycles += 2;
            Post = Post | 64;
          }
        } else
          I++;
      else if (Acc('U'))
        if (0x34 <= Order && Order <= 0x35) {
          if (!(Post & 64)) {
            Mcycles += 2;
            Post = Post | 64;
          }
        } else
          I++;
      else if (Pc()) {
        if (!(Post & 128)) {
          Mcycles += 2;
          Post = Post | 128;
        }
      } else if (Preschar == ',')
        Nextchar();
      else {
        J = 1;
        break;
      }
    while (Moreitems());
    Instrout(Order, Post, 0, 2, Mcycles);
    if (Accfault) Fault(_imp_str_literal("Stack not specified"));
    for (I = I; I >= 1; I--) Fault(_imp_str_literal("Cannot stack stack pointer"));
    if (J) Fault(_imp_str_literal("Illegal operand"));
    continue;
  Itype3_21:;
    if (Preschar == '#') do
        Nextchar();
      while (Preschar == Bchar);
    I = Getopd(Opd);
    Instrout(Order, Opd, 0, 2, Mcycles);
    if (I)
      Fault(_imp_str_literal("Cannot evaluate operand"));
    else if (0 > Opd || Opd > 255)
      Fault(_imp_str_literal("Illegal mask"));
    continue;
  Itype3_22:;
    Instrout(0x1F, ((unsigned)Order >> 8) & 255, Order & 255, 3, Mcycles);
    continue;
  Itype3_23:;
    if (Acc('1'))
      Accop = 1;
    else if (Acc('2')) {
      Accop = 1;
      Order = Order | 0x1000;
      Mcycles++;
    } else if (Acc('3')) {
      Accop = 1;
      Order = Order | 0x1100;
      Mcycles++;
    }
    Instrout(Order, 0, 0, 1, Mcycles);
    continue;
  Itype3_24:;
    Instrout(Order, 0, 0, 5, Mcycles);
    continue;
  Itype3_25:;
    Instrout(0x34, 0x04, Order, 4, Mcycles);
    continue;
  Itype3_26:;
    do {
      if (Preschar == ',') {
        Opd = 0;
        I = 0;
      } else
        I = Getopd(Opd);
      if (!Cont) {
        J = Lp;
        Lookahead = 1;
        while (Moreitems())
          if (Preschar != ',') K = Getopd(K);
        Lookahead = 0;
        Instrout(0, Opd & 255, 0, -1, 0);
        Lp = J - 1;
        Nextchar();
        Cont = 1;
      } else
        Instrout(0, Opd & 255, 0, -1, 0);
      if (I != 0 || -128 > Opd || Opd > 255) Fault(_imp_str_literal("Invalid constant"));
    } while (Moreitems());
    Cont = 0;
    continue;
  Itype3_27:;
    do {
      if (Preschar == ',') {
        Opd = 0;
        I = 0;
      } else
        I = Getopd(Opd);
      if (!Cont) {
        J = Lp;
        Lookahead = 1;
        while (Moreitems())
          if (Preschar != ',') K = Getopd(K);
        Lookahead = 0;
        Instrout(0, Opd, 0, -2, 0);
        Lp = J - 1;
        Nextchar();
        Cont = 1;
      } else
        Instrout(0, Opd, 0, -2, 0);
      if (I) Fault(_imp_str_literal("Invalid constant"));
    } while (Moreitems());
    Cont = 0;
    continue;
  Itype3_28:;
    I = Getopd(Opd);
    Instrout(0, Opd, 0, -6, 0);
    if (!Lid) Fault(_imp_str_literal("No name to equate"));
    if (I) Fault(_imp_str_literal("Cannot evaluate operand"));
    if (Lid != 0 && I == 0 && Nass[Lid] == 3 && Nval[Lid] != Opd) {
      Fault(_imp_str_literal("Inconsistent label"));
      Nval[Lid] = Opd;
    }
    continue;
  Itype3_29:;
    I = Getopd(Opd);
    if (!I) Ca = Opd;
    Instrout(0, 0, 0, 0, 0);
    if (Lid) Fault(_imp_str_literal("Illegal label"));
    if (I) Fault(_imp_str_literal("Cannot evaluate operand"));
    continue;
  Itype3_30:;
    I = Getopd(Opd);
    if (I == 0 && 0 <= Opd && Opd <= 255) Dpcontents = Opd << 8;
    Instrout(0, Opd, 0, -3, 0);
    if (Lid) Fault(_imp_str_literal("Illegal label"));
    if (I)
      Fault(_imp_str_literal("Cannot evaluate operand"));
    else if (0 > Opd || Opd > 255)
      Fault(_imp_str_literal("Invalid direct page contents"));
    continue;
  Itype3_31:;
    I = Getopd(Opd);
    Instrout(0, Opd, 0, -4, 0);
    if (!I)
      Ca += Opd;
    else
      Fault(_imp_str_literal("Cannot evaluate operand"));
    continue;
  Itype3_32:;
    Nondense = 1;
    if ('0' <= Preschar && Preschar <= '9') {
      I = 0;
      J = Lp;
      do {
        I = I * 10 + Preschar - '0';
        Nextchar();
      } while ('0' <= Preschar && Preschar <= '9');
      if (Preschar == ',') {
        Nextchar();
        if (!I) {
          Instrout(0, 0, 0, 0, 0);
          Fault(_imp_str_literal("Invalid string"));
        } else {
          while (I > 0) {
            if (Preschar == Nl)
              Opd = ' ';
            else {
              Opd = Line[Lp];
              Nextchar();
            }
            I--;
            if (!Cont) {
              J = Lp;
              for (K = 1; K <= I; K++) {
                if (Preschar == Nl) break;
                Nextchar();
              }
              Instrout(0, Opd, 0, -1, 0);
              Lp = J - 1;
              Nextchar();
              Cont = 1;
            } else
              Instrout(0, Opd, 0, -1, 0);
          }
          Cont = 0;
        }
        continue;
      } else {
        Lp = J - 1;
        Nextchar();
      }
    }
    if (Preschar < ' ') {
      while (Preschar != Nl) Nextchar();
      Instrout(0, 0, 0, 0, 0);
      Fault(_imp_str_literal("Invalid string delimiter"));
    } else {
      Delim = Preschar;
      Nextchar();
      for (;;) {
        if (Preschar == Nl) {
          if (!Cont) {
            Instrout(0, 0, 0, 0, 0);
            Fault(_imp_str_literal("Invalid string"));
          }
          break;
        }
        if (Preschar == Delim) {
          Nextchar();
          if (Preschar != Delim) {
            if (!Cont) {
              Instrout(0, 0, 0, 0, 0);
              Fault(_imp_str_literal("Invalid string"));
            }
            break;
          }
        }
        if (!Cont) {
          I = Lp;
          for (;;) {
            while (Preschar != Delim && Preschar != Nl) Nextchar();
            if (Preschar == Delim) Nextchar();
            if (Preschar != Delim) break;
            Nextchar();
          }
          Instrout(0, Line[I], 0, -1, 0);
          Lp = I - 1;
          Nextchar();
          Cont = 1;
        } else
          Instrout(0, Line[Lp], 0, -1, 0);
        Nextchar();
      }
      Cont = 0;
    }
    continue;
  Itype3_33:;
    Nondense = 1;
    Header = _imp_str_literal("");
    while (Preschar != Nl) {
      Header = _imp_join(Header, Tostring(Line[Lp]));
      Nextchar();
    }
    Instrout(0, 0, 0, -7, 0);
    if (Lid) Fault(_imp_str_literal("Illegal label"));
    continue;
  Itype3_34:;
    I = Lp;
    J = Bchar;
    do
      if (Getoption(Opt)) {
        goto *Optionaction[Optionaction_sw = (Opt) - -1];
      Optionaction_1:;
      Optionaction_2:;
        Bchar = ' ';
        goto Nextoption;
      Optionaction_3:;
      Optionaction_4:;
        Bchar = -1;
        goto Nextoption;
      Optionaction_5:;
      Optionaction_6:;
        Cflag = 1;
        goto Nextoption;
      Optionaction_7:;
      Optionaction_8:;
        Cflag = 0;
        goto Nextoption;
      Optionaction_9:;
        Drad = 4;
        Sp1 = 3;
        Sp2 = 6;
        goto Nextoption;
      Optionaction_10:;
        Drad = 5;
        Sp1 = 3;
        Sp2 = 5;
        goto Nextoption;
      Optionaction_11:;
        Drad = 8;
        Sp1 = 2;
        Sp2 = 4;
        goto Nextoption;
      Optionaction_12:;
      Optionaction_13:;
      Optionaction_14:;
      Optionaction_15:;
        Eflag = 1;
        goto Nextoption;
      Optionaction_16:;
      Optionaction_17:;
        Eflag = 0;
        goto Nextoption;
      Optionaction_18:;
      Optionaction_19:;
        Fflag = 1;
        goto Nextoption;
      Optionaction_20:;
      Optionaction_21:;
        Fflag = 0;
        goto Nextoption;
      Optionaction_22:;
      Optionaction_23:;
        Gflag = 1;
        goto Nextoption;
      Optionaction_24:;
      Optionaction_25:;
        Gflag = 0;
        goto Nextoption;
      Optionaction_26:;
      Optionaction_27:;
        Lflag = 2;
        goto Nextoption;
      Optionaction_28:;
      Optionaction_29:;
        Lflag = 1;
        goto Nextoption;
      Optionaction_30:;
      Optionaction_31:;
        Lflag = 0;
        goto Nextoption;
      Optionaction_32:;
      Optionaction_33:;
        Pflag = 3;
        goto Nextoption;
      Optionaction_34:;
      Optionaction_35:;
        Pflag = 0;
        goto Nextoption;
      Optionaction_36:;
      Optionaction_37:;
        Sflag = 1;
        goto Nextoption;
      Optionaction_38:;
      Optionaction_39:;
        Sflag = 0;
        goto Nextoption;
      Optionaction_40:;
      Optionaction_41:;
        Tflag = 1;
        goto Nextoption;
      Optionaction_42:;
      Optionaction_43:;
        Tflag = 0;
        goto Nextoption;
      Optionaction_44:;
      Optionaction_45:;
        Wflag = 1;
        goto Nextoption;
      Optionaction_46:;
      Optionaction_47:;
        Wflag = 0;
        goto Nextoption;
      Optionaction_48:;
      Optionaction_49:;
        Xflag = 1;
        goto Nextoption;
      Optionaction_50:;
      Optionaction_51:;
        Xflag = 0;
      Optionaction_M1:;
      Optionaction_0:;
      Nextoption:;
      }
    while (Moreitems());
    if (Lflag == 2)
      Sp3 = Linewidth - Sp1 - Sp2 * 3 - Cflag * 3 - Wflag - 11;
    else
      Sp3 = Linewidth - Wflag - 7;
    Instrout(0, 0, 0, -7, 0);
    if (Lid) Fault(_imp_str_literal("Illegal label"));
    Lp = I - 1;
    Nextchar();
    Bchar = J;
    do
      if (Getoption(Opt))
        if (Opt == 1 || Opt == 2)
          Bchar = ' ';
        else if (Opt == 3 || Opt == 4)
          Bchar = -1;
        else if (Opt < 0)
          Fault(_imp_str_literal("Unknown option"));
        else
          Fault(_imp_str_literal("Cannot evaluate operand"));
    while (Moreitems());
    continue;
  Itype3_35:;
    if (Lid) {
      Instrout(0, 0, 0, -7, 0);
      Fault(_imp_str_literal("Illegal label"));
    }
    if (Lflag) Nline(Linesonpage);
    continue;
  Itype3_36:;
    I = Getopd(Opd);
    if (Lid) {
      Instrout(0, 0, 0, -7, 0);
      Fault(_imp_str_literal("Illegal label"));
    }
    if (Lflag)
      if (!I)
        Nline(Opd);
      else
        Nline(1);
  }
Itype3_37:;
  Instrout(0, 0, 0, -7, 0);
  if (Lid) Fault(_imp_str_literal("Illegal label"));
  for (I = 1; I <= Nnames; I++)
    if (!Nass[I]) Fault(_imp_join(_imp_str_literal("Symbol "), _imp_join(Name[I], _imp_str_literal(" has no value"))));
  if (Xflag) {
    Sqs(1, Nnames);
    Nline(Linesonpage);
    Printstring(_imp_str_literal("   Symbol Cross Reference Table"));
    Nline(2);
    Sp3 = (Linewidth - 6 - Sp2) / 6;
    for (I = 1; I <= Nnames; I++) {
      Printstring(Name[I]);
      Spaces(7 - *Length(Name[I]));
      if (Nass[I] == 0 || Nass[I] == 2 || Nass[I] == 4)
        for (J = 1; J <= Sp2; J++) Printsymbol('*');
      else
        Printnumber(Nval[I], 2);
      J = Xhead[I];
      K = 0;
      do {
        L = Xlink[J];
        Xlink[J] = K;
        K = J;
        J = L;
      } while (J);
      J = 0;
      do {
        if (J == Sp3) {
          Nline(1);
          Spaces(7 + Sp2);
          J = 0;
        }
        Write(Xentry[K], 5);
        J++;
        K = Xlink[K];
      } while (K);
      Nline(1);
    }
  } else if (Sflag) {
    Sqs(1, Nnames);
    Nline(Linesonpage);
    Printstring(_imp_str_literal("  Symbol Table"));
    Nline(2);
    Sp3 = (Linewidth + 8 - Sp2) / 15;
    Sp1 = (unsigned)(Linewidth - Sp3 * 15 + 9 - Sp2) >> 1;
    for (J = 1; J <= Nnames; J++) {
      if ((J - 1) == (J - 1) / Sp3 * Sp3) {
        Nline(1);
        Spaces(Sp2);
      } else
        Spaces(8 - Sp2);
      Printstring(Name[J]);
      Spaces(7 - *Length(Name[J]));
      if (Nass[J] == 0 || Nass[J] == 2 || Nass[J] == 4)
        for (I = 1; I <= Sp2; I++) Printsymbol('*');
      else
        Printnumber(Nval[J], 2);
    }
    Nline(1);
  }
  Nline(2);
  Spaces(2);
  if (!Faults)
    Printstring(_imp_str_literal("No"));
  else
    Write(Faults, 0);
  Printstring(_imp_str_literal(" fault"));
  if (Faults != 1) Printsymbol('s');
  Printstring(_imp_str_literal(" in this assembly."));
  Newline();
  Selectoutput(0);
  Spaces(2);
  if (!Faults) {
    Write(Ln, 0);
    Printstring(_imp_str_literal(" line"));
    if (Ln != 1) Printsymbol('s');
    Printstring(_imp_str_literal(" assembled."));
  } else {
    Write(Faults, 0);
    Printstring(_imp_str_literal(" fault"));
    if (Faults != 1) Printsymbol('s');
    Printstring(_imp_str_literal(" in this assembly."));
  }
  Newline();
  Close();
  exit(0);
  int /* boolean */ Matches(_imp_string Source, _imp_string Pattern, int Min, int *I) {
    int L;
    L = *Length(Pattern);
    if (*Length(Pattern) >= *Length(Source))
      L = *Length(Source);
    else
      L = *Length(Pattern);
    for (I = 1; I <= L; I++)
      if (*Charno(Source, *I) != *Charno(Pattern, *I))
        if ('A' <= *Charno(Source, *I) && *Charno(Source, *I) <= 'Z')
          return (0);
        else if (*I <= Min)
          return (0);
        else
          return (1);
    *I = *I + 1;
    if (*I <= Min) return (0);
    return (1);
  }
  _imp_string Lc(_imp_string Source) {
    _imp_string Result;
    int I;
    Result = _imp_str_literal("");
    for (I = 1; I <= *Length(Source); I++)
      if ('A' <= (*Charno(Source, I) & 127) && (*Charno(Source, I) & 127) <= 'Z')
        Result = _imp_join(Result, Tostring((*Charno(Source, I) & 127) + 'a' - 'A'));
      else
        Result = _imp_join(Result, Tostring(*Charno(Source, I) & 127));
    return (Result);
  }
  int /* boolean */ Istyped(_imp_string Source, _imp_string * File) {
    int I;
    for (I = 1; I <= *Length(Source); I++)
      if (*Charno(Source, I) == '.') {
        *File = Substring(Source, 1, I - 1);
        return (1);
      }
    *File = Source;
    return (0);
  }
  void Readline(void) {
    int Ch;
    int I;
    if (_imp_on_event(9)) {
      if (I == 1) {
        Line[1] = ' ';
        Line[2] = 'E';
        Line[3] = 'N';
        Line[4] = 'D';
        Line[5] = Nl;
      } else
        Line[I] = Nl;
      goto Eofexit;
    }
    Ln++;
    for (I = 1; I <= Maxline + 1; I++) {
      Readsymbol(Ch);
      Line[I] = Ch;
      if ((Line[I] & 127) == Nl || (Line[I] & 127) == 12) break;
    }
    while ((Line[I] & 127) != Nl && (Line[I] & 127) != 12) {
      Readsymbol(Ch);
      Line[I] = Ch;
    }
  Eofexit:;
    Lp = 0;
    Nextchar();
  }
  void Nextchar(void) {
    Lp++;
    Preschar = Line[Lp] & 127;
    if ('a' <= Preschar && Preschar <= 'z')
      Preschar = Preschar + 'A' - 'a';
    else if (Preschar == 12)
      Preschar = Nl;
    else if (Preschar == 9)
      Preschar = ' ';
  }
  void Skipblanks(void) {
    while (Preschar == ' ') Nextchar();
  }
  int /* boolean */ Moreitems(void) {
    while (Preschar == Bchar) Nextchar();
    if (Preschar != ',') return (0);
    do
      Nextchar();
    while (Preschar == Bchar);
    return (1);
  }
  int /* boolean */ Getoption(int *Opt) {
    _imp_string Option;
    if ('A' <= Preschar && Preschar <= 'Z') {
      Option = Tostring(Preschar);
      for (;;) {
        Nextchar();
        if (('A' > Preschar || Preschar > 'Z') && ('0' > Preschar || Preschar > '9')) break;
        Option = _imp_join(Option, Tostring(Preschar));
      }
      for (Opt = 1; Opt <= Nooptions; Opt++)
        if (Optiontext[*Opt] == Option) return (1);
      *Opt = -1;
      return (1);
    } else {
      *Opt = 0;
      if (Preschar != ',') return (0);
      Nextchar();
      return (1);
    }
  }
  int Getname(int *Nid) {
    _imp_string N;
    int H;
    int L;
    if ('A' > Preschar || Preschar > 'Z') {
      *Nid = 0;
      return (1);
    }
    H = Preschar - '0';
    N = Tostring(Preschar);
    L = 1;
    for (;;) {
      Nextchar();
      if (('A' > Preschar || Preschar > 'Z') && ('0' > Preschar || Preschar > '9')) break;
      L++;
      if (L <= 6) {
        H = (H << 4) + Preschar - '0';
        N = _imp_join(N, Tostring(Preschar));
      }
    }
    H = H & 32767;
    H -= H / Nhash * Nhash;
    L = Hnlink[H];
    while (L) {
      if (Name[L] == N) {
        *Nid = L;
        if (Pass == 4 && Xxentries <= Xentries && Lookahead == 0) {
          Xxentries++;
          if (Xxentries > Xentries)
            Fault(_imp_str_literal("Too many references"));
          else {
            Xlink[Xxentries] = Xhead[L];
            Xentry[Xxentries] = Ln;
            Xhead[L] = Xxentries;
          }
        }
        return (0);
      }
      L = Nlink[L];
    }
    if (Nnames == Names) {
      Fault(_imp_str_literal("Too many names"));
      exit(0);
    }
    Nnames++;
    Name[Nnames] = N;
    Nlink[Nnames] = Hnlink[H];
    if (_imp_strcmp(N, _imp_str_literal("A")) == 0 || _imp_strcmp(N, _imp_str_literal("B")) == 0 ||
        _imp_strcmp(N, _imp_str_literal("CC")) == 0 || _imp_strcmp(N, _imp_str_literal("DP")) == 0 ||
        _imp_strcmp(N, _imp_str_literal("X")) == 0 || _imp_strcmp(N, _imp_str_literal("Y")) == 0 ||
        _imp_strcmp(N, _imp_str_literal("U")) == 0 || _imp_strcmp(N, _imp_str_literal("S")) == 0 ||
        _imp_strcmp(N, _imp_str_literal("PC")) == 0 || _imp_strcmp(N, _imp_str_literal("PCR")) == 0)
      Nass[Nnames] = 2;
    else
      Nass[Nnames] = 0;
    Nval[Nnames] = 0;
    if (Pass == 4 && Xxentries <= Xentries) {
      Xxentries++;
      if (Xxentries > Xentries)
        Fault(_imp_str_literal("Too many references"));
      else {
        Xlink[Xxentries] = 0;
        Xentry[Xxentries] = Ln;
        Xhead[Nnames] = Xxentries;
      }
    } else
      Xhead[Nnames] = 0;
    Hnlink[H] = Nnames;
    *Nid = Nnames;
    return (0);
  }
  int /* boolean */ Getinstr(int *Iid) {
    _imp_string I;
    int H;
    int L;
    *Iid = 0;
    if ('A' > Preschar || Preschar > 'Z') return (0);
    H = Preschar - '0';
    I = Tostring(Preschar);
    for (L = 2; L <= 5; L++) {
      Nextchar();
      if (('A' > Preschar || Preschar > 'Z') && ('0' > Preschar || Preschar > '9')) goto Goti;
      H = (H << 4) + Preschar - '0';
      I = _imp_join(I, Tostring(Preschar));
    }
    Nextchar();
    if ('A' <= Preschar && Preschar <= 'Z') return (0);
  Goti:
    H = H & 32767;
    H -= H / Ihash * Ihash;
    L = Hilink[H];
    while (L) {
      if (Instr[L] == I) {
        *Iid = L;
        return (1);
      }
      L = Ilink[L];
    }
    return (0);
  }
  void Evaluate(int *A, int B, unsigned char Op) {
    if (Op == '+')
      *A = *A + B;
    else if (Op == '-')
      *A = *A - B;
    else if (Op == '*')
      *A = *A * B;
    else if (Op == '/')
      *A = *A / B;
    else if (Op == '|')
      *A = *A - *A / B * B;
    else if (Op == '!')
      *A = *A | B;
    else if (Op == '&')
      *A = *A & B;
    else if (Op == '\\')
      *A = *A ^ B;
    else if (Op == '<')
      *A = *A << B;
    else if (Op == '>')
      *A = (unsigned)*A >> B;
  }
  int Getterm(int *Opd) {
    int I;
    while (Preschar == '+') do
        Nextchar();
      while (Preschar == Bchar);
    if (Preschar == '-') {
      do
        Nextchar();
      while (Preschar == Bchar);
      I = Getterm(*Opd);
      *Opd = -*Opd;
    } else if (Preschar == '\\') {
      do
        Nextchar();
      while (Preschar == Bchar);
      I = Getterm(*Opd);
      *Opd = ~*Opd;
    } else if (Preschar == '(') {
      do
        Nextchar();
      while (Preschar == Bchar);
      I = Getexpression(*Opd);
      if (!I) {
        while (Preschar == Bchar) Nextchar();
        if (Preschar == ')')
          Nextchar();
        else
          I = 1;
      }
    } else if (!Getname(I))
      if (Pass == 1 || Nass[I] == 1 || Nass[I] == 3) {
        *Opd = Nval[I];
        I = 0;
      } else
        I = 1;
    else
      I = Getconst(*Opd);
    return (I);
  }
  int Getexpression(int *Opd) {
    int Sp;
    int Prio;
    int I;
    unsigned char Opstk[5 /*1:5*/];
    unsigned char Priostk[5 /*1:5*/];
    int Opdstk[6 /*0:5*/];
    if (Getterm(Opdstk[0])) return (1);
    Sp = 0;
    I = 0;
    for (;;) {
      while (Preschar == Bchar) Nextchar();
      if (Preschar == '!' || Preschar == '\\')
        Prio = 0;
      else if (Preschar == '&')
        Prio = 1;
      else if (Preschar == '+' || Preschar == '-')
        Prio = 2;
      else if (Preschar == '*' || Preschar == '/' || Preschar == '|')
        Prio = 3;
      else if (Preschar == '<' || Preschar == '>')
        Prio = 4;
      else
        break;
      while (Sp > 0 && Priostk[Sp] >= Prio) {
        Evaluate(Opdstk[Sp - 1], Opdstk[Sp], Opstk[Sp]);
        Sp--;
      }
      Sp++;
      Opstk[Sp] = Preschar;
      Priostk[Sp] = Prio;
      do
        Nextchar();
      while (Preschar == Bchar);
      if (Getterm(Opdstk[Sp])) {
        Sp--;
        I = 1;
        break;
      }
    }
    for (Sp = Sp; Sp >= 1; Sp--) Evaluate(Opdstk[Sp - 1], Opdstk[Sp], Opstk[Sp]);
    if (!I) *Opd = Opdstk[0];
    return (I);
  }
  int Getopd(int *Opd) {
    int Nid;
    int Op;
    int Cval;
    if (Fflag) return (Getexpression(*Opd));
    *Opd = 0;
    if (Preschar == '+' || Preschar == '-') {
      Op = Preschar;
      do
        Nextchar();
      while (Preschar == Bchar);
    } else
      Op = '+';
    for (;;) {
      if (!Getname(Nid)) {
        if (Pass != 1 && Nass[Nid] != 1 && Nass[Nid] != 3) return (1);
        Cval = Nval[Nid];
      } else if (Getconst(Cval))
        return (1);
      Evaluate(*Opd, Cval, Op);
      while (Preschar == Bchar) Nextchar();
      Op = Preschar;
      if (Op != '+' && Op != '-' && Op != '*' && Op != '/') return (0);
      do
        Nextchar();
      while (Preschar == Bchar);
    }
  }
  int Getconst(int *Cval) {
    int Started;
    int Digval;
    int Binval;
    int Octval;
    int Hexval;
    int Binpos;
    int Octpos;
    int Decpos;
    Started = 1;
    if (Preschar == '*') {
      Nextchar();
      *Cval = Ca;
      return (0);
    }
    *Cval = 0;
    if ('0' <= Preschar && Preschar <= '9') {
      Binpos = 0;
      Octpos = 0;
      Decpos = 0;
      Binval = 0;
      Octval = 0;
      Hexval = 0;
      for (;;) {
        if (Binpos == 0 && Preschar == 'B') {
          Nextchar();
          if ('0' <= Preschar && Preschar <= '9' || 'A' <= Preschar && Preschar <= 'F' || Preschar == 'H') {
            Binpos = 1;
            Octpos = 1;
            Decpos = 1;
            Hexval = (Hexval << 4) + 11;
          } else {
            *Cval = Binval;
            return (0);
          }
        }
        if (Octpos == 0 && (Preschar == 'O' || Preschar == 'Q')) {
          *Cval = Octval;
          Nextchar();
          return (0);
        } else if (Preschar == 'H') {
          *Cval = Hexval;
          Nextchar();
          return (0);
        } else if ('A' <= Preschar && Preschar <= 'F')
          Digval = Preschar - 'A' + 10;
        else if ('0' <= Preschar && Preschar <= '9')
          Digval = Preschar - '0';
        else
          return (Decpos);
        if (Digval > 1) Binpos = 1;
        if (Digval > 7) Octpos = 1;
        if (Digval > 9) Decpos = 1;
        Binval = (Binval << 1) + Digval;
        Octval = (Octval << 3) + Digval;
        *Cval = *Cval * 10 + Digval;
        Hexval = (Hexval << 4) + Digval;
        Nextchar();
      }
    }
    if (Preschar == '$')
      for (;;) {
        Nextchar();
        if ('0' <= Preschar && Preschar <= '9')
          *Cval = *Cval << 4 | (Preschar - '0');
        else if ('A' <= Preschar && Preschar <= 'F')
          *Cval = *Cval << 4 | (Preschar - 'A' + 10);
        else
          return (Started);
        Started = 0;
      }
    if (Preschar == '@')
      for (;;) {
        Nextchar();
        if ('0' > Preschar || Preschar > '7') return (Started);
        *Cval = (*Cval << 3) | (Preschar - '0');
        Started = 0;
      }
    if (Preschar == '%')
      for (;;) {
        Nextchar();
        if ('0' > Preschar || Preschar > '1') return (Started);
        *Cval = (*Cval << 1) | (Preschar - '0');
        Started = 0;
      }
    if (Preschar == '\'') {
      Nextchar();
      if (Lp == Maxline + 1) return (1);
      *Cval = Line[Lp];
      Nextchar();
      return (0);
    }
    return (1);
  }
  void Analiseoperand(int Eca, int *Post, int *Opd, int *Type, int *Cycles) {
    int Indirect;
    int I;
    *Type = 5;
    if (Preschar == '[') {
      do
        Nextchar();
      while (Preschar == Bchar);
      Indirect = 1;
    } else
      Indirect = 0;
    if (Moreitems())
      if (Pc()) {
        *Opd = 0;
        *Post = 0x8C;
        *Type = 6;
        *Cycles = *Cycles + 3;
      } else if (Pcrelative()) {
        *Opd = -2 - Eca;
        if (Pass < 3 || -128 <= *Opd && *Opd <= 127) {
          *Post = 0x8C;
          *Type = 6;
          *Cycles = *Cycles + 3;
        } else {
          *Opd = *Opd - 1;
          *Post = 0x8D;
          *Type = 7;
          *Cycles = *Cycles + 7;
        }
      } else if (!Autoindexed(*Post, *Cycles))
        *Type = 0;
      else if (Pc()) {
        *Opd = 0;
        *Post = 0x8C;
        *Type = 6;
        *Cycles = *Cycles + 3;
      } else if (Pcrelative()) {
        *Opd = -2 - Eca;
        if (Pass < 3 || -128 <= *Opd && *Opd <= 127) {
          *Post = 0x8C;
          *Type = 6;
          *Cycles = *Cycles + 3;
        } else {
          *Opd = *Opd - 1;
          *Post = 0x8D;
          *Type = 7;
          *Cycles = *Cycles + 7;
        }
      } else if (!Autoindexed(*Post, *Cycles)) {
        if (Acc('A')) {
          if (!Moreitems()) {
            *Type = 1;
            goto Checkindirect;
          }
          *Post = 0x86;
          *Cycles = *Cycles + 3;
        } else if (Acc('B')) {
          if (!Moreitems()) {
            *Type = 2;
            goto Checkindirect;
          }
          *Post = 0x85;
          *Cycles = *Cycles + 3;
        } else if (Acc('D')) {
          if (!Moreitems()) {
            *Type = 0;
            goto Checkindirect;
          }
          *Post = 0x8B;
          *Cycles = *Cycles + 6;
        } else if (Preschar == '<') {
          do
            Nextchar();
          while (Preschar == Bchar);
          if (!Getopd(*Opd))
            *Type = 4;
          else
            *Type = 0;
          *Cycles = *Cycles + 3;
          goto Checkindirect;
        } else if (Preschar == '>') {
          do
            Nextchar();
          while (Preschar == Bchar);
          if (!Getopd(*Opd))
            if (!Indirect)
              *Type = 3;
            else {
              *Type = 4;
              *Cycles = *Cycles + 1;
            }
          else
            *Type = 0;
          *Cycles = *Cycles + 2;
          goto Checkindirect;
        } else if (!Getopd(*Opd))
          if (Moreitems())
            if (Pc()) {
              if (Pass < 3 || -128 <= *Opd && *Opd <= 127) {
                *Post = 0x8C;
                *Type = 6;
                *Cycles = *Cycles + 3;
              } else {
                *Post = 0x8D;
                *Type = 7;
                *Cycles = *Cycles + 7;
              }
              goto Checkindirect;
            } else if (Pcrelative()) {
              *Opd = *Opd - Eca - 2;
              if (Pass < 3 || -128 <= *Opd && *Opd <= 127) {
                *Post = 0x8C;
                *Type = 6;
                *Cycles = *Cycles + 3;
              } else {
                *Opd = *Opd - 1;
                *Post = 0x8D;
                *Type = 7;
                *Cycles = *Cycles + 7;
              }
              goto Checkindirect;
            } else if (Pass < 3 || *Opd == 0) {
              if (!Autoindexed(*Post, *Cycles)) *Type = 0;
              goto Checkindirect;
            } else if (Indirect == 0 && -16 <= *Opd && *Opd <= 15) {
              *Post = *Opd & 31;
              *Cycles = *Cycles + 3;
            } else if (-128 <= *Opd && *Opd <= 127) {
              *Post = 0x88;
              *Type = 6;
              *Cycles = *Cycles + 3;
            } else {
              *Post = 0x89;
              *Type = 7;
              *Cycles = *Cycles + 6;
            }
          else {
            if (Indirect == 0 && 0 <= *Opd - Dpcontents && *Opd - Dpcontents <= 255) {
              *Type = 3;
              *Cycles = *Cycles + 2;
            } else {
              *Type = 4;
              *Cycles = *Cycles + 3;
            }
            goto Checkindirect;
          }
        else
          *Type = 0;
        if (Indexreg(I))
          *Post = *Post | (I << 5);
        else
          *Type = 0;
      }
  Checkindirect:;
    if (Indirect) {
      if (1 <= *Type && *Type <= 2 || (*Type == 5 && (*Post == 0x80 || *Post == 0x82))) *Type = 0;
      while (Preschar == Bchar) Nextchar();
      if (Preschar == ']') {
        Nextchar();
        *Cycles = *Cycles + 3;
        if (3 <= *Type && *Type <= 4) {
          *Post = 0x9F;
          *Cycles = *Cycles + 4 - *Type;
          *Type = 7;
        } else
          *Post = *Post | 0x10;
      } else
        *Type = 0;
    }
  }
  int /* boolean */ Autoindexed(int *Post, int *Cycles) {
    int Oldlp;
    int Reg;
    Oldlp = Lp;
    if (Preschar == '-') {
      do
        Nextchar();
      while (Preschar == Bchar);
      if (Preschar == '-') {
        do
          Nextchar();
        while (Preschar == Bchar);
        *Post = 0x83;
      } else
        *Post = 0x82;
    } else
      *Post = 0x84;
    if (Indexreg(Reg)) {
      if (*Post == 0x84) {
        while (Preschar == Bchar) Nextchar();
        if (Preschar == '+') {
          do
            Nextchar();
          while (Preschar == Bchar);
          if (Preschar == '+') {
            Nextchar();
            *Post = 0x81;
            *Cycles = *Cycles + 5;
          } else {
            *Post = 0x80;
            *Cycles = *Cycles + 4;
          }
        } else
          *Cycles = *Cycles + 2;
      } else
        *Cycles = *Cycles + 4 + (*Post & 1);
      *Post = *Post | (Reg << 5);
      return (1);
    }
    Lp = Oldlp - 1;
    Nextchar();
    return (0);
  }
  int /* boolean */ Accumulator(void) {
    if (Acc('A')) return (1);
    if (Acc('B')) return (1);
    return (0);
  }
  int /* boolean */ Acc(unsigned char Accid) {
    if (Preschar != Accid) return (0);
    Nextchar();
    if (('A' > Preschar || Preschar > 'Z') && ('0' > Preschar || Preschar > '9')) return (1);
    Lp -= 2;
    Nextchar();
    return (0);
  }
  int /* boolean */ Indexreg(int *Reg) {
    if (Acc('X')) {
      *Reg = 0;
      return (1);
    }
    if (Acc('Y')) {
      *Reg = 1;
      return (1);
    }
    if (Acc('U')) {
      *Reg = 2;
      return (1);
    }
    if (Acc('S')) {
      *Reg = 3;
      return (1);
    }
    return (0);
  }
  int /* boolean */ Transferreg(int *Reg) {
    if (Acc('D')) {
      *Reg = 0;
      return (1);
    }
    if (Acc('X')) {
      *Reg = 1;
      return (1);
    }
    if (Acc('Y')) {
      *Reg = 2;
      return (1);
    }
    if (Acc('U')) {
      *Reg = 3;
      return (1);
    }
    if (Acc('S')) {
      *Reg = 4;
      return (1);
    }
    if (Pc()) {
      *Reg = 5;
      return (1);
    }
    if (Acc('A')) {
      *Reg = 8;
      return (1);
    }
    if (Acc('B')) {
      *Reg = 9;
      return (1);
    }
    if (Cc()) {
      *Reg = 10;
      return (1);
    }
    if (Dp()) {
      *Reg = 11;
      return (1);
    }
    return (0);
  }
  int /* boolean */ Cc(void) {
    if (Preschar != 'C') return (0);
    Nextchar();
    if (Acc('C')) return (1);
    Lp -= 2;
    Nextchar();
    return (0);
  }
  int /* boolean */ Dp(void) {
    if (Preschar != 'D') return (0);
    Nextchar();
    if (Acc('P')) return (1);
    Lp -= 2;
    Nextchar();
    return (0);
  }
  int /* boolean */ Pc(void) {
    if (Preschar != 'P') return (0);
    Nextchar();
    if (Acc('C')) return (1);
    Lp -= 2;
    Nextchar();
    return (0);
  }
  int /* boolean */ Pcrelative(void) {
    if (Preschar != 'P') return (0);
    Nextchar();
    if (Preschar == 'C') {
      Nextchar();
      if (Acc('R')) return (1);
      Lp--;
    }
    Lp -= 2;
    Nextchar();
    return (0);
  }
  void Dumpblock(void) {
    int Checksum;
    int Oldrad;
    int I;
    Selectoutput(1);
    Oldrad = Drad;
    Drad = 8;
    Printstring(_imp_str_literal("S1"));
    Printnumber(Bp + 3, 1);
    Printnumber(Bufferca, 2);
    Checksum = (((unsigned)Bufferca >> 8) & 255) + (Bufferca & 255) + Bp + 3;
    for (I = 1; I <= Bp; I++) {
      Checksum += Buffer[I];
      Printnumber(Buffer[I], 1);
    }
    Printnumber(~(Checksum & 255), 1);
    Printsymbol(13);
    Newline();
    Drad = Oldrad;
    Selectoutput(2);
    Bp = 0;
  }
  void Dump(unsigned char Byte) {
    if (!Ostarted) {
      Selectoutput(1);
      Printsymbol(13);
      Newline();
      Printstring(_imp_str_literal("S00600004844521B"));
      Printsymbol(13);
      Newline();
      Selectoutput(2);
      Ostarted = 1;
    }
    if (!Bp) Bufferca = Ca;
    if (Bufferca + Bp != Ca) {
      Dumpblock();
      Bufferca = Ca;
    }
    Bp++;
    Buffer[Bp] = Byte;
    Ca++;
    if (Bp == 16) Dumpblock();
  }
  void Close(void) {
    if (Ostarted) {
      if (Bp) Dumpblock();
      Selectoutput(1);
      Printstring(_imp_str_literal("S9030000FC"));
      Printsymbol(13);
      Newline();
      Selectoutput(2);
    }
  }
  void Instrout(int Op, int Post, int Opd, int B, int Cyc) {
    int I;
    int J;
    int K;
    int Lit;
    I = 1;
    if (Lflag != 0 && ((Gflag != 0 && Lflag != 1) || Cont != 1)) {
      Write(Ln, 5);
      if (Wflag) Space();
      if (Lflag == 2) {
        Space();
        if (B <= -5)
          Spaces(Sp2);
        else
          Printnumber(Ca, 2);
        Space();
        if (-6 <= B && B <= -1) {
          Spaces(Sp2 + 1);
          if (!(B & 1))
            Printnumber(Post, 2);
          else {
            Printnumber(Post, 1);
            Spaces(Sp2 - Sp1);
          }
          Spaces(Sp1 + 1);
        } else {
          if (B <= 0)
            Spaces(Sp2);
          else if (0 <= Op && Op <= 255) {
            Printnumber(Op, 1);
            Spaces(Sp2 - Sp1);
          } else
            Printnumber(Op, 2);
          Space();
          if (B <= 1)
            Spaces(Sp1 + Sp2 + 1);
          else if (B <= 4) {
            Printnumber(Post, 1);
            Space();
            if (B <= 2)
              Spaces(Sp2);
            else if (B == 3) {
              Printnumber(Opd, 1);
              Spaces(Sp2 - Sp1);
            } else
              Printnumber(Opd, 2);
          } else {
            Printnumber(Post, 2);
            Spaces(Sp1 + 1);
          }
        }
        if (Cflag)
          if (!Cyc)
            Spaces(3);
          else
            Write(Cyc, 2);
      }
      if (!Cont) {
        Space();
        if (!Tflag)
          for (;;) {
            Outsymbol(Line[I]);
            if ((Line[I] & 127) == Nl || (Line[I] & 127) == 12) break;
            I++;
          }
        else {
          J = 1;
          Outtag(I, J, 8);
          if (Accop == 1) Outtag(I, J, 12);
          Outtag(I, J, 15);
          K = 0;
          Lit = 0;
          while (I != Lp) {
            if ((Line[I] & 127) == ' ') {
              if (Nondense == 1 || Lit == 1) K++;
            } else {
              J = J + K + 1;
              while (K > 0) {
                Outsymbol(' ');
                K--;
              }
              Outsymbol(Line[I]);
            }
            if ((Line[I] & 127) == '\'')
              Lit = 1;
            else
              Lit = 0;
            I++;
          }
          while ((Line[I] & 127) == ' ') I++;
          if (Lp != 1 && (Line[I] & 127) != Nl && (Line[I] & 127) != 12) do {
              Outsymbol(' ');
              J++;
            } while (J < 24);
          for (;;) {
            Outsymbol(Line[I]);
            if ((Line[I] & 127) == Nl || (Line[I] & 127) == 12) break;
            I++;
          }
        }
      } else
        Nline(1);
    } else
      while ((Line[I] & 127) != Nl && (Line[I] & 127) != 12) I++;
    if (I == Maxline + 1) Fault(_imp_str_literal("Truncated line"));
    if (B >= 1) {
      if (0 > Op || Op > 255) Dump(((unsigned)Op >> 8) & 255);
      Dump(Op & 255);
      if (B == 5) Dump(((unsigned)Post >> 8) & 255);
      if (B >= 2) Dump(Post & 255);
      if (B == 4) Dump(((unsigned)Opd >> 8) & 255);
      if (3 <= B && B <= 4) Dump(Opd & 255);
    } else if (-2 <= B && B <= -1) {
      if (B == -2) Dump(((unsigned)Post >> 8) & 255);
      Dump((Post & 255));
    }
  }
  void Outtag(int *I, int *J, int Col) {
    while ((Line[*I] & 127) != ' ' && *I != Lp) {
      Outsymbol(Line[*I]);
      *I = *I + 1;
      *J = *J + 1;
    }
    while ((Line[*I] & 127) == ' ' && *I != Lp) *I = *I + 1;
    if (*I != Lp) do {
        Outsymbol(' ');
        *J = *J + 1;
      } while (*J < Col);
  }
  void Outsymbol(unsigned char Char) {
    static int Optr = 0;
    if ((Char & 127) == Nl) {
      Optr = 0;
      Nline(1);
    } else if ((Char & 127) == 12) {
      Optr = 0;
      Nline(Linesonpage);
    } else {
      if (Optr == Sp3) {
        if (!Wflag) return;
        Nline(1);
        Write(Ln, 5);
        Printsymbol('+');
        Spaces(Linewidth - Sp3 - 7);
        Optr = 0;
      }
      Printsymbol(Char);
      Optr++;
    }
  }
  void Fault(_imp_string S) {
    Faults++;
    if (Eflag) {
      Printstring(_imp_join(_imp_str_literal("****  "), _imp_join(S, _imp_str_literal(".  ****"))));
      Nline(1);
    }
  }
  void Nline(int N) {
    static int Lineonpage = Linesonpage + 1;
    static int Pageno = 0;
    if (N >= 0)
      if (Lineonpage + Pflag + N > Linesonpage) {
        Pageno++;
        if (N)
          if (Lineonpage == Linesonpage)
            Newline();
          else
            Printsymbol(12);
        if (!Pflag)
          Lineonpage = 1;
        else {
          Newline();
          Printstring(_imp_str_literal("  Motorola M6809 Assembler "));
          Spaces((Linewidth - 37 - *Length(Header)) / 2);
          Printstring(Header);
          Spaces((Linewidth - 36 - *Length(Header)) / 2);
          Printstring(_imp_str_literal(" Page"));
          Write(Pageno, 2);
          Newlines(2);
          Lineonpage = 4;
        }
      } else {
        Newlines(N);
        Lineonpage += N;
      }
  }
  void Printnumber(int N, int D) {
    static const _imp_string H[16 /*0:15*/] = {
        _imp_str_literal("0"), _imp_str_literal("1"), _imp_str_literal("2"), _imp_str_literal("3"),
        _imp_str_literal("4"), _imp_str_literal("5"), _imp_str_literal("6"), _imp_str_literal("7"),
        _imp_str_literal("8"), _imp_str_literal("9"), _imp_str_literal("A"), _imp_str_literal("B"),
        _imp_str_literal("C"), _imp_str_literal("D"), _imp_str_literal("E"), _imp_str_literal("F")};
    int Model;
    int Nn;
    _imp_string S;
    Model = 1 << (D * 8 - 1);
    S = _imp_str_literal("");
    do {
      Model = ((unsigned)Model >> 1) / Drad;
      Nn = ((unsigned)N >> 1) / Drad;
      S = _imp_join(H[N - ((Nn * Drad) << 1)], S);
      N = Nn;
    } while (Model);
    Printstring(S);
  }
  void Sqs(int L, int R) {
    int Nasskey;
    int Nvalkey;
    int Xheadkey;
    int Lp;
    int Rp;
    int I;
    _imp_string Namekey;
    if (L >= R) return;
    while (R - L > Insertlimit) {
      Lp = L;
      Rp = R + 1;
      Namekey = Name[L];
      Nasskey = Nass[L];
      Nvalkey = Nval[L];
      Xheadkey = Xhead[L];
      for (;;) {
        do
          Rp--;
        while (Rp != Lp && Namekey <= Name[Rp]);
        if (Lp == Rp) break;
        Name[Lp] = Name[Rp];
        Nass[Lp] = Nass[Rp];
        Nval[Lp] = Nval[Rp];
        Xhead[Lp] = Xhead[Rp];
        do
          Lp++;
        while (Rp != Lp && Namekey > Name[Lp]);
        if (Lp == Rp) break;
        Name[Rp] = Name[Lp];
        Nass[Rp] = Nass[Lp];
        Nval[Rp] = Nval[Lp];
        Xhead[Rp] = Xhead[Lp];
      }
      Name[Lp] = Namekey;
      Nass[Lp] = Nasskey;
      Nval[Lp] = Nvalkey;
      Xhead[Lp] = Xheadkey;
      if (Lp - L > R - Rp) {
        Sqs(Rp + 1, R);
        R = Lp - 1;
      } else {
        Sqs(L, Lp - 1);
        L = Rp + 1;
      }
    }
    for (Rp = L + 1; Rp <= R; Rp++) {
      Namekey = Name[Rp];
      Nasskey = Nass[Rp];
      Nvalkey = Nval[Rp];
      Xheadkey = Xhead[Rp];
      Lp = L;
      while (Lp != Rp && Namekey > Name[Lp]) Lp++;
      for (I = Rp - 1; I >= Lp; I--) {
        Name[I + 1] = Name[I];
        Nass[I + 1] = Nass[I];
        Nval[I + 1] = Nval[I];
        Xhead[I + 1] = Xhead[I];
      }
      Name[Lp] = Namekey;
      Nass[Lp] = Nasskey;
      Nval[Lp] = Nvalkey;
      Xhead[Lp] = Xheadkey;
    }
  }
  exit(0);
  return (1);
}
