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

  val = 0;

  delimiter = line[lexterm];
  if( isalpha( line[lexstart] ))
  {
    sym = evalSymbol();
    if( M_UNDEFINED( sym->type ) && pass == 2 )
    {
      errorSymbol( &undefined_symbol, sym->name, lexstart );
      nextLexeme();
      return( sym );
    }
    else
    {
      nextLexeme();
      return( sym );
    }
  }
  else if( isdigit( line[lexstart] ))
  {
    from = lexstart;
    val = 0;
    while( from < lexterm )
    {
      if( isdigit( line[from] ))
      {
        digit = (WORD16) line[from++] - (WORD16) '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 + 1 <= 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 & 07777) + reloc;
      nextLexeme();
      break;

    case '[':                   /* Generate literal on page zero.             */
      if( !literals_ok && LITERAL_ERROR)
      {
        errorMessage( &literal_gen_off, lexstart );
      }
      nextLexBlank();           /* Skip bracket                               */
      val = getExprs() & 07777;

      if( line[lexstart] == ']' )
      {
        nextLexBlank();         /* Skip end bracket                           */
      }

      sym_eval.val = (literals_ok || !LITERAL_ERROR) ? insertLiteral( cp , val,
        GET_PAGE_INDEX(field)) : 0;
      return( &sym_eval );

    case '(':                   /* Generate literal on current page.          */
      if( !literals_ok && LITERAL_ERROR)
      {
        errorMessage( &literal_gen_off, lexstart );
      }

      nextLexBlank();           /* Skip paren                                 */
      val = getExprs() & 07777;

      if( line[lexstart] == ')' )
      {
        nextLexBlank();         /* Skip end paren                             */
      }

      loc = (literals_ok || !LITERAL_ERROR) ? insertLiteral( cp, val, GET_PAGE_INDEX(clc) ) : 0;
      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 %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movslq 0x8025(%rip), %r14      # 0xd81c
leaq 0x7f92(%rip), %r15      # 0xd790
movb (%r14,%r15), %al
movb %al, 0x8018(%rip)       # 0xd820
callq 0x21c0
movq (%rax), %rdx
movslq 0x7ffd(%rip), %rbx      # 0xd814
movsbq (%rbx,%r15), %rcx
movzwl (%rdx,%rcx,2), %edx
btl $0xa, %edx
jb 0x58a4
btl $0xb, %edx
jb 0x58dd
movzbl %cl, %eax
cmpl $0x2d, %eax
jle 0x5922
cmpl $0x2e, %eax
je 0x59c0
cmpl $0x3d, %eax
je 0x59d9
cmpl $0x5b, %eax
jne 0x5a57
callq 0x44ee
callq 0x453e
movl %eax, %ebx
andl $0xfff, %ebx            # imm = 0xFFF
movslq 0x7fa4(%rip), %rax      # 0xd814
cmpb $0x5d, (%rax,%r15)
jne 0x587c
callq 0x44ee
movzwl 0x7edf(%rip), %edx      # 0xd762
shrl $0x7, %edx
andl $0x1f, %edx
movzwl %bx, %esi
leaq 0x5dcd(%rip), %rdi      # 0xb660
callq 0x5772
movw %ax, 0x5a55(%rip)       # 0xb2f4
jmp 0x5aa3
callq 0x4638
movq %rax, %rbx
testb $0x1, (%rax)
jne 0x58d3
cmpl $0x2, 0x5b38(%rip)      # 0xb3f0
jne 0x58d3
movq %rbx, %rsi
addq $0x4, %rsi
movl 0x7f4d(%rip), %edx      # 0xd814
leaq 0x58fa(%rip), %rdi      # 0xb1c8
callq 0x43d8
callq 0x3be8
jmp 0x5aaa
xorl %ebp, %ebp
cmpl %r14d, %ebx
jge 0x5a97
movq (%rax), %rax
movswl 0x7e90(%rip), %ecx      # 0xd782
movsbq (%rbx,%r15), %rdx
testb $0x8, 0x1(%rax,%rdx,2)
je 0x5997
addl $-0x30, %edx
cmpl %ecx, %edx
jge 0x5a6e
movzwl %bp, %ebp
imull %ecx, %ebp
addl %edx, %ebp
incq %rbx
cmpl %r14d, %ebx
jl 0x58f2
jmp 0x5a97
cmpl $0x22, %eax
je 0x5a1f
cmpl $0x28, %eax
jne 0x5a57
callq 0x44ee
callq 0x453e
movl %eax, %ebx
andl $0xfff, %ebx            # imm = 0xFFF
movslq 0x7ec7(%rip), %rax      # 0xd814
cmpb $0x29, (%rax,%r15)
jne 0x5959
callq 0x44ee
movzwl 0x7e00(%rip), %edx      # 0xd760
shrl $0x7, %edx
andl $0x1f, %edx
movzwl %bx, %esi
leaq 0x5cf0(%rip), %rdi      # 0xb660
callq 0x5772
movzwl 0x7dea(%rip), %ecx      # 0xd766
addw 0x7ddd(%rip), %cx       # 0xd760
andl $0x7f80, %ecx           # imm = 0x7F80
addl %eax, %ecx
movw %cx, 0x5962(%rip)       # 0xb2f4
jmp 0x5aa3
movl 0x7e77(%rip), %ebx      # 0xd814
leaq 0x11(%rsp), %r15
movq %r15, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x4368
leaq 0x57b2(%rip), %rdi      # 0xb168
movq %r15, %rsi
movl %ebx, %edx
jmp 0x5a90
movzwl 0x7d99(%rip), %ebp      # 0xd760
andl $0xfff, %ebp            # imm = 0xFFF
addw 0x7d92(%rip), %bp       # 0xd766
jmp 0x5a97
leaq 0x57b8(%rip), %rdi      # 0xb198
movl %ebx, %esi
callq 0x5ac8
movslq 0x7e3e(%rip), %rax      # 0xd82c
addq %rax, %r15
movzbl (%r15), %ecx
testl %ecx, %ecx
je 0x5a0b
cmpl $0xa, %ecx
je 0x5a0b
incl %eax
movl %eax, 0x7e26(%rip)      # 0xd82c
incq %r15
jmp 0x59f1
movl %eax, 0x7e03(%rip)      # 0xd814
movl %eax, 0x7e05(%rip)      # 0xd81c
movl %eax, 0x7e07(%rip)      # 0xd824
jmp 0x5a65
movl 0x7e07(%rip), %eax      # 0xd82c
cmpl 0x7e05(%rip), %eax      # 0xd830
jge 0x5ab8
movsbl 0x1(%rbx,%r15), %ebp
orl $0x80, %ebp
movq %rbx, %rax
addq $0x2, %rax
movb 0x2(%rbx,%r15), %cl
movb %cl, 0x7dd1(%rip)       # 0xd820
movl %eax, 0x7dd7(%rip)      # 0xd82c
jmp 0x5a97
leaq 0x56da(%rip), %rdi      # 0xb138
movl %ebx, %esi
callq 0x5ac8
callq 0x44ee
xorl %ebp, %ebp
jmp 0x5a9c
movl 0x7da0(%rip), %esi      # 0xd814
leaq 0xa(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
callq 0x4368
leaq 0x56ed(%rip), %rdi      # 0xb178
movq %r15, %rsi
movl %ebx, %edx
callq 0x43d8
xorl %ebp, %ebp
callq 0x3be8
movw %bp, 0x5851(%rip)       # 0xb2f4
leaq 0x583e(%rip), %rbx      # 0xb2e8
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x57d9(%rip), %rdi      # 0xb298
movl %ebx, %esi
callq 0x5ac8
jmp 0x5a95