// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/crossassemblers/macro7/macro7.c
// Function: onePass
void onePass()
{
  BOOL    blanks;
  int     ix;
  int     jx;
  char    name[SYMLEN];
  WORD32  newclc;
  BOOL    scanning_line;
  WORD32  start;
  SYM_T  *sym;
  WORD32  term;
  WORD32  val;

  clc = 0100;                  /* Default starting address is 100 octal.     */
  start_addr = 0100;           /* No starting address.                       */
  lit_loc = LIT_BASE;          /* Literal pool base.                         */
  mac_count = 0;               /* No macros defined.                          */
  mac_ptr = NULL;              /* Not in a macro.                             */
  for( ix = 0; ix < MAC_TABLE_LENGTH; ix++)
  {
    if ( mac_bodies[ix] )
    {
      free( mac_bodies[ix] );
    }
  }
  cp.error = FALSE;
  listed = TRUE;
  lineno = 0;
  list_pageno = 0;
  list_lineno = 0;
  list_title_set = FALSE;
  page_lineno = LIST_LINES_PER_PAGE;    /* Force top of page for new titles.  */
  radix = 8;                    /* Initial radix is octal (base 8).           */

  /* Now open the first input file.                                           */
  end_of_input = FALSE;
  filix_curr = filix_start;     /* Initialize pointer to input files.         */
  if(( infile = fopen( save_argv[filix_curr], "r" )) == NULL )
  {
    fprintf( stderr, "%s: cannot open \"%s\"\n", save_argv[0],
      save_argv[filix_curr] );
    exit( -1 );
  }

  while( TRUE )
  {
    readLine();
    nextLexeme();

    scanning_line = TRUE;
    while( scanning_line )
    {
      if( end_of_input )
      {
        endOfBinary();
        fclose( infile );
        return;
      }
      if( isend( line[lexstart] ))
      {
        scanning_line = FALSE;
      }
      else
      {
        switch( line[lexstart] )
        {
        case '/':
          scanning_line = FALSE;
          break;

        case '\t':
          nextLexeme();
          break;

        default:
          for( jx = lexstart; jx < maxcc; jx++ )
          {
            if( is_blank( line[jx] ) || isdone( line[jx] )) break;
          }
          if( line[jx] == '/')
          {
            newclc = (getExpr())->val & 077777;
            /* Do not change Current Location Counter if an error occurred.   */
            if( !error_in_line )
            {
              clc = newclc;
            }
            printLine( line, 0, newclc, LINE_VAL );
            cc = jx + 1;
            nextLexeme();
            while( line[lexstart] == '\t' ) nextLexeme();
            break;
          }

          switch( line[lexterm] )
          {
          case ',':
            if( isalpha( line[lexstart] ))
            {
              /* Use lookup so symbol will not be counted as reference.       */
              sym = lookup( lexemeToName( name, lexstart, lexterm ));
              if( M_DEFINED( sym->type ))
              {
                if( sym->val != clc && pass == 2 )
                {
                  errorSymbol( &duplicate_label, sym->name, lexstart );
                }
                sym->type = sym->type | DUPLICATE;
              }
              /* Must call define on pass 2 to generate concordance.          */
              defineLexeme( lexstart, lexterm, clc, LABEL );
            }
            else
            {
              errorLexeme( &label_syntax, lexstart );
            }
            nextLexeme();           /* skip label                             */
            nextLexeme();           /* skip comma                             */
            while( line[lexstart] == '\t' ) nextLexeme();
            break;

          case '=':
            if( isalpha( line[lexstart] ))
            {
              start = lexstart;
              term = lexterm;
              delimiter = line[lexterm];
              nextLexBlank();       /* skip symbol                            */
              nextLexeme();         /* skip trailing =                        */
              val = getExprs();
              defineLexeme( start, term, val, DEFINED );
              printLine( line, 0, val, LINE_VAL );
            }
            else
            {
              errorLexeme( &symbol_syntax, lexstartprev );
              nextLexeme();         /* skip symbol                            */
              nextLexeme();         /* skip trailing =                        */
              getExprs();           /* skip expression                        */
            }
            while( line[lexstart] == '\t' ) nextLexeme();
            break;

          default:
            if( isalpha( line[lexstart] ))
            {
              sym = evalSymbol();
              val = sym->val;
              if( M_MACRO( sym->type ))
              {                     /* Find arguments.                       */
                blanks = TRUE;      /* Expecting blanks.                     */
                for( jx = 0; !isdone( line[cc] ) && ( jx < MAC_MAX_ARGS ); cc++ )
                {
                  if(( line[cc] == ',' ) || is_blank( line[cc] )) blanks = TRUE;
                  else if( blanks )
                  {
                     mac_arg_pos[jx++] = cc;
                     blanks = FALSE;
                  }
                } /* end for                                                 */                
                for( ; jx < MAC_MAX_ARGS; jx++ )
                {
                  mac_arg_pos[jx] = 0;
                }
                for( jx = 0; jx < LINELEN; jx++ )
                {
                  mac_line[jx] = line[jx];
                }
                mac_cc = cc;       /* Save line and position in line.        */
                mac_ptr = mac_bodies[val];
                if( mac_ptr ) scanning_line = FALSE;
                else nextLexeme();         
              } /* end if macro                                              */
              else if( M_PSEUDO( sym->type ))
              {
                nextLexeme();         /* Skip symbol                          */
                scanning_line = pseudoOperators( (PSEUDO_T)val & 0777777 );
              }
              else
              {
                /* Identifier is not a pseudo-op, interpret as load value     */
                punchOutObject( clc, getExprs() & 0777777 );
                incrementClc();
              }
            }
            else
            {
              /* Identifier is a value, interpret as load value               */
              punchOutObject( clc, getExprs() & 0777777 );
              incrementClc();
            }
            break;
          } /* end switch                                                     */
          break;
        } /* end switch                                                       */
      } /* end if                                                             */
    } /* end while( scanning_line )                                           */
  } /* end while( TRUE )                                                      */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0x40, %eax
movl %eax, 0x97e9(%rip)      # 0xc360
movl %eax, 0x97e7(%rip)      # 0xc364
movl $0x1f00, 0x97e1(%rip)   # imm = 0x1F00
movl $0x0, 0x97db(%rip)      # 0xc36c
movq $0x0, 0x97d4(%rip) # 0xc370
xorl %ebx, %ebx
leaq 0x74bb(%rip), %r13      # 0xa060
movq (%rbx,%r13), %rdi
testq %rdi, %rdi
je 0x2bb3
callq 0x2040
addq $0x8, %rbx
cmpq $0x2000, %rbx           # imm = 0x2000
jne 0x2ba5
xorl %eax, %eax
movl %eax, 0x97b0(%rip)      # 0xc378
movl $0x1, 0x113aa(%rip)     # 0x13f7c
movl %eax, 0x113a8(%rip)     # 0x13f80
movl %eax, 0x113a6(%rip)     # 0x13f84
movl %eax, 0x113a4(%rip)     # 0x13f88
movb %al, 0x113a2(%rip)      # 0x13f8c
movl $0x3c, 0x1139c(%rip)    # 0x13f90
movl $0x8, 0x11396(%rip)     # 0x13f94
movb %al, 0x11394(%rip)      # 0x13f98
movslq 0x9645(%rip), %rax      # 0xc250
movl %eax, 0x1138b(%rip)     # 0x13f9c
movq 0x7430(%rip), %rcx      # 0xa048
movq (%rcx,%rax,8), %rdi
leaq 0x3515(%rip), %rsi      # 0x6138
callq 0x2140
movq %rax, 0x9619(%rip)      # 0xc248
testq %rax, %rax
je 0x3066
callq 0x356d
callq 0x380e
cmpb $0x0, 0x1134f(%rip)     # 0x13f98
je 0x2c6b
callq 0x3932
movq 0x95f1(%rip), %rdi      # 0xc248
callq 0x2090
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1132e(%rip), %rbx     # 0x13fa0
movabsq $0x4000800100001601, %r14 # imm = 0x4000800100001601
movl 0x1149e(%rip), %ebp     # 0x14120
movslq %ebp, %rcx
movzbl (%rcx,%rbx), %eax
cmpl $0x9, %eax
jg 0x2c99
testl %eax, %eax
je 0x2ca3
cmpl $0x9, %eax
je 0x2ca8
jmp 0x2cb8
cmpl $0xa, %eax
je 0x2ca3
cmpl $0x2f, %eax
jne 0x2cb8
callq 0x356d
callq 0x380e
cmpb $0x0, 0x112e4(%rip)     # 0x13f98
je 0x2c7c
jmp 0x2c4b
movl 0x11466(%rip), %edx     # 0x14124
movl %ebp, %r15d
cmpl %edx, %ebp
jge 0x2ce8
movslq %edx, %rsi
movzbl (%rcx,%rbx), %edi
cmpq $0x3e, %rdi
ja 0x2cd8
btq %rdi, %r14
jb 0x2ce5
incq %rcx
cmpq %rcx, %rsi
jne 0x2cc8
movl %edx, %r15d
jmp 0x2ce8
movl %ecx, %r15d
movslq %r15d, %rcx
cmpb $0x2f, (%rcx,%rbx)
jne 0x2d42
callq 0x396c
movl 0x72a8(%rip), %edx      # 0x9fa4
movl $0x7fff, %eax           # imm = 0x7FFF
andl %eax, %edx
cmpb $0x0, 0x1141e(%rip)     # 0x14128
jne 0x2d12
movl %edx, 0x964e(%rip)      # 0xc360
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %ecx
callq 0x3bad
incl %r15d
movl %r15d, 0x11401(%rip)    # 0x1412c
callq 0x380e
movslq 0x113e9(%rip), %rax     # 0x14120
cmpb $0x9, (%rax,%rbx)
je 0x2d2b
jmp 0x2cad
movsbq %al, %r14
movslq 0x113e3(%rip), %r15     # 0x14130
movzbl (%r15,%rbx), %r12d
callq 0x2180
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
cmpl $0x3d, %r12d
je 0x2dab
cmpl $0x2c, %r12d
jne 0x2df4
btl $0xa, %eax
movabsq $0x4000800100001601, %r14 # imm = 0x4000800100001601
jb 0x2e44
leaq 0xa(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x3dfe
leaq 0x7054(%rip), %rdi      # 0x9df0
movq %r12, %rsi
movl %ebp, %edx
callq 0x3e73
jmp 0x2ecb
btl $0xa, %eax
jb 0x2ee7
movl 0x1137c(%rip), %r12d    # 0x14138
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x3dfe
leaq 0x704b(%rip), %rdi      # 0x9e20
movq %r14, %rsi
movl %r12d, %edx
callq 0x3e73
callq 0x380e
callq 0x380e
callq 0x3fd7
jmp 0x2f36
btl $0xa, %eax
movabsq $0x4000800100001601, %r14 # imm = 0x4000800100001601
jb 0x2f58
movl 0x9552(%rip), %ebp      # 0xc360
callq 0x3fd7
andl $0x3ffff, %eax          # imm = 0x3FFFF
movl %ebp, %edi
movl %eax, %esi
callq 0x497a
movl 0x9539(%rip), %edi      # 0xc360
callq 0x4e47
movl 0x952e(%rip), %eax      # 0xc360
incl %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movl %eax, 0x9521(%rip)      # 0xc360
jmp 0x2cad
leaq 0x11(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x3dfe
movq %r12, %rdi
callq 0x3cd1
testb $0x1, (%rax)
je 0x2e97
movq %rax, %r15
movl 0xc(%rax), %eax
cmpl 0x94f1(%rip), %eax      # 0xc360
je 0x2e93
cmpl $0x2, 0x9278(%rip)      # 0xc0f0
jne 0x2e93
movq %r15, %rsi
addq $0x4, %rsi
movl 0x11299(%rip), %edx     # 0x14120
leaq 0x6f22(%rip), %rdi      # 0x9db0
callq 0x3e73
orb $0x21, (%r15)
movl 0x11283(%rip), %ebp     # 0x14120
movl 0x1128d(%rip), %edx     # 0x14130
movl 0x94b6(%rip), %r15d     # 0xc360
leaq 0xa(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
callq 0x3dfe
movq %r12, %rdi
movl %r15d, %esi
movl $0x9, %edx
movl %ebp, %ecx
callq 0x2a9c
callq 0x380e
callq 0x380e
movslq 0x11244(%rip), %rax     # 0x14120
cmpb $0x9, (%rax,%rbx)
je 0x2ed0
jmp 0x2cad
movb %r12b, 0x11246(%rip)    # 0x14134
callq 0x3f87
callq 0x380e
callq 0x3fd7
movl %eax, %r12d
leaq 0xa(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x3dfe
movq %r14, %rdi
movl %r12d, %esi
movl $0x1, %edx
movl %ebp, %ecx
callq 0x2a9c
movq %rbx, %rdi
xorl %esi, %esi
movl %r12d, %edx
movl $0x1, %ecx
callq 0x3bad
movabsq $0x4000800100001601, %r14 # imm = 0x4000800100001601
movslq 0x111d9(%rip), %rax     # 0x14120
cmpb $0x9, (%rax,%rbx)
jne 0x2cad
callq 0x380e
jmp 0x2f40
callq 0x412d
movslq 0xc(%rax), %rbp
movl (%rax), %eax
notl %eax
testl $0x101, %eax            # imm = 0x101
jne 0x2fe3
movslq 0x111b9(%rip), %r15     # 0x1412c
movq %r15, %rcx
addq %rbx, %rcx
movb $0x1, %dl
xorl %eax, %eax
movabsq $0x4000100100001000, %r8 # imm = 0x4000100100001000
movabsq $0x800000000401, %r9    # imm = 0x800000000401
movzbl (%rcx), %edi
cmpq $0x2f, %rdi
ja 0x2fa0
btq %rdi, %r9
jb 0x300a
cmpl $0x9, %edi
je 0x300a
cmpl $0x13, %eax
jg 0x300a
cmpl $0x3e, %edi
ja 0x2fcb
movb $0x1, %sil
movl %edi, %edi
btq %rdi, %r8
jae 0x2fcb
incl %r15d
movl %r15d, 0x11168(%rip)    # 0x1412c
incq %rcx
movl %esi, %edx
jmp 0x2f91
testb %dl, %dl
je 0x2fdf
movslq %eax, %rdx
incl %eax
leaq 0x6fe5(%rip), %rsi      # 0x9fc0
movl %r15d, (%rsi,%rdx,4)
xorl %esi, %esi
jmp 0x2fba
testb $0x43, %al
jne 0x2e08
callq 0x380e
andl $0x3ffff, %ebp          # imm = 0x3FFFF
movl %ebp, %edi
callq 0x418c
testb %al, %al
jne 0x2cad
jmp 0x2ca3
cmpl $0x13, %eax
jg 0x3033
movslq %eax, %rcx
leaq 0x6fa7(%rip), %rdx      # 0x9fc0
leaq (%rdx,%rcx,4), %rdi
movl $0x13, %ecx
subl %eax, %ecx
leaq 0x4(,%rcx,4), %rdx
xorl %esi, %esi
callq 0x20c0
movl $0xc, %ecx
leaq 0x11101(%rip), %rdi     # 0x14140
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl %r15d, 0x11274(%rip)    # 0x142c0
movq (%r13,%rbp,8), %rax
movq %rax, 0x9318(%rip)      # 0xc370
testq %rax, %rax
jne 0x2ca3
jmp 0x2ca8
callq 0x2340