// File: /workspace/github_c_makefile_star2_O1/aap[P]pdp11/kd11a.c
// Function: addr_dst
static int
addr_dst(KD11A *cpu, int m, int b)
{
	int dm, df;
	int ai;

	df = m&7;
	dm = m>>3;
	if(df == SP && USER) df = USP;	// KT11-SP
	ai = 1 + (!b || (df&6)==6 || dm&1);
	switch(dm){
	case 0:
		assert(0);	// we don't do that here
		break;
	case 1:
		// MOV00
		D = setBA(cpu, R[df], df, 1, !b);	// BUG: D missing in microcode flow
		goto MOV07;
	case 2:
		// MOV01
		setBA(cpu, R[df], df, 1, !b);
		D = R[df] + ai;
		goto MOV07;
	case 3:
		// MOV03
		setBA(cpu, R[df], df, 0, 1);
		setMM(cpu, 0);
		D = R[df] + 2;
		R[df] = D;
		if(dati(cpu)) return 1;
		goto MOV11;
	case 4:
		// MOV02
		D = setBA(cpu, R[df]-ai, df, 1, !b);
		MOV07:
		R[df] = D;
		break;
	case 5:
		// MOV04
		D = setBA(cpu, R[df]-2, df, 0, 1);
		R[df] = D;
		setMM(cpu, 0);
		if(dati(cpu)) return 1;
		goto MOV11;
	case 6:
		// MOV05/06
		 setBA(cpu, R[PC], PC, 0, 1);	// only if not still set from fetch
		setMM(cpu, 0);
		D = R[PC] + 2;
		R[PC] = D;
		if(dati(cpu)) return 1;
		// MOV08
		B = R[DEST] = UNIBUS_DATA;
		// MOV09
		setBA(cpu, R[df]+B, df, 1, !b);
		break;
	case 7:
		// MOV05/06
		 setBA(cpu, R[PC], PC, 0, 1);	// only if not still set from fetch
		setMM(cpu, 0);
		D = R[PC] + 2;
		R[PC] = D;
		if(dati(cpu)) return 1;
		// MOV08
		B = R[DEST] = UNIBUS_DATA;
		// MOV10
		setBA(cpu, R[df]+B, df, 0, 1);	// oda BUG???
		setMM(cpu, 0);
		if(dati(cpu)) return 1;
		MOV11:
		B = R[DEST] = UNIBUS_DATA;
		// MOV12
		setBA(cpu, R[DEST], DEST, 0, !b);
		break;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rdi, %rbx
movl %esi, %r15d
andl $0x7, %r15d
movl %esi, %ecx
shrl $0x3, %ecx
cmpl $0x6, %r15d
jne 0x5ed5
movb 0x86(%rbx), %al
andb $0x2, %al
shrb %al
movzbl %al, %eax
leal 0x6(,%rax,8), %r15d
movl %r15d, %edx
notl %edx
xorl %eax, %eax
btl $0x3, %esi
adcw $0x1, %ax
testb $0x6, %dl
movl $0x2, %edx
cmovel %edx, %eax
testl %ebp, %ebp
cmovel %edx, %eax
movl %ecx, %ecx
leaq 0x327f(%rip), %rdx      # 0x917c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl %r15d, %eax
movzwl (%rbx,%rax,2), %eax
jmp 0x5f64
movl %r15d, %eax
movzwl (%rbx,%rax,2), %ecx
addl $-0x2, %ecx
movl 0x38(%rbx), %edx
movl %edx, %esi
andl $-0x61, %esi
orl $0x40, %esi
movl %esi, 0x38(%rbx)
movw %cx, 0x24(%rbx)
movw %cx, 0x22(%rbx)
movw %cx, (%rbx,%rax,2)
testb $0x8, %dl
jne 0x60a7
movzwl 0x86(%rbx), %eax
movw %ax, 0x84(%rbx)
movzwl 0x138(%rbx), %eax
andl $0x1, %eax
jmp 0x60b2
movl %r15d, %ecx
movzwl (%rbx,%rcx,2), %ecx
subl %eax, %ecx
movl %ecx, %eax
cmpl $0x6, %r15d
jne 0x5f7a
movl 0x38(%rbx), %ecx
testb $0x8, %cl
jne 0x5f7a
orl $0x20, %ecx
movl %ecx, 0x38(%rbx)
jmp 0x5f7e
andb $-0x21, 0x38(%rbx)
xorl %ecx, %ecx
testl %ebp, %ebp
sete %cl
movl 0x38(%rbx), %edx
andl $-0x41, %edx
shll $0x6, %ecx
orl %edx, %ecx
movl %ecx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
jmp 0x6097
movl %r15d, %eax
movzwl (%rbx,%rax,2), %ecx
movl 0x38(%rbx), %edx
movl %edx, %esi
andl $-0x61, %esi
orl $0x40, %esi
movl %esi, 0x38(%rbx)
movw %cx, 0x24(%rbx)
testb $0x8, %dl
jne 0x60ba
movzwl 0x86(%rbx), %ecx
movw %cx, 0x84(%rbx)
movzwl 0x138(%rbx), %ecx
andl $0x1, %ecx
jmp 0x60c5
movl %r15d, %ecx
movzwl (%rbx,%rcx,2), %ecx
cmpl $0x6, %r15d
jne 0x6078
movl 0x38(%rbx), %edx
testb $0x8, %dl
jne 0x6078
orl $0x20, %edx
movl %edx, 0x38(%rbx)
jmp 0x607c
movzwl 0xe(%rbx), %eax
movl 0x38(%rbx), %ecx
movl %ecx, %edx
andl $-0x61, %edx
orl $0x40, %edx
movl %edx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
testb $0x8, %cl
jne 0x611c
movzwl 0x86(%rbx), %ecx
movw %cx, 0x84(%rbx)
movzwl 0x138(%rbx), %ecx
andl $0x1, %ecx
jmp 0x6127
movzwl 0xe(%rbx), %eax
movl 0x38(%rbx), %ecx
movl %ecx, %edx
andl $-0x61, %edx
orl $0x40, %edx
movl %edx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
testb $0x8, %cl
jne 0x617e
movzwl 0x86(%rbx), %ecx
movw %cx, 0x84(%rbx)
movzwl 0x138(%rbx), %ecx
andl $0x1, %ecx
jmp 0x6189
andb $-0x21, 0x38(%rbx)
xorl %edx, %edx
testl %ebp, %ebp
sete %dl
movl 0x38(%rbx), %esi
andl $-0x41, %esi
shll $0x6, %edx
orl %esi, %edx
movl %edx, 0x38(%rbx)
movw %cx, 0x24(%rbx)
addl %ecx, %eax
movw %ax, 0x22(%rbx)
movl %r15d, %ecx
movw %ax, (%rbx,%rcx,2)
jmp 0x6212
movw $0x0, 0x84(%rbx)
xorl %eax, %eax
movl %eax, 0x13c(%rbx)
jmp 0x60da
movw $0x0, 0x84(%rbx)
xorl %ecx, %ecx
movl %ecx, 0x13c(%rbx)
movzwl (%rbx,%rax,2), %ecx
addl $0x2, %ecx
movw %cx, 0x22(%rbx)
movw %cx, (%rbx,%rax,2)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x70ca
movl $0x1, %r14d
testl %eax, %eax
jne 0x6215
movl 0x38(%rbx), %eax
andl $-0x61, %eax
leal 0x40(%rax), %ecx
testl %ebp, %ebp
movq 0x28(%rbx), %rdx
movzwl 0xc(%rdx), %edx
movw %dx, 0x14(%rbx)
cmovnel %eax, %ecx
movw %dx, 0x20(%rbx)
movl %ecx, 0x38(%rbx)
movw %dx, 0x24(%rbx)
jmp 0x6212
movw $0x0, 0x84(%rbx)
xorl %ecx, %ecx
movl %ecx, 0x13c(%rbx)
addl $0x2, %eax
movw %ax, 0x22(%rbx)
movw %ax, 0xe(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x70ca
movl $0x1, %r14d
testl %eax, %eax
jne 0x6215
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %eax
movw %ax, 0x14(%rbx)
movw %ax, 0x20(%rbx)
movl %r15d, %ecx
addw (%rbx,%rcx,2), %ax
cmpl $0x6, %r15d
jne 0x61f6
movl 0x38(%rbx), %ecx
testb $0x8, %cl
jne 0x61f6
orl $0x20, %ecx
jmp 0x61fc
movw $0x0, 0x84(%rbx)
xorl %ecx, %ecx
movl %ecx, 0x13c(%rbx)
addl $0x2, %eax
movw %ax, 0x22(%rbx)
movw %ax, 0xe(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x70ca
movl $0x1, %r14d
testl %eax, %eax
jne 0x6215
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %eax
movw %ax, 0x14(%rbx)
movw %ax, 0x20(%rbx)
movl %r15d, %ecx
addw (%rbx,%rcx,2), %ax
movl 0x38(%rbx), %ecx
movl %ecx, %edx
andl $-0x61, %edx
orl $0x40, %edx
movl %edx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
testb $0x8, %cl
jne 0x6223
movzwl 0x86(%rbx), %eax
movw %ax, 0x84(%rbx)
movzwl 0x138(%rbx), %eax
andl $0x1, %eax
jmp 0x622e
movl 0x38(%rbx), %ecx
andl $-0x21, %ecx
xorl %edx, %edx
testl %ebp, %ebp
sete %dl
andl $-0x41, %ecx
shll $0x6, %edx
orl %ecx, %edx
movl %edx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movw $0x0, 0x84(%rbx)
xorl %eax, %eax
movl %eax, 0x13c(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x70ca
jmp 0x60ea
leaq 0x32a6(%rip), %rdi      # 0x94f0
leaq 0x32a1(%rip), %rsi      # 0x94f2
leaq 0x34ca(%rip), %rcx      # 0x9722
movl $0x207, %edx            # imm = 0x207
callq 0x20d0