// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/crossassemblers/macro7/macro7.c
// Function: eval
SYM_T *eval()
{
  WORD32  digit;
  WORD32  from;
  WORD32  loc;
  SYM_T  *sym;
  WORD32  val;

  val = 0;

  delimiter = line[lexterm];
  if( isalpha( line[lexstart] ))
  {
    sym = evalSymbol();
    if( M_UNDEFINED( sym->type ))
    {
      if( pass == 2 )
      {
        errorSymbol( &undefined_symbol, sym->name, lexstart );
      }
      nextLexeme();
      return( sym );
    }
    else if( M_PSEUDO( sym->type ))
    {
      if( sym->val == DECIMAL )
      {
        radix = 10;
      }
      else if( sym->val == OCTAL )
      {
        radix = 8;
      }
      else if( pass == 2 )
      {
        errorSymbol( &misplaced_symbol, sym->name, lexstart );
      }
      sym_eval.type = sym->type;
      sym_eval.val = 0;
      nextLexeme();
      return( &sym_eval );
    }
    else if( M_MACRO( sym->type ))
    {
      if( pass == 2 )
      {
        errorSymbol( &misplaced_symbol, sym->name, lexstart );
      }
      sym_eval.type = sym->type;
      sym_eval.val = 0;
      nextLexeme();
      return( &sym_eval );
    }
    else
    {
      nextLexeme();
      return( sym );
    }
  }
  else if( isdigit( line[lexstart] ))
  {
    from = lexstart;
    val = 0;
    while( from < lexterm )
    {
      if( isdigit( line[from] ))
      {
        digit = (WORD32) line[from++] - (WORD32) '0';
        if( digit < radix )
        {
          val = val * radix + digit;
        }
        else
        {
          errorLexeme( &number_not_radix, from - 1 );
          val = 0;
          from = lexterm;
        }
      }
      else
      {
        errorLexeme( &not_a_number, lexstart );
        val = 0;
        from = lexterm;
      }
    }
    nextLexeme();
    sym_eval.val = val;
    return( &sym_eval );
  }
  else
  {
    switch( line[lexstart] )
    {
    case '"':                   /* Character literal                          */
      if( cc + 2 < maxcc )
      {
        val = line[lexstart + 1] | 0200;
        delimiter = line[lexstart + 2];
        cc = lexstart + 2;
      }
      else
      {
        errorMessage( &no_literal_value, lexstart );
      }
      nextLexeme();
      break;

    case '.':                   /* Value of Current Location Counter          */
      val = clc;
      nextLexeme();
      break;

    case '(':                   /* Generate literal on current page.          */
      nextLexBlank();           /* Skip paren                                 */
      val = getExprs() & 0777777;

      if( line[lexstart] == ')' )
      {
        delimiter = line[lexterm];
        nextLexeme();           /* Skip end paren                             */
      }
      else
      {
        /* errorMessage( "parens", NULL );                                    */
      }

      loc = insertLiteral( &cp, clc, val );
      sym_eval.val = loc + ( clc & 060000 );
      return( &sym_eval );

    default:
      switch( line[lexstart] )
      {
      case '=':
        errorMessage( &illegal_equals, lexstart );
        moveToEndOfLine();
        break;

      default:
        errorMessage( &illegal_character, lexstart );
        break;
      }
      val = 0;                  /* On error, set value to zero.               */
      nextLexBlank();           /* Go past illegal character.                 */
    }
  }
  sym_eval.val = val;
  return( &sym_eval );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movslq 0xfa7f(%rip), %r13      # 0x14120
leaq 0xf8e8(%rip), %r12      # 0x13f90
movb (%r13,%r12), %al
movb %al, 0xfa71(%rip)       # 0x14124
callq 0x2170
movq %rax, %rbx
movq (%rax), %rdx
movl 0xfa4c(%rip), %esi      # 0x14110
movslq %esi, %rax
movsbq (%rax,%r12), %rcx
movzwl (%rdx,%rcx,2), %edx
btl $0xa, %edx
jb 0x4745
btl $0xb, %edx
jb 0x4782
movzbl %cl, %ecx
cmpl $0x3d, %ecx
je 0x489f
cmpl $0x28, %ecx
je 0x4838
cmpl $0x2e, %ecx
je 0x4894
cmpl $0x22, %ecx
jne 0x48b2
movl 0xfa0f(%rip), %ecx      # 0x1411c
addl $0x2, %ecx
cmpl 0xf9fe(%rip), %ecx      # 0x14114
jge 0x4912
movsbl 0x1(%rax,%r12), %ebx
orl $0x80, %ebx
movq %rax, %rcx
addq $0x2, %rcx
movb 0x2(%rax,%r12), %al
movb %al, 0xf9ea(%rip)       # 0x14124
movl %ecx, 0xf9dc(%rip)      # 0x1411c
jmp 0x4920
callq 0x3ea6
movq %rax, %rbx
movl (%rax), %eax
testb $0x1, %al
jne 0x47df
cmpl $0x2, 0x7982(%rip)      # 0xc0e0
jne 0x490b
movq %rbx, %rsi
addq $0x4, %rsi
movl 0xf99f(%rip), %edx      # 0x14110
leaq 0x56d8(%rip), %rdi      # 0x9e50
callq 0x3c3b
jmp 0x490b
leaq 0x5667(%rip), %r14      # 0x9df0
leaq 0x5670(%rip), %r15      # 0x9e00
movl 0xf7ee(%rip), %eax      # 0x13f84
movslq %esi, %rsi
xorl %ebp, %ebp
cmpl %r13d, %esi
jge 0x480b
movq (%rbx), %rdx
movsbq (%rsi,%r12), %rcx
testb $0x8, 0x1(%rdx,%rcx,2)
je 0x47c0
addl $-0x30, %ecx
cmpl %eax, %ecx
jge 0x47cb
imull %eax, %ebp
addl %ecx, %ebp
incq %rsi
jmp 0x479b
movl 0xf94a(%rip), %esi      # 0x14110
movq %r14, %rdi
jmp 0x47ce
movq %r15, %rdi
callq 0x3d11
movl 0xf946(%rip), %r13d     # 0x14120
movl %r13d, %esi
jmp 0x4790
movl %eax, %ecx
notl %ecx
testb $0x43, %cl
jne 0x481b
movl 0xc(%rbx), %eax
cmpl $0x9, %eax
je 0x48c7
testl %eax, %eax
jne 0x48d3
movl $0xa, 0xf77e(%rip)      # 0x13f84
jmp 0x48f5
callq 0x368c
movl %ebp, 0x5766(%rip)      # 0x9f7c
jmp 0x492b
testw $0x101, %cx             # imm = 0x101
jne 0x490b
cmpl $0x2, 0x78b3(%rip)      # 0xc0e0
je 0x48dc
jmp 0x48f7
callq 0x3d4f
callq 0x3d9f
movl %eax, %ebx
andl $0x3ffff, %ebx          # imm = 0x3FFFF
movslq 0xf8bf(%rip), %rax      # 0x14110
cmpb $0x29, (%rax,%r12)
jne 0x486e
movslq 0xf8c1(%rip), %rax      # 0x14120
movb (%rax,%r12), %al
movb %al, 0xf8bb(%rip)       # 0x14124
callq 0x368c
leaq 0x7af3(%rip), %rdi      # 0xc368
movl %ebx, %edx
callq 0x4660
movl $0x6000, %ecx           # imm = 0x6000
andl 0x7ac9(%rip), %ecx      # 0xc350
addl %eax, %ecx
movl %ecx, 0x56ed(%rip)      # 0x9f7c
jmp 0x492b
movl 0x7ab6(%rip), %ebx      # 0xc350
jmp 0x4920
leaq 0x557a(%rip), %rdi      # 0x9e20
callq 0x4944
callq 0x49c5
jmp 0x48be
leaq 0x5507(%rip), %rdi      # 0x9dc0
callq 0x4944
callq 0x3d4f
xorl %ebx, %ebx
jmp 0x4925
movl $0x8, 0xf6b3(%rip)      # 0x13f84
jmp 0x48f5
cmpl $0x2, 0x7806(%rip)      # 0xc0e0
jne 0x48f5
movq %rbx, %rsi
addq $0x4, %rsi
movl 0xf827(%rip), %edx      # 0x14110
leaq 0x5570(%rip), %rdi      # 0x9e60
callq 0x3c3b
movl (%rbx), %eax
movl %eax, 0x5673(%rip)      # 0x9f70
leaq 0x566c(%rip), %rbx      # 0x9f70
andl $0x0, 0x5671(%rip)      # 0x9f7c
callq 0x368c
jmp 0x4932
leaq 0x55c7(%rip), %rdi      # 0x9ee0
callq 0x4944
xorl %ebx, %ebx
callq 0x368c
movl %ebx, 0x5651(%rip)      # 0x9f7c
leaq 0x563e(%rip), %rbx      # 0x9f70
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq