// File: /workspace/github_c_makefile_star2_O2/mist64[P]cbm6502asm/src/direct2.c
// Function: dir2equ
int dir2equ() {
	/* handle the various forms of equates */

	long l;
	int i;
	char *sym = 0, *equal = 0, *exp = 0, localsym[34];

	if (!strchr(p1, '=') && !strchr(p2, '=') && *s3 != '=')
		return 0;                 /* not equate */
	if (!(equal = strchr(line, '='))) /* search for = */
		return 0;                 /* this isn't an equate */
	exp = strchr(line, ';');          /* check for comments */
	if (exp && exp < equal) return 0; /* there was ; before = */
	for (exp = equal + 1; isspace(*exp) && *exp; exp++)
		; /* point to expression */
	for (sym = equal - 1; isspace(*sym) && sym >= line; sym--)
		; /* find non-space */
	for (; !isspace(*sym) && sym >= line; sym--)
		; /* find space */
	sym++;    /* point to symbol */

	if (sym != line && !isspace(*line)) /* optional label on line */
		if (good_label(s1)) get_label(s1, 1);

	known = evaluate(exp, &l); /* evaluate expression */
	equ = TRUE;
	if (*sym == '*')
		if (sym[1] != '=' && !isspace(sym[1]))
			display_error(error = 'S');
		else if (known)
			loc_cntr = l;
		else
			display_error(error = 'U');
	else {
		if (isdigit(*sym)) {
			for (i = 0; isdigit(*sym); sym++)
				i = i * 10 + *sym - '0';
			makelocal(i, localsym);
			insert_symbol(localsym, l, 1, expdef, TRUE);
		} else {
			for (i = 0; i < 32; i++)
				if (isspace(sym[i]) || sym[i] == '=') {
					localsym[i] = 0;
					break;
				} else
					localsym[i] = toupper(sym[i]);
			insert_symbol(localsym, l, 1, expdef, FALSE);
		}
		ptr->value = l;
		ptr->known |= known;
		ptr->equate = TRUE;
	}
	data = 2;
	d[0] = l >> 8 & 255;
	d[1] = l & 255;
	return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
leaq 0xaae5(%rip), %rdi      # 0xda10
pushq $0x3d
popq %rsi
callq 0x10d0
testq %rax, %rax
jne 0x2f61
leaq 0xb051(%rip), %rdi      # 0xdf90
pushq $0x3d
popq %rsi
callq 0x10d0
testq %rax, %rax
jne 0x2f61
leaq 0xb15d(%rip), %rax      # 0xe0b0
movq (%rax), %rax
xorl %ebx, %ebx
cmpb $0x3d, (%rax)
jne 0x31cd
leaq 0xb158(%rip), %rdi      # 0xe0c0
pushq $0x3d
popq %rsi
callq 0x10d0
xorl %ebx, %ebx
testq %rax, %rax
je 0x31cd
movq %rax, %r12
leaq 0xb13b(%rip), %r15      # 0xe0c0
pushq $0x3b
popq %rsi
movq %r15, %rdi
callq 0x10d0
testq %rax, %rax
setne %cl
cmpq %r12, %rax
setb %al
testb %al, %cl
jne 0x31cd
callq 0x1240
movq %rax, %rbx
movq (%rax), %rax
movq %r12, %r14
movsbq 0x1(%r14), %rcx
incq %r14
testq %rcx, %rcx
je 0x2fcb
movzwl (%rax,%rcx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x2fb2
decq %r12
leaq -0x1(%r12), %rcx
cmpq %r15, %r12
jb 0x2fec
movsbq (%r12), %rdx
movzwl (%rax,%rdx,2), %edx
movq %rcx, %r12
andl $0x2000, %edx           # imm = 0x2000
jne 0x2fce
addq $0x4, %rcx
leaq -0x3(%rcx), %rdx
leaq -0x1(%rcx), %r12
cmpq %r15, %rdx
jb 0x3011
movsbq -0x3(%rcx), %rcx
movzwl (%rax,%rcx,2), %edx
movq %r12, %rcx
andl $0x2000, %edx           # imm = 0x2000
je 0x2ff0
leaq -0x1(%r12), %r13
cmpq 0x9fcb(%rip), %r13      # 0xcfe8
je 0x3048
movsbq (%r15), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x3048
leaq 0xaa67(%rip), %r15      # 0xda98
movq (%r15), %rdi
callq 0x74a1
testl %eax, %eax
je 0x3048
movq (%r15), %rdi
pushq $0x1
popq %rsi
callq 0x7550
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x479e
leaq 0xb277(%rip), %r14      # 0xe2d3
movb %al, (%r14)
leaq 0xb26c(%rip), %rcx      # 0xe2d2
movb $0x1, (%rcx)
movsbq -0x1(%r12), %rcx
cmpq $0x2a, %rcx
jne 0x309b
movsbq (%r12), %rcx
cmpq $0x3d, %rcx
je 0x30ed
movq (%rbx), %rdx
testb $0x20, 0x1(%rdx,%rcx,2)
jne 0x30ed
leaq 0xad6f(%rip), %rax      # 0xde00
movb $0x53, (%rax)
pushq $0x53
jmp 0x3159
movq (%rbx), %rbx
movzwl (%rbx,%rcx,2), %eax
btl $0xb, %eax
jb 0x3105
xorl %r15d, %r15d
cmpq $0x20, %r15
je 0x3167
movsbq (%r13), %r12
cmpq $0x3d, %r12
je 0x3161
movzwl (%rbx,%r12,2), %eax
andl $0x2000, %eax           # imm = 0x2000
jne 0x3161
callq 0x1030
movq (%rax), %rax
movb (%rax,%r12,4), %al
movb %al, 0x10(%rsp,%r15)
incq %r15
incq %r13
jmp 0x30ab
testb %al, %al
je 0x314d
movq 0x8(%rsp), %rax
leaq 0xa723(%rip), %rcx      # 0xd820
movq %rax, (%rcx)
jmp 0x31ad
xorl %edi, %edi
btl $0xb, %eax
jae 0x3127
movsbl %cl, %eax
imull $0xa, %edi, %ecx
leal (%rcx,%rax), %edi
addl $-0x30, %edi
movsbq (%r12), %rcx
movzwl (%rbx,%rcx,2), %eax
incq %r12
jmp 0x3107
leaq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0x80de
movq 0x8(%rsp), %rsi
leaq 0xaca8(%rip), %rax      # 0xdde8
movl (%rax), %ecx
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %r8d
jmp 0x3180
leaq 0xacac(%rip), %rax      # 0xde00
movb $0x55, (%rax)
pushq $0x55
popq %rdi
callq 0x1e1c
jmp 0x31ad
movb $0x0, 0x10(%rsp,%r15)
movq 0x8(%rsp), %rsi
leaq 0xac75(%rip), %rax      # 0xdde8
movl (%rax), %ecx
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
xorl %r8d, %r8d
callq 0x812d
movq 0x8(%rsp), %rax
leaq 0xaabf(%rip), %rcx      # 0xdc50
movq (%rcx), %rcx
movq %rax, 0x18(%rcx)
movzbl (%r14), %eax
andl $0x1, %eax
shll $0x8, %eax
orw 0x20(%rcx), %ax
orl $0x20, %eax
movw %ax, 0x20(%rcx)
pushq $0x1
popq %rbx
leaq 0xb11a(%rip), %rax      # 0xe2d1
movb $0x2, (%rax)
movzwl 0x8(%rsp), %eax
leaq 0xb00a(%rip), %rcx      # 0xe1d0
rolw $0x8, %ax
movw %ax, (%rcx)
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq