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

	df = m&7;
	dm = m>>3;
	if(df == SP && USER) df = USP;	// KT11-SP
	switch(dm){
	case 0:
		assert(0);	// we don't do that here
		break;
	case 1:
		// JMP00
		D = R[df];
		JMP04:
		B = R[TEMP] = D;
		break;
	case 2:
		// JMP01
		D = R[df] + 2;
		R[df] = D;
		// JMP02
		D = R[df] - 2;
		goto JMP04;
	case 3:
		// JMP05
		setBA(cpu, R[df], df, 0, 1);
		setMM(cpu, 0);
		D = R[df] + 2;
		R[df] = D;
		if(dati(cpu)) return 1;
		goto JMP11;
	case 4:
		// JMP03
		D = R[df] - 2;
		R[df] = D;
		goto JMP04;
	case 5:
		// JMP06
		D = setBA(cpu, R[df]-2, df, 0, 1);
		setMM(cpu, 0);
		R[df] = D;
		if(dati(cpu)) return 1;
		goto JMP11;
	case 6:
		// JMP08
		 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;
		// JMP14
		B = R[TEMP] = UNIBUS_DATA;
		// JMP15
		D = R[df] + B;
		goto JMP04;
	case 7:
		// JMP07
		 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;
		// JMP09
		B = R[TEMP] = UNIBUS_DATA;
		// JMP10
		D = setBA(cpu, R[df]+B, df, 0, 1);
		setMM(cpu, 0);
		if(dati(cpu)) return 1;
		JMP11:
		B = R[TEMP] = UNIBUS_DATA;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl %esi, %r14d
andl $0x7, %r14d
shrl $0x3, %esi
cmpl $0x6, %r14d
jne 0x63bf
movb 0x86(%rbx), %al
andb $0x2, %al
shrb %al
movzbl %al, %eax
leal 0x6(,%rax,8), %r14d
movl %esi, %eax
leaq 0x1e04(%rip), %rcx      # 0x81cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %r14d, %eax
movzwl (%rbx,%rax,2), %eax
jmp 0x6563
movl %r14d, %r14d
movzwl (%rbx,%r14,2), %eax
addl $-0x2, %eax
movl 0x38(%rbx), %ecx
andl $-0x61, %ecx
orl $0x40, %ecx
movl %ecx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
movw %ax, 0x22(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x59d2
movzwl 0x22(%rbx), %eax
movw %ax, (%rbx,%r14,2)
jmp 0x645b
movl %r14d, %ecx
movzwl (%rbx,%rcx,2), %eax
addl $-0x2, %eax
movw %ax, 0x22(%rbx)
movw %ax, (%rbx,%rcx,2)
jmp 0x6567
movl %r14d, %r14d
movzwl (%rbx,%r14,2), %eax
movl 0x38(%rbx), %ecx
andl $-0x61, %ecx
orl $0x40, %ecx
movl %ecx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x59d2
movzwl (%rbx,%r14,2), %eax
addl $0x2, %eax
movw %ax, 0x22(%rbx)
movw %ax, (%rbx,%r14,2)
movq %rbx, %rdi
callq 0x5a53
testl %eax, %eax
jne 0x64c6
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %eax
jmp 0x6567
movl %r14d, %ecx
movzwl (%rbx,%rcx,2), %eax
movl %eax, %edx
addl $0x2, %edx
movw %dx, (%rbx,%rcx,2)
jmp 0x6563
movzwl 0xe(%rbx), %eax
movl 0x38(%rbx), %ecx
andl $-0x61, %ecx
orl $0x40, %ecx
movl %ecx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x59d2
movzwl 0xe(%rbx), %eax
addl $0x2, %eax
movw %ax, 0x22(%rbx)
movw %ax, 0xe(%rbx)
movq %rbx, %rdi
callq 0x5a53
testl %eax, %eax
je 0x6550
pushq $0x1
popq %rbp
jmp 0x6571
movzwl 0xe(%rbx), %eax
movl 0x38(%rbx), %ecx
andl $-0x61, %ecx
orl $0x40, %ecx
movl %ecx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x59d2
movzwl 0xe(%rbx), %eax
addl $0x2, %eax
movw %ax, 0x22(%rbx)
movw %ax, 0xe(%rbx)
movq %rbx, %rdi
callq 0x5a53
pushq $0x1
popq %rbp
testl %eax, %eax
jne 0x6571
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %eax
movw %ax, 0x10(%rbx)
movw %ax, 0x20(%rbx)
movl %r14d, %ecx
addw (%rbx,%rcx,2), %ax
movl 0x38(%rbx), %ecx
andl $-0x61, %ecx
orl $0x40, %ecx
movl %ecx, 0x38(%rbx)
movw %ax, 0x24(%rbx)
movw %ax, 0x22(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x59d2
movq %rbx, %rdi
callq 0x5a53
testl %eax, %eax
jne 0x6571
jmp 0x6467
movq 0x28(%rbx), %rax
movzwl 0xc(%rax), %eax
movw %ax, 0x10(%rbx)
movl %r14d, %ecx
addw (%rbx,%rcx,2), %ax
movw %ax, 0x22(%rbx)
movw %ax, 0x10(%rbx)
movw %ax, 0x20(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1fa5(%rip), %rdi      # 0x8524
leaq 0x1fa0(%rip), %rsi      # 0x8526
leaq 0x2230(%rip), %rcx      # 0x87bd
movl $0x253, %edx            # imm = 0x253
callq 0x20d0