// File: /workspace/github_c_makefile_star2_O3/AK6DN[P]dec-utilities-for-pdp/macro8x/macro8x.c
// Function: eval
SYM_T *eval()
{
  WORD32  digit;
  WORD32  from;
  WORD32  loc;
  SYM_T  *sym;
  WORD32  val;

  val = 0;

  delimiter = line[lexterm];
  if( is_alpha( 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( is_digit( line[lexstart] ))
  {
    from = lexstart;
    val = 0;
    while( from < lexterm )
    {
      if( is_digit( 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( lexstart + 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 + reloc;
      nextLexeme();
      break;

    case '[':                   /* Generate literal on page zero.             */
      nextLexBlank();           /* Skip bracket                               */
      val = getExprs() & 07777;
      if( line[lexstart] == ']' )
      {
        delimiter = line[lexterm];
        nextLexeme();           /* Skip end bracket                           */
      }
      else
      {
        /* errorMessage( "parens", lexstart );                                */
      }
      sym_eval.val = insertLiteral( &pz, field, val );
      return( &sym_eval );

    case '(':                   /* Generate literal on current page.          */
      nextLexBlank();           /* Skip paren                                 */
      val = getExprs() & 07777;

      if( line[lexstart] == ')' )
      {
        delimiter = line[lexterm];
        nextLexeme();           /* Skip end paren                             */
      }
      else
      {
        /* errorMessage( "parens", NULL );                                    */
      }
      if( testZeroPool( val ))
      {
        sym_eval.val = insertLiteral( &pz, field, val );
      }
      else
      {
        loc = insertLiteral( &cp, clc, val );
        sym_eval.val = loc + (( clc + reloc ) & 077600 );
      }
      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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x1339c(%rip), %r14     # 0x18c18
leaq 0x12f9d(%rip), %r15     # 0x18820
movb (%r14,%r15), %al
movb %al, 0x13393(%rip)      # 0x18c20
callq 0x21a0
movq (%rax), %rdx
movq 0x1336c(%rip), %rbx     # 0x18c08
movsbq (%rbx,%r15), %rcx
movzwl (%rdx,%rcx,2), %edx
btl $0xa, %edx
jb 0x5966
btl $0xb, %edx
jb 0x59a1
movzbl %cl, %eax
cmpl $0x2d, %eax
jle 0x5a50
cmpl $0x2e, %eax
je 0x5b3a
cmpl $0x3d, %eax
je 0x5b4d
cmpl $0x5b, %eax
jne 0x5bf6
callq 0x43d7
callq 0x4429
movq %rax, %rbx
andl $0xfff, %ebx            # imm = 0xFFF
movq 0x1330e(%rip), %rax     # 0x18c08
cmpb $0x5d, (%rax,%r15)
jne 0x5917
movq 0x13310(%rip), %rax     # 0x18c18
movb (%rax,%r15), %al
movb %al, 0x1330e(%rip)      # 0x18c20
callq 0x3ad6
movl 0x1169b(%rip), %eax     # 0x16fb8
shrl $0x7, %eax
movzbl %al, %eax
movl %eax, %edx
shll $0x3, %edx
leaq 0x116a1(%rip), %rcx     # 0x16fd0
movq (%rdx,%rcx), %rcx
leaq 0x11e96(%rip), %rsi     # 0x177d0
movq (%rdx,%rsi), %rdx
leaq 0x12aa3(%rip), %rdi     # 0x183e8
leaq (%rdi,%rcx,8), %r8
cmpq %rdx, %rcx
jle 0x5c83
decq %rcx
leaq -0x8(%r8), %r9
cmpq %rbx, (%r8)
movq %r9, %r8
jne 0x5949
jmp 0x5c8f
callq 0x45df
movq %rax, %rbx
movl (%rax), %eax
testb $0x1, %al
jne 0x59e8
cmpq $0x2, 0x93b4(%rip)      # 0xed30
jne 0x5bec
movq %rbx, %rsi
addq $0x4, %rsi
movq 0x13278(%rip), %rdx     # 0x18c08
leaq 0x7099(%rip), %rdi      # 0xca30
callq 0x42b6
jmp 0x5bec
cmpq %r14, %rbx
jge 0x5c38
movq (%rax), %rax
movq 0x12e5c(%rip), %rcx     # 0x18810
xorl %r12d, %r12d
movsbq (%rbx,%r15), %rdx
testb $0x8, 0x1(%rax,%rdx,2)
je 0x5b14
addq $-0x30, %rdx
cmpq %rcx, %rdx
jge 0x5c0f
incq %rbx
imulq %rcx, %r12
addq %rdx, %r12
cmpq %r14, %rbx
jl 0x59b7
jmp 0x5c3b
movl %eax, %ecx
notl %ecx
testb $0x43, %cl
jne 0x5a15
movq 0x10(%rbx), %rcx
cmpq $0x19, %rcx
je 0x5bc9
cmpq $0x4, %rcx
jne 0x5a21
movq $0xa, 0x12e00(%rip) # 0x18810
jmp 0x5bd4
testl $0x101, %ecx            # imm = 0x101
jne 0x5bec
cmpq $0x2, 0x9307(%rip)      # 0xed30
jne 0x5bd4
movq %rbx, %rsi
addq $0x4, %rsi
movq 0x131cb(%rip), %rdx     # 0x18c08
leaq 0x6ffc(%rip), %rdi      # 0xca40
callq 0x42b6
movl (%rbx), %eax
jmp 0x5bd4
cmpl $0x22, %eax
je 0x5b94
cmpl $0x28, %eax
jne 0x5bf6
callq 0x43d7
callq 0x4429
movq %rax, %rbx
andl $0xfff, %ebx            # imm = 0xFFF
movq 0x1318c(%rip), %rax     # 0x18c08
cmpb $0x29, (%rax,%r15)
jne 0x5a99
movq 0x1318e(%rip), %rax     # 0x18c18
movb (%rax,%r15), %al
movb %al, 0x1318c(%rip)      # 0x18c20
callq 0x3ad6
movl 0x11519(%rip), %eax     # 0x16fb8
shrl $0x7, %eax
movzbl %al, %eax
leal (,%rax,8), %ecx
leaq 0x11d1d(%rip), %rsi     # 0x177d0
movq (%rcx,%rsi), %rdx
leaq 0x11512(%rip), %rdi     # 0x16fd0
movq (%rcx,%rdi), %rcx
cmpq %rcx, %rdx
jge 0x5ae4
leaq 0x1291a(%rip), %rdi     # 0x183e8
movq %rdx, %r8
cmpq %rbx, 0x8(%rdi,%r8,8)
je 0x5c69
incq %r8
cmpq %r8, %rcx
jne 0x5ad1
movq 0x114c5(%rip), %rsi     # 0x16fb0
leaq 0x124ee(%rip), %rdi     # 0x17fe0
movq %rbx, %rdx
callq 0x5812
movl 0x114c8(%rip), %ecx     # 0x16fc8
addl 0x114aa(%rip), %ecx     # 0x16fb0
andl $0x7f80, %ecx           # imm = 0x7F80
addq %rax, %rcx
jmp 0x5c8f
movq 0x130ed(%rip), %rbx     # 0x18c08
leaq 0x11(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x423f
leaq 0x6e9b(%rip), %rdi      # 0xc9d0
jmp 0x5c2d
movq 0x11487(%rip), %r14     # 0x16fc8
addq 0x11468(%rip), %r14     # 0x16fb0
jmp 0x5c5b
leaq 0x6eac(%rip), %rdi      # 0xca00
movq %rbx, %rsi
callq 0x5cac
movq 0x130cd(%rip), %rax     # 0x18c30
movzbl (%rax,%r15), %ecx
testl %ecx, %ecx
je 0x5b7d
cmpl $0xa, %ecx
je 0x5b7d
incq %rax
movq %rax, 0x130b5(%rip)     # 0x18c30
jmp 0x5b63
movq %rax, 0x13084(%rip)     # 0x18c08
movq %rax, 0x1308d(%rip)     # 0x18c18
movq %rax, 0x13096(%rip)     # 0x18c28
jmp 0x5c05
leaq 0x2(%rbx), %rax
cmpq 0x13499(%rip), %rax     # 0x19038
jge 0x5c49
movsbq 0x1(%rbx,%r15), %r14
orq $0x80, %r14
movb 0x2(%rbx,%r15), %cl
movb %cl, 0x13063(%rip)      # 0x18c20
movq %rax, 0x1306c(%rip)     # 0x18c30
jmp 0x5c5b
movq $0x8, 0x12c3c(%rip) # 0x18810
movl %eax, 0x6fb6(%rip)      # 0xcb90
leaq 0x6faf(%rip), %rbx      # 0xcb90
movq $0x0, 0x6fb4(%rip) # 0xcba0
callq 0x3ad6
jmp 0x5c9d
leaq 0x6da3(%rip), %rdi      # 0xc9a0
movq %rbx, %rsi
callq 0x5cac
callq 0x43d7
xorl %r14d, %r14d
jmp 0x5c60
movq 0x12ff2(%rip), %rsi     # 0x18c08
leaq 0xa(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x423f
leaq 0x6db3(%rip), %rdi      # 0xc9e0
movq %r15, %rsi
movq %rbx, %rdx
callq 0x42b6
xorl %r12d, %r12d
callq 0x3ad6
movq %r12, 0x6f59(%rip)      # 0xcba0
jmp 0x5c96
leaq 0x6ea0(%rip), %rdi      # 0xcaf0
movq %rbx, %rsi
callq 0x5cac
xorl %r14d, %r14d
callq 0x3ad6
movq %r14, 0x6f39(%rip)      # 0xcba0
jmp 0x5c96
leaq (%rdi,%rcx,8), %r8
cmpq %rdx, %rcx
jle 0x5c83
decq %rcx
leaq -0x8(%r8), %r9
cmpq %rbx, (%r8)
movq %r9, %r8
jne 0x5c6d
jmp 0x5c8f
leaq -0x1(%rdx), %rcx
movq %rcx, (%rsi,%rax,8)
movq %rbx, (%rdi,%rdx,8)
movq %rcx, 0x6f0a(%rip)      # 0xcba0
leaq 0x6ef3(%rip), %rbx      # 0xcb90
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq