// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x128c6(%rip), %r13     # 0x17c08
leaq 0x124c7(%rip), %r12     # 0x17810
movb (%r13,%r12), %al
movb %al, 0x128bc(%rip)      # 0x17c10
callq 0x2190
movq %rax, %rbx
movq (%rax), %rcx
movq 0x12892(%rip), %rsi     # 0x17bf8
movsbq (%rsi,%r12), %rax
movzwl (%rcx,%rax,2), %ecx
btl $0xa, %ecx
jb 0x53e4
btl $0xb, %ecx
jb 0x5423
movzbl %al, %eax
cmpl $0x5b, %eax
je 0x55d6
cmpl $0x28, %eax
je 0x54fb
cmpl $0x2e, %eax
je 0x55b1
cmpl $0x3d, %eax
je 0x559e
cmpl $0x22, %eax
jne 0x55c1
leaq 0x2(%rsi), %rax
cmpq 0x12c6e(%rip), %rax     # 0x18028
jge 0x562c
movsbq 0x1(%rsi,%r12), %rbx
orq $0x80, %rbx
movb 0x2(%rsi,%r12), %cl
movb %cl, 0x12838(%rip)      # 0x17c10
movq %rax, 0x12841(%rip)     # 0x17c20
jmp 0x563a
callq 0x4323
movq %rax, %rbx
movl (%rax), %eax
testb $0x1, %al
jne 0x5483
cmpq $0x2, 0x8922(%rip)      # 0xdd20
jne 0x5594
movq %rbx, %rsi
addq $0x4, %rsi
movq 0x127e6(%rip), %rdx     # 0x17bf8
leaq 0x6607(%rip), %rdi      # 0xba20
callq 0x4043
jmp 0x5594
leaq 0x6596(%rip), %r14      # 0xb9c0
leaq 0x659f(%rip), %r15      # 0xb9d0
movq 0x123c8(%rip), %rax     # 0x17800
xorl %ebp, %ebp
cmpq %r13, %rsi
jge 0x54b0
movq (%rbx), %rdx
movsbq (%rsi,%r12), %rcx
testb $0x8, 0x1(%rdx,%rcx,2)
je 0x5463
addq $-0x30, %rcx
cmpq %rax, %rcx
jge 0x546f
incq %rsi
imulq %rax, %rbp
addq %rcx, %rbp
jmp 0x543a
movq 0x1278e(%rip), %rsi     # 0x17bf8
movq %r14, %rdi
jmp 0x5472
movq %r15, %rdi
callq 0x4122
movq 0x1278a(%rip), %r13     # 0x17c08
movq %r13, %rsi
jmp 0x5431
movl %eax, %ecx
notl %ecx
testb $0x43, %cl
jne 0x54c1
movq 0x10(%rbx), %rcx
cmpq $0x19, %rcx
je 0x5574
cmpq $0x4, %rcx
jne 0x54cc
movq $0xa, 0x12355(%rip) # 0x17800
jmp 0x557f
callq 0x394b
movq %rbp, 0x66d4(%rip)      # 0xbb90
jmp 0x5646
testw $0x101, %cx             # imm = 0x101
jne 0x5594
cmpq $0x2, 0x884c(%rip)      # 0xdd20
jne 0x557f
movq %rbx, %rsi
addq $0x4, %rsi
movq 0x12710(%rip), %rdx     # 0x17bf8
leaq 0x6541(%rip), %rdi      # 0xba30
callq 0x4043
movl (%rbx), %eax
jmp 0x557f
callq 0x4164
callq 0x41b6
movq %rax, %rbx
andl $0xfff, %ebx            # imm = 0xFFF
movq 0x126e3(%rip), %rax     # 0x17bf8
cmpb $0x29, (%rax,%r12)
jne 0x5532
movq 0x126e5(%rip), %rax     # 0x17c08
movb (%rax,%r12), %al
movb %al, 0x126e3(%rip)      # 0x17c10
callq 0x394b
movq %rbx, %rdi
callq 0x5294
testb %al, %al
jne 0x560d
movq 0x10a57(%rip), %rsi     # 0x15fa0
leaq 0x11a80(%rip), %rdi     # 0x16fd0
movq %rbx, %rdx
callq 0x52d9
movq %rax, %rcx
movl 0x10a57(%rip), %eax     # 0x15fb8
addl 0x10a39(%rip), %eax     # 0x15fa0
andl $0x7f80, %eax           # imm = 0x7F80
addq %rcx, %rax
jmp 0x5623
movq $0x8, 0x12281(%rip) # 0x17800
movl %eax, 0x65fb(%rip)      # 0xbb80
leaq 0x65f4(%rip), %rbx      # 0xbb80
andq $0x0, 0x65fc(%rip)      # 0xbb90
callq 0x394b
jmp 0x564d
leaq 0x644b(%rip), %rdi      # 0xb9f0
callq 0x565f
callq 0x56e2
jmp 0x55cd
movq 0x10a00(%rip), %rbx     # 0x15fb8
addq 0x109e1(%rip), %rbx     # 0x15fa0
jmp 0x563a
leaq 0x63c8(%rip), %rdi      # 0xb990
callq 0x565f
callq 0x4164
xorl %ebx, %ebx
jmp 0x563f
callq 0x4164
callq 0x41b6
movq %rax, %rbx
andl $0xfff, %ebx            # imm = 0xFFF
movq 0x12608(%rip), %rax     # 0x17bf8
cmpb $0x5d, (%rax,%r12)
jne 0x560d
movq 0x1260a(%rip), %rax     # 0x17c08
movb (%rax,%r12), %al
movb %al, 0x12608(%rip)      # 0x17c10
callq 0x394b
movq 0x10994(%rip), %rsi     # 0x15fa8
leaq 0x11dbd(%rip), %rdi     # 0x173d8
movq %rbx, %rdx
callq 0x52d9
movq %rax, 0x6566(%rip)      # 0xbb90
jmp 0x5646
leaq 0x64ad(%rip), %rdi      # 0xbae0
callq 0x565f
xorl %ebx, %ebx
callq 0x394b
movq %rbx, 0x654a(%rip)      # 0xbb90
leaq 0x6533(%rip), %rbx      # 0xbb80
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq