// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl -0x14(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x20(%rbp)
movl -0x14(%rbp), %eax
sarl $0x3, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x6, -0x20(%rbp)
jne 0x7bb4
movq -0x10(%rbp), %rax
movzwl 0x86(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x7bb4
movl $0xe, -0x20(%rbp)
movb $0x1, %al
cmpl $0x0, -0x18(%rbp)
movb %al, -0x25(%rbp)
je 0x7bde
movl -0x20(%rbp), %ecx
andl $0x6, %ecx
movb $0x1, %al
cmpl $0x6, %ecx
movb %al, -0x25(%rbp)
je 0x7bde
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
movzbl %al, %eax
andl $0x1, %eax
incl %eax
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %eax
movq %rax, -0x30(%rbp)
subq $0x7, %rax
ja 0x7fe6
movq -0x30(%rbp), %rax
leaq 0x55e0(%rip), %rcx      # 0xd1e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x5944(%rip), %rdi      # 0xd55c
leaq 0x593f(%rip), %rsi      # 0xd55e
movl $0x207, %edx            # imm = 0x207
leaq 0x5b63(%rip), %rcx      # 0xd78e
callq 0x20d0
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movl -0x20(%rbp), %edx
cmpl $0x0, -0x18(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %r8d
movl $0x1, %ecx
movzwl %ax, %esi
callq 0x73f0
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
jmp 0x7d7b
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movl -0x20(%rbp), %edx
cmpl $0x0, -0x18(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %r8d
movl $0x1, %ecx
movzwl %ax, %esi
callq 0x73f0
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
addl -0x24(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
jmp 0x7d7b
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movl -0x20(%rbp), %edx
xorl %ecx, %ecx
movl $0x1, %r8d
movzwl %ax, %esi
callq 0x73f0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x7470
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
addl $0x2, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movw 0x22(%rax), %dx
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movq -0x10(%rbp), %rdi
callq 0x75e0
cmpl $0x0, %eax
je 0x7d37
movl $0x1, -0x4(%rbp)
jmp 0x7fed
jmp 0x7f9e
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
subl -0x24(%rbp), %eax
movl -0x20(%rbp), %edx
cmpl $0x0, -0x18(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %r8d
movl $0x1, %ecx
movzwl %ax, %esi
callq 0x73f0
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movw 0x22(%rax), %dx
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x7fe6
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
subl $0x2, %eax
movl -0x20(%rbp), %edx
xorl %ecx, %ecx
movl $0x1, %r8d
movzwl %ax, %esi
callq 0x73f0
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movw 0x22(%rax), %dx
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x7470
movq -0x10(%rbp), %rdi
callq 0x75e0
cmpl $0x0, %eax
je 0x7dfe
movl $0x1, -0x4(%rbp)
jmp 0x7fed
jmp 0x7f9e
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl $0x7, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
movzwl 0xe(%rax), %esi
callq 0x73f0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x7470
movq -0x10(%rbp), %rax
movzwl 0xe(%rax), %eax
addl $0x2, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movw 0x22(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xe(%rax)
movq -0x10(%rbp), %rdi
callq 0x75e0
cmpl $0x0, %eax
je 0x7e6c
movl $0x1, -0x4(%rbp)
jmp 0x7fed
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x14(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movq -0x10(%rbp), %rcx
movzwl 0x20(%rcx), %ecx
addl %ecx, %eax
movl -0x20(%rbp), %edx
cmpl $0x0, -0x18(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %r8d
movl $0x1, %ecx
movzwl %ax, %esi
callq 0x73f0
jmp 0x7fe6
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl $0x7, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
movzwl 0xe(%rax), %esi
callq 0x73f0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x7470
movq -0x10(%rbp), %rax
movzwl 0xe(%rax), %eax
addl $0x2, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movw 0x22(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xe(%rax)
movq -0x10(%rbp), %rdi
callq 0x75e0
cmpl $0x0, %eax
je 0x7f31
movl $0x1, -0x4(%rbp)
jmp 0x7fed
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x14(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movq -0x10(%rbp), %rcx
movzwl 0x20(%rcx), %ecx
addl %ecx, %eax
movl -0x20(%rbp), %edx
xorl %ecx, %ecx
movl $0x1, %r8d
movzwl %ax, %esi
callq 0x73f0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x7470
movq -0x10(%rbp), %rdi
callq 0x75e0
cmpl $0x0, %eax
je 0x7f9c
movl $0x1, -0x4(%rbp)
jmp 0x7fed
jmp 0x7f9e
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x14(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movw 0x14(%rax), %ax
cmpl $0x0, -0x18(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %r8d
movl $0xa, %edx
xorl %ecx, %ecx
movzwl %ax, %esi
callq 0x73f0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)