// File: /workspace/github_c_makefile_star2_O3/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, 0x97f5(%rip)      # 0xc360
movl %eax, 0x97f3(%rip)      # 0xc364
movl $0x1f00, 0x97ed(%rip)   # imm = 0x1F00
movl $0x0, 0x97e7(%rip)      # 0xc36c
movq $0x0, 0x97e0(%rip) # 0xc370
xorl %ebx, %ebx
leaq 0x74c7(%rip), %r14      # 0xa060
movq (%rbx,%r14), %rdi
testq %rdi, %rdi
je 0x2ba7
callq 0x2040
addq $0x8, %rbx
cmpq $0x2000, %rbx           # imm = 0x2000
jne 0x2b99
xorl %eax, %eax
movl %eax, 0x97bc(%rip)      # 0xc378
movl $0x1, 0x113b6(%rip)     # 0x13f7c
movl %eax, 0x113b4(%rip)     # 0x13f80
movl %eax, 0x113b2(%rip)     # 0x13f84
movl %eax, 0x113b0(%rip)     # 0x13f88
movb %al, 0x113ae(%rip)      # 0x13f8c
movl $0x3c, 0x113a8(%rip)    # 0x13f90
movl $0x8, 0x113a2(%rip)     # 0x13f94
movb %al, 0x113a0(%rip)      # 0x13f98
movslq 0x9651(%rip), %rax      # 0xc250
movl %eax, 0x11397(%rip)     # 0x13f9c
movq 0x743c(%rip), %rcx      # 0xa048
movq (%rcx,%rax,8), %rdi
leaq 0x3545(%rip), %rsi      # 0x615c
callq 0x2140
movq %rax, 0x9625(%rip)      # 0xc248
testq %rax, %rax
je 0x3056
callq 0x3582
callq 0x3816
cmpb $0x0, 0x1135b(%rip)     # 0x13f98
je 0x2c5f
callq 0x3929
movq 0x95fd(%rip), %rdi      # 0xc248
callq 0x2090
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1133a(%rip), %rbx     # 0x13fa0
movabsq $0x4000800100001601, %r14 # imm = 0x4000800100001601
movl 0x114aa(%rip), %ebp     # 0x14120
movslq %ebp, %rcx
movb (%rcx,%rbx), %al
movzbl %al, %edx
cmpl $0x9, %edx
jg 0x2c8f
testl %edx, %edx
je 0x2c99
cmpl $0x9, %edx
je 0x2c9e
jmp 0x2cae
cmpl $0xa, %edx
je 0x2c99
cmpl $0x2f, %edx
jne 0x2cae
callq 0x3582
callq 0x3816
cmpb $0x0, 0x112ee(%rip)     # 0x13f98
je 0x2c70
jmp 0x2c3f
movl 0x11470(%rip), %edx     # 0x14124
movl %eax, %esi
movl %ebp, %r15d
cmpl %edx, %ebp
jge 0x2ce6
movslq %edx, %rsi
movzbl (%rcx,%rbx), %edi
cmpq $0x3e, %rdi
ja 0x2cd0
btq %rdi, %r14
jb 0x2cda
incq %rcx
cmpq %rcx, %rsi
jne 0x2cc0
jmp 0x2cdc
movl %ecx, %edx
movslq %edx, %rcx
movb (%rcx,%rbx), %sil
movl %edx, %r15d
cmpb $0x2f, %sil
jne 0x2d3d
callq 0x3963
movl 0x72ad(%rip), %edx      # 0x9fa4
movl $0x7fff, %eax           # imm = 0x7FFF
andl %eax, %edx
cmpb $0x0, 0x11423(%rip)     # 0x14128
jne 0x2d0d
movl %edx, 0x9653(%rip)      # 0xc360
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %ecx
callq 0x3b9d
incl %r15d
movl %r15d, 0x11406(%rip)    # 0x1412c
callq 0x3816
movslq 0x113ee(%rip), %rax     # 0x14120
cmpb $0x9, (%rax,%rbx)
je 0x2d26
jmp 0x2ca3
movq %r14, %r13
movsbq %al, %r14
movslq 0x113e5(%rip), %r15     # 0x14130
movzbl (%r15,%rbx), %r12d
callq 0x2180
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
cmpl $0x3d, %r12d
je 0x2d9e
cmpl $0x2c, %r12d
movq %r13, %r14
jne 0x2dea
btl $0xa, %eax
jb 0x2e30
leaq 0xa(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x3de8
leaq 0x7061(%rip), %rdi      # 0x9df0
movq %r12, %rsi
movl %ebp, %edx
callq 0x3e58
jmp 0x2ebe
btl $0xa, %eax
movq %r13, %r14
jb 0x2eda
movl 0x11386(%rip), %r12d    # 0x14138
leaq 0xa(%rsp), %r13
movq %r13, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x3de8
leaq 0x7055(%rip), %rdi      # 0x9e20
movq %r13, %rsi
movl %r12d, %edx
callq 0x3e58
callq 0x3816
callq 0x3816
callq 0x3fbc
jmp 0x2f30
btl $0xa, %eax
jb 0x2f42
movl 0x9566(%rip), %ebp      # 0xc360
callq 0x3fbc
andl $0x3ffff, %eax          # imm = 0x3FFFF
movl %ebp, %edi
movl %eax, %esi
callq 0x4962
movl 0x954d(%rip), %edi      # 0xc360
callq 0x4df7
movl 0x9542(%rip), %eax      # 0xc360
incl %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movl %eax, 0x9535(%rip)      # 0xc360
jmp 0x2ca3
leaq 0x11(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x3de8
movq %r12, %rdi
callq 0x3cc1
movq %rax, %r15
movl (%rax), %eax
testb $0x1, %al
je 0x2e8a
movl 0xc(%r15), %ecx
cmpl 0x9503(%rip), %ecx      # 0xc360
je 0x2e84
cmpl $0x2, 0x928a(%rip)      # 0xc0f0
jne 0x2e84
movq %r15, %rsi
addq $0x4, %rsi
movl 0x112ab(%rip), %edx     # 0x14120
leaq 0x6f34(%rip), %rdi      # 0x9db0
callq 0x3e58
movl (%r15), %eax
orl $0x21, %eax
movl %eax, (%r15)
movl 0x11290(%rip), %ebp     # 0x14120
movl 0x1129a(%rip), %edx     # 0x14130
movl 0x94c3(%rip), %r15d     # 0xc360
leaq 0xa(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
callq 0x3de8
movq %r12, %rdi
movl %r15d, %esi
movl $0x9, %edx
movl %ebp, %ecx
callq 0x2a90
callq 0x3816
callq 0x3816
movslq 0x11251(%rip), %rax     # 0x14120
cmpb $0x9, (%rax,%rbx)
je 0x2ec3
jmp 0x2ca3
movb $0x3d, 0x11253(%rip)    # 0x14134
callq 0x3f6c
callq 0x3816
callq 0x3fbc
movl %eax, %r12d
leaq 0xa(%rsp), %r13
movq %r13, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x3de8
movq %r13, %rdi
movl %r12d, %esi
movl $0x1, %edx
movl %ebp, %ecx
callq 0x2a90
movq %rbx, %rdi
xorl %esi, %esi
movl %r12d, %edx
movl $0x1, %ecx
callq 0x3b9d
jmp 0x2f30
callq 0x3816
movslq 0x111e9(%rip), %rax     # 0x14120
cmpb $0x9, (%rax,%rbx)
je 0x2f2b
jmp 0x2ca3
callq 0x40fb
movslq 0xc(%rax), %rbp
movl (%rax), %eax
notl %eax
testl $0x101, %eax            # imm = 0x101
jne 0x2fcd
movslq 0x111cf(%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 0x2f8a
btq %rdi, %r9
jb 0x2ff4
cmpl $0x9, %edi
je 0x2ff4
cmpl $0x13, %eax
jg 0x2ff4
cmpl $0x3e, %edi
ja 0x2fb5
movb $0x1, %sil
movl %edi, %edi
btq %rdi, %r8
jae 0x2fb5
incl %r15d
movl %r15d, 0x1117e(%rip)    # 0x1412c
incq %rcx
movl %esi, %edx
jmp 0x2f7b
testb %dl, %dl
je 0x2fc9
movslq %eax, %rdx
incl %eax
leaq 0x6ffb(%rip), %rsi      # 0x9fc0
movl %r15d, (%rsi,%rdx,4)
xorl %esi, %esi
jmp 0x2fa4
testb $0x43, %al
jne 0x2df4
callq 0x3816
andl $0x3ffff, %ebp          # imm = 0x3FFFF
movl %ebp, %edi
callq 0x415a
testb %al, %al
jne 0x2ca3
jmp 0x2c99
cmpl $0x13, %eax
jg 0x301d
movslq %eax, %rcx
leaq 0x6fbd(%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 0x11117(%rip), %rdi     # 0x14140
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl %r15d, 0x1128a(%rip)    # 0x142c0
leaq 0x7023(%rip), %rax      # 0xa060
movq (%rax,%rbp,8), %rax
movq %rax, 0x9328(%rip)      # 0xc370
testq %rax, %rax
jne 0x2c99
jmp 0x2c9e
callq 0x2340