// File: /workspace/github_c_makefile_star2_O0/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
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 0x7644
movq -0x10(%rbp), %rax
movzwl 0x86(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x7644
movl $0xe, -0x20(%rbp)
movb $0x1, %al
cmpl $0x0, -0x18(%rbp)
movb %al, -0x25(%rbp)
je 0x766e
movl -0x20(%rbp), %ecx
andl $0x6, %ecx
movb $0x1, %al
cmpl $0x6, %ecx
movb %al, -0x25(%rbp)
je 0x766e
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 0x7af9
movq -0x30(%rbp), %rax
leaq 0x5b30(%rip), %rcx      # 0xd1c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x5eb4(%rip), %rdi      # 0xd55c
leaq 0x5eaf(%rip), %rsi      # 0xd55e
movl $0x2a1, %edx            # imm = 0x2A1
leaq 0x60b2(%rip), %rcx      # 0xd76d
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
xorl %ecx, %ecx
movzwl %ax, %esi
callq 0x73f0
movq -0x10(%rbp), %rdi
movl $0xc, %esi
callq 0x7470
jmp 0x7ac4
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
xorl %ecx, %ecx
movzwl %ax, %esi
callq 0x73f0
movq -0x10(%rbp), %rdi
movl $0xc, %esi
callq 0x7470
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 0x7a3e
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 0x77d2
movl $0x1, -0x4(%rbp)
jmp 0x7b59
jmp 0x7a6e
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
xorl %ecx, %ecx
movzwl %ax, %esi
callq 0x73f0
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rdi
movl $0xc, %esi
callq 0x7470
jmp 0x7a3e
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), %rdi
xorl %esi, %esi
callq 0x7470
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 0x7890
movl $0x1, -0x4(%rbp)
jmp 0x7b59
jmp 0x7a6e
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 0x78fe
movl $0x1, -0x4(%rbp)
jmp 0x7b59
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x12(%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
xorl %ecx, %ecx
movzwl %ax, %esi
callq 0x73f0
movq -0x10(%rbp), %rdi
movl $0xc, %esi
callq 0x7470
jmp 0x7ac4
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 0x79ce
movl $0x1, -0x4(%rbp)
jmp 0x7b59
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x12(%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 0x7a3c
movl $0x1, -0x4(%rbp)
jmp 0x7b59
jmp 0x7a6e
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 0x7a6c
movl $0x1, -0x4(%rbp)
jmp 0x7b59
jmp 0x7add
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x12(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movw 0x12(%rax), %ax
cmpl $0x0, -0x18(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %r8d
movl $0x9, %edx
xorl %ecx, %ecx
movzwl %ax, %esi
callq 0x73f0
movq -0x10(%rbp), %rdi
movl $0xc, %esi
callq 0x7470
movq -0x10(%rbp), %rdi
callq 0x75e0
cmpl $0x0, %eax
je 0x7adb
movl $0x1, -0x4(%rbp)
jmp 0x7b59
jmp 0x7add
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x12(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
cmpl $0x0, -0x18(%rbp)
je 0x7b52
movq -0x10(%rbp), %rax
movzwl 0x24(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7b52
movq -0x10(%rbp), %rax
movzwl 0x20(%rax), %eax
andl $0xff00, %eax           # imm = 0xFF00
movq -0x10(%rbp), %rcx
movzwl 0x20(%rcx), %ecx
sarl $0x8, %ecx
andl $0xff, %ecx
orl %ecx, %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, 0x12(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)