// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/kd11a.c
// Function: dato_cpu
static int
dato_cpu(KD11A *cpu, int b)
{
	word mask;
	mask = b ? (BA&1 ? 0177400 : 0377) : 0177777;

	/* internal registers */
	// actually just BA without KT11
	if(PBA > 0760000){
#ifdef KT11
		if((PBA&0777760) == 0772300){
			wrpdr(cpu, 8 + (PBA>>1 & 7), b);
			goto ok;
		}else if((PBA&0777760) == 0772340){
			wrpar(cpu, 8 + (PBA>>1 & 7), b);
			goto ok;
		}else if((PBA&0777760) == 0777600){
			wrpdr(cpu, PBA>>1 & 7, b);
			goto ok;
		}else if((PBA&0777760) == 0777640){
			wrpar(cpu, PBA>>1 & 7, b);
			goto ok;
		}else if((PBA&~1) == 0777572){
			SETMASK(cpu->sr0, UNIBUS_DATA, mask&0160401);
			goto ok;
		}else if((PBA&~3) == 0777574)
			goto ok;
		else
#endif
		if((PBA&0777400) == 0777400){
			switch(PBA&0377){
			case 0170: case 0171:
				/* can't write switches */
				goto ok;
#ifdef KJ11
			case 0374: case 0375:
				SETMASK(cpu->slr, UNIBUS_DATA, mask&0177400);
				goto ok;
#endif
			case 0376: case 0377:
				if(mask&0377)
					SETMASK(cpu->psw, UNIBUS_DATA, ~PSW_T);
				KT if(mask&0177400){
					cpu->prev = UNIBUS_DATA>>12 & 3;
					cpu->cur = UNIBUS_DATA>>14 & 3;
				}
				goto ok;
			}
		}
	}
	return 0;
ok:	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x9c35
movq -0x10(%rbp), %rax
movzwl 0x24(%rax), %edx
andl $0x1, %edx
movl $0xff, %eax
movl $0xff00, %ecx           # imm = 0xFF00
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0x9c3f
movl $0xffff, %eax           # imm = 0xFFFF
movl %eax, -0x1c(%rbp)
jmp 0x9c3f
movl -0x1c(%rbp), %eax
movw %ax, -0x16(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
cmpl $0x3e000, 0x8(%rax)     # imm = 0x3E000
jbe 0x9eeb
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %eax
andl $0x3fff0, %eax          # imm = 0x3FFF0
cmpl $0x3f4c0, %eax          # imm = 0x3F4C0
jne 0x9c96
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %esi
shrl %esi
andl $0x7, %esi
addl $0x8, %esi
movl -0x14(%rbp), %edx
callq 0x9f10
jmp 0x9ef4
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %eax
andl $0x3fff0, %eax          # imm = 0x3FFF0
cmpl $0x3f4e0, %eax          # imm = 0x3F4E0
jne 0x9cd1
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %esi
shrl %esi
andl $0x7, %esi
addl $0x8, %esi
movl -0x14(%rbp), %edx
callq 0x9fb0
jmp 0x9ef4
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %eax
andl $0x3fff0, %eax          # imm = 0x3FFF0
cmpl $0x3ff80, %eax          # imm = 0x3FF80
jne 0x9d09
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %esi
shrl %esi
andl $0x7, %esi
movl -0x14(%rbp), %edx
callq 0x9f10
jmp 0x9ef4
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %eax
andl $0x3fff0, %eax          # imm = 0x3FFF0
cmpl $0x3ffa0, %eax          # imm = 0x3FFA0
jne 0x9d41
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %esi
shrl %esi
andl $0x7, %esi
movl -0x14(%rbp), %edx
callq 0x9fb0
jmp 0x9ef4
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %eax
andl $-0x2, %eax
cmpl $0x3ff7a, %eax          # imm = 0x3FF7A
jne 0x9d9d
movq -0x10(%rbp), %rax
movzwl 0x138(%rax), %eax
movzwl -0x16(%rbp), %ecx
andl $0xe101, %ecx           # imm = 0xE101
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movzwl 0xc(%rcx), %ecx
movzwl -0x16(%rbp), %edx
andl $0xe101, %edx           # imm = 0xE101
andl %edx, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x138(%rax)
jmp 0x9ef4
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %eax
andl $-0x4, %eax
cmpl $0x3ff7c, %eax          # imm = 0x3FF7C
jne 0x9db7
jmp 0x9ef4
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rax), %eax
andl $0x3ff00, %eax          # imm = 0x3FF00
cmpl $0x3ff00, %eax          # imm = 0x3FF00
jne 0x9edd
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movzbl 0x8(%rax), %eax
movl %eax, -0x20(%rbp)
addl $-0x78, %eax
subl $0x2, %eax
jb 0x9e0c
jmp 0x9deb
movl -0x20(%rbp), %eax
addl $0xffffff04, %eax       # imm = 0xFFFFFF04
subl $0x2, %eax
jb 0x9e11
jmp 0x9dfa
movl -0x20(%rbp), %eax
addl $0xffffff02, %eax       # imm = 0xFFFFFF02
subl $0x2, %eax
jb 0x9e58
jmp 0x9edb
jmp 0x9ef4
movq -0x10(%rbp), %rax
movzwl 0x82(%rax), %eax
movzwl -0x16(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movzwl 0xc(%rcx), %ecx
movzwl -0x16(%rbp), %edx
andl $0xff00, %edx           # imm = 0xFF00
andl %edx, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x82(%rax)
jmp 0x9ef4
movzwl -0x16(%rbp), %eax
andl $0xff, %eax
cmpl $0x0, %eax
je 0x9e8b
movq -0x10(%rbp), %rax
movzbl 0x30(%rax), %eax
andl $0x10, %eax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movzwl 0xc(%rcx), %ecx
andl $-0x11, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x30(%rax)
movzwl -0x16(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
cmpl $0x0, %eax
je 0x9ed9
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movzwl 0xc(%rax), %eax
sarl $0xc, %eax
andl $0x3, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x88(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movzwl 0xc(%rax), %eax
sarl $0xe, %eax
andl $0x3, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x86(%rax)
jmp 0x9ef4
jmp 0x9edd
jmp 0x9edf
jmp 0x9ee1
jmp 0x9ee3
jmp 0x9ee5
jmp 0x9ee7
jmp 0x9ee9
jmp 0x9eeb
movl $0x0, -0x4(%rbp)
jmp 0x9efb
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)