// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movslq 0x877e(%rip), %r13      # 0xd80c
leaq 0x86eb(%rip), %r12      # 0xd780
movb (%r13,%r12), %al
movb %al, 0x8770(%rip)       # 0xd810
callq 0x21a0
movq %rax, %rbx
movq (%rax), %rdx
movl 0x8753(%rip), %esi      # 0xd804
movslq %esi, %rax
movsbq (%rax,%r12), %rcx
movzwl (%rdx,%rcx,2), %edx
btl $0xa, %edx
jb 0x5138
btl $0xb, %edx
jb 0x5171
movzbl %cl, %ecx
cmpl $0x5b, %ecx
je 0x5281
cmpl $0x28, %ecx
je 0x51e0
cmpl $0x2e, %ecx
je 0x5256
cmpl $0x3d, %ecx
je 0x5243
cmpl $0x22, %ecx
jne 0x526c
movl 0x8719(%rip), %ecx      # 0xd81c
cmpl 0x8717(%rip), %ecx      # 0xd820
jge 0x52cb
movsbl 0x1(%rax,%r12), %ebx
orl $0x80, %ebx
movq %rax, %rcx
addq $0x2, %rcx
movb 0x2(%rax,%r12), %al
movb %al, 0x86e3(%rip)       # 0xd810
movl %ecx, 0x86e9(%rip)      # 0xd81c
jmp 0x52d9
callq 0x429c
movq %rax, %rbx
testb $0x1, (%rax)
jne 0x5167
cmpl $0x2, 0x6294(%rip)      # 0xb3e0
jne 0x5167
movq %rbx, %rsi
addq $0x4, %rsi
movl 0x86a9(%rip), %edx      # 0xd804
leaq 0x6056(%rip), %rdi      # 0xb1b8
callq 0x4045
callq 0x3907
jmp 0x52ec
leaq 0x5fe0(%rip), %r14      # 0xb158
leaq 0x5fe9(%rip), %r15      # 0xb168
movswl 0x85ec(%rip), %eax      # 0xd772
movslq %esi, %rsi
xorl %ebp, %ebp
cmpl %r13d, %esi
jge 0x51cf
movq (%rbx), %rdx
movsbq (%rsi,%r12), %rcx
testb $0x8, 0x1(%rdx,%rcx,2)
je 0x51b0
addl $-0x30, %ecx
cmpl %eax, %ecx
jge 0x51bb
imull %eax, %ebp
addl %ecx, %ebp
incq %rsi
jmp 0x518b
movl 0x864e(%rip), %esi      # 0xd804
movq %r14, %rdi
jmp 0x51be
movq %r15, %rdi
callq 0x411d
movl 0x8642(%rip), %r13d     # 0xd80c
movl %r13d, %esi
jmp 0x517f
callq 0x3907
movw %bp, 0x6109(%rip)       # 0xb2e4
jmp 0x52e5
callq 0x415b
callq 0x41ab
movl %eax, %ebx
andl $0xfff, %ebx            # imm = 0xFFF
movslq 0x860b(%rip), %rax      # 0xd804
cmpb $0x29, (%rax,%r12)
jne 0x5205
callq 0x415b
movzwl 0x8544(%rip), %edx      # 0xd750
shrl $0x7, %edx
andl $0x1f, %edx
movzwl %bx, %esi
leaq 0x6434(%rip), %rdi      # 0xb650
callq 0x5012
movzwl 0x852e(%rip), %ecx      # 0xd756
addw 0x8521(%rip), %cx       # 0xd750
andl $0x7f80, %ecx           # imm = 0x7F80
addl %eax, %ecx
movw %cx, 0x60a6(%rip)       # 0xb2e4
jmp 0x52e5
leaq 0x5f3e(%rip), %rdi      # 0xb188
callq 0x52fe
callq 0x5380
jmp 0x5278
movzwl 0x84f3(%rip), %ebx      # 0xd750
andl $0xfff, %ebx            # imm = 0xFFF
addw 0x84ec(%rip), %bx       # 0xd756
jmp 0x52d9
leaq 0x5eb5(%rip), %rdi      # 0xb128
callq 0x52fe
callq 0x415b
xorl %ebx, %ebx
jmp 0x52de
callq 0x415b
callq 0x41ab
movl %eax, %ebx
andl $0xfff, %ebx            # imm = 0xFFF
movslq 0x856a(%rip), %rax      # 0xd804
cmpb $0x5d, (%rax,%r12)
jne 0x52a6
callq 0x415b
movzwl 0x84a5(%rip), %edx      # 0xd752
shrl $0x7, %edx
andl $0x1f, %edx
movzwl %bx, %esi
leaq 0x6393(%rip), %rdi      # 0xb650
callq 0x5012
movw %ax, 0x601b(%rip)       # 0xb2e4
jmp 0x52e5
leaq 0x5fb6(%rip), %rdi      # 0xb288
callq 0x52fe
xorl %ebx, %ebx
callq 0x3907
movw %bx, 0x5fff(%rip)       # 0xb2e4
leaq 0x5fec(%rip), %rbx      # 0xb2d8
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq