// File: /workspace/github_c_makefile_star2_O3/aap[P]pdp11/kd11a.c
// Function: fetch_src
static int
fetch_src(KD11A *cpu, int m, int b)
{
	int sm, sf;
	int ai;

	sf = m&7;
	sm = m>>3;
	if(sf == SP && USER) sf = USP;	// KT11-SP
	ai = 1 + (!b || (sf&6)==6 || sm&1);
	switch(sm){
	case 0:
		assert(0);	// we don't do that here
		break;
	case 1:
		// SRC00
		setBA(cpu, R[sf], sf, 0, !b);
		setMM(cpu, 014);
		goto SRC14;
	case 2:
		// SRC01
		setBA(cpu, R[sf], sf, 0, !b);
		setMM(cpu, 014);
		D = R[sf] + ai;
		goto SRC03;
	case 3:
		// SRC04
		setBA(cpu, R[sf], sf, 0, 1);
		setMM(cpu, 0);
		D = R[sf] + 2;
		R[sf] = D;
		if(dati(cpu)) return 1;
		goto SRC12;
	case 4:
		// SRC02
		D = setBA(cpu, R[sf]-ai, sf, 0, !b);
		setMM(cpu, 014);
		goto SRC03;
	case 5:
		// SRC05
		D = setBA(cpu, R[sf]-2, sf, 0, 1);
		setMM(cpu, 0);
		R[sf] = D;
		if(dati(cpu)) return 1;
		goto SRC12;
	case 6:
		// SRC06
		 setBA(cpu, R[PC], PC, 0, 1);	// actually still set from fetch
		setMM(cpu, 0);
		D = R[PC] + 2;
		R[PC] = D;
		if(dati(cpu)) return 1;
		// SRC07
		B = R[SOURCE] = UNIBUS_DATA;
		// SRC08
		setBA(cpu, R[sf]+B, sf, 0, !b);
		setMM(cpu, 014);
		goto SRC14;
	case 7:
		// SRC09
		 setBA(cpu, R[PC], PC, 0, 1);	// actually still set from fetch
		setMM(cpu, 0);
		D = R[PC] + 2;
		R[PC] = D;
		if(dati(cpu)) return 1;
		// SRC10
		B = R[SOURCE] = UNIBUS_DATA;
		// SRC11
		setBA(cpu, R[sf]+B, sf, 0, 1);
		setMM(cpu, 0);
		if(dati(cpu)) return 1;
		goto SRC12;
//

		SRC03:
		R[sf] = D;
		if(dati(cpu)) return 1;
		goto SRC15;

		SRC12:
		B = R[SOURCE] = UNIBUS_DATA;
		// SRC13
		setBA(cpu, R[SOURCE], SOURCE, 0, !b);
		setMM(cpu, 014);
		SRC14:
		if(dati(cpu)) return 1;
		SRC15:
		B = R[SOURCE] = UNIBUS_DATA;
	}
	if(b && BA&1){
		// SRC16
		D = B&0177400 | (B>>8)&0377;
		// SRC17
		B = R[SOURCE] = D;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movq %rdi, %rbx
movl %esi, %r15d
andl $0x7, %r15d
movl %esi, %ecx
shrl $0x3, %ecx
cmpl $0x6, %r15d
jne 0x5a67
movb 0x86(%rbx), %al
andb $0x2, %al
shrb %al
movzbl %al, %eax
leal 0x6(,%rax,8), %r15d
movl %r15d, %edi
notl %edi
xorl %eax, %eax
btl $0x3, %esi
movl $0x0, %edx
adcw $0x1, %dx
testb $0x6, %dil
movl $0x2, %esi
cmovel %esi, %edx
testl %ebp, %ebp
cmovel %esi, %edx
movl %ecx, %ecx
leaq 0x36c7(%rip), %rsi      # 0x915c
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
xorl %eax, %eax
testl %ebp, %ebp
sete %al
movl %r15d, %ecx
movzwl (%rbx,%rcx,2), %ecx
jmp 0x5be5
movl %r15d, %eax
movzwl (%rbx,%rax,2), %ecx
addl $-0x2, %ecx
movl 0x38(%rbx), %edi
movl %edi, %edx
andl $-0x61, %edx
orl $0x40, %edx
movl %edx, 0x38(%rbx)
movw %cx, 0x24(%rbx)
movw %cx, 0x22(%rbx)
xorl %edx, %edx
movl $0x0, %esi
testb $0x8, %dil
jne 0x5aef
movzwl 0x86(%rbx), %edx
movzwl 0x138(%rbx), %esi
andl $0x1, %esi
movw %dx, 0x84(%rbx)
movl %esi, 0x13c(%rbx)
jmp 0x5bb2
xorl %esi, %esi
testl %ebp, %ebp
sete %sil
movl %r15d, %eax
movzwl (%rbx,%rax,2), %ecx
subl %edx, %ecx
movl 0x38(%rbx), %edi
movl %edi, %edx
andl $-0x61, %edx
shll $0x6, %esi
orl %edx, %esi
movl %esi, 0x38(%rbx)
movw %cx, 0x24(%rbx)
movw %cx, 0x22(%rbx)
xorl %edx, %edx
movl $0x0, %esi
testb $0x8, %dil
jne 0x5b55
xorl %edx, %edx
cmpl $0x0, 0x140(%rbx)
setne %dl
movzwl 0x86(%rbx,%rdx,2), %edx
movzwl 0x138(%rbx), %esi
andl $0x1, %esi
movw %dx, 0x84(%rbx)
movl %esi, 0x13c(%rbx)
jmp 0x5c96
movl %r15d, %eax
movzwl (%rbx,%rax,2), %ecx
movl 0x38(%rbx), %edi
movl %edi, %edx
andl $-0x61, %edx
orl $0x40, %edx
movl %edx, 0x38(%rbx)
movw %cx, 0x24(%rbx)
xorl %edx, %edx
movl $0x0, %esi
testb $0x8, %dil
jne 0x5b9e
movzwl 0x86(%rbx), %edx
movzwl 0x138(%rbx), %esi
andl $0x1, %esi
movw %dx, 0x84(%rbx)
movl %esi, 0x13c(%rbx)
addl $0x2, %ecx
movw %cx, 0x22(%rbx)
movw %cx, (%rbx,%rax,2)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7188
movl $0x1, %r14d
testl %eax, %eax
jne 0x5cae
xorl %eax, %eax
testl %ebp, %ebp
sete %al
movq 0x28(%rbx), %rcx
movzwl 0xc(%rcx), %ecx
movw %cx, 0x12(%rbx)
movw %cx, 0x20(%rbx)
movl 0x38(%rbx), %edx
movl %edx, %esi
andl $-0x61, %esi
shll $0x6, %eax
orl %esi, %eax
movl %eax, 0x38(%rbx)
movw %cx, 0x24(%rbx)
xorl %eax, %eax
movl $0x0, %ecx
testb $0x8, %dl
jne 0x5c23
xorl %eax, %eax
cmpl $0x0, 0x140(%rbx)
setne %al
movzwl 0x86(%rbx,%rax,2), %eax
movzwl 0x138(%rbx), %ecx
andl $0x1, %ecx
movw %ax, 0x84(%rbx)
movl %ecx, 0x13c(%rbx)
jmp 0x5c9a
xorl %esi, %esi
testl %ebp, %ebp
sete %sil
movl %r15d, %eax
movzwl (%rbx,%rax,2), %ecx
movl 0x38(%rbx), %r8d
movl %r8d, %edi
andl $-0x61, %edi
shll $0x6, %esi
orl %edi, %esi
movl %esi, 0x38(%rbx)
movw %cx, 0x24(%rbx)
xorl %esi, %esi
movl $0x0, %edi
testb $0x8, %r8b
jne 0x5c83
xorl %esi, %esi
cmpl $0x0, 0x140(%rbx)
setne %sil
movzwl 0x86(%rbx,%rsi,2), %esi
movzwl 0x138(%rbx), %edi
andl $0x1, %edi
movw %si, 0x84(%rbx)
movl %edi, 0x13c(%rbx)
addl %edx, %ecx
movw %cx, 0x22(%rbx)
movw %cx, (%rbx,%rax,2)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7188
movl $0x1, %r14d
testl %eax, %eax
je 0x5cba
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %eax
movw %ax, 0x12(%rbx)
movw %ax, 0x20(%rbx)
testl %ebp, %ebp
je 0x5cae
testb $0x1, 0x24(%rbx)
je 0x5cae
movl %eax, %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
movzwl %ax, %eax
shrl $0x8, %eax
orl %ecx, %eax
movw %ax, 0x22(%rbx)
movw %ax, 0x12(%rbx)
movw %ax, 0x20(%rbx)
jmp 0x5cae
movzwl 0xe(%rbx), %eax
movl 0x38(%rbx), %esi
movl %esi, %ecx
andl $-0x61, %ecx
orl $0x40, %ecx
movl %ecx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
xorl %ecx, %ecx
movl $0x0, %edx
testb $0x8, %sil
jne 0x5d29
movzwl 0x86(%rbx), %ecx
movzwl 0x138(%rbx), %edx
andl $0x1, %edx
movw %cx, 0x84(%rbx)
movl %edx, 0x13c(%rbx)
addl $0x2, %eax
movw %ax, 0x22(%rbx)
movw %ax, 0xe(%rbx)
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7188
movl $0x1, %r14d
testl %eax, %eax
jne 0x5cae
xorl %eax, %eax
testl %ebp, %ebp
sete %al
movq 0x28(%rbx), %rcx
movzwl 0xc(%rcx), %ecx
movw %cx, 0x12(%rbx)
movw %cx, 0x20(%rbx)
movl %r15d, %edx
addw (%rbx,%rdx,2), %cx
movl 0x38(%rbx), %edx
movl %edx, %esi
andl $-0x61, %esi
shll $0x6, %eax
orl %esi, %eax
movl %eax, 0x38(%rbx)
movw %cx, 0x24(%rbx)
movl $0x0, %eax
testb $0x8, %dl
jne 0x5db8
xorl %eax, %eax
cmpl $0x0, 0x140(%rbx)
setne %al
movzwl 0x86(%rbx,%rax,2), %eax
movzwl 0x138(%rbx), %r12d
andl $0x1, %r12d
movw %ax, 0x84(%rbx)
movl %r12d, 0x13c(%rbx)
jmp 0x5c9a
movzwl 0xe(%rbx), %ecx
movl 0x38(%rbx), %esi
movl %esi, %edx
andl $-0x61, %edx
orl $0x40, %edx
movl %edx, 0x38(%rbx)
movw %cx, 0x24(%rbx)
movl $0x0, %edx
testb $0x8, %sil
jne 0x5dfd
movzwl 0x86(%rbx), %edx
movzwl 0x138(%rbx), %eax
andl $0x1, %eax
movw %dx, 0x84(%rbx)
movl %eax, 0x13c(%rbx)
addl $0x2, %ecx
movw %cx, 0x22(%rbx)
movw %cx, 0xe(%rbx)
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7188
movl $0x1, %r14d
testl %eax, %eax
jne 0x5cae
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %eax
movw %ax, 0x12(%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)
movl $0x0, %eax
testb $0x8, %cl
jne 0x5e76
movzwl 0x86(%rbx), %eax
movzwl 0x138(%rbx), %r12d
andl $0x1, %r12d
movw %ax, 0x84(%rbx)
movl %r12d, 0x13c(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7188
jmp 0x5bc6
leaq 0x3656(%rip), %rdi      # 0x94f0
leaq 0x3651(%rip), %rsi      # 0x94f2
leaq 0x3859(%rip), %rcx      # 0x9701
movl $0x2a1, %edx            # imm = 0x2A1
callq 0x20d0