// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/eae.c
// Function: datob_ke11
int
datob_ke11(Bus *bus, void *dev)
{
	KE11 *ke = dev;
	if(bus->addr >= 0777300 && bus->addr < 0777320){
//		printf("EAE DATOB %o %o\n", bus->addr, bus->data);
		switch(bus->addr){
		case KE_DIV:
			ke->x = sxt(bus->data);
			divide(ke);
			break;
		case KE_AC:
			ke->ac = sxt(bus->data);
			break;
		case KE_AC+1:
			SETMASK(ke->ac, bus->data, 0177400);
			break;
		case KE_MQ:
			ke->mq = sxt(bus->data);
			/* sign extend into AC */
			if(ke->mq&0100000)
				ke->ac = 0177777;
			else
				ke->ac = 0;
			break;
		case KE_MQ+1:
			SETMASK(ke->mq, bus->data, 0177400);
			/* sign extend into AC */
			if(ke->mq&0100000)
				ke->ac = 0177777;
			else
				ke->ac = 0;
			break;
		case KE_MULT:
			ke->x = sxt(bus->data);
			mult(ke);
			break;
		case KE_SCSR:
			break;
		case KE_NORM:
			norm(ke);
			break;
		case KE_LSH:
			ke->sc = bus->data & 077;
			lsh(ke);
			break;
		case KE_ASH:
			ke->sc = bus->data & 077;
			ash(ke);
			break;
		case KE_DIV+1:
		case KE_MULT+1:
		case KE_SCSR+1:
		case KE_NORM+1:
		case KE_LSH+1:
		case KE_ASH+1:
			break;

		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3fec0, 0x8(%rax)     # imm = 0x3FEC0
jb 0x6dd0
movq -0x10(%rbp), %rax
cmpl $0x3fed0, 0x8(%rax)     # imm = 0x3FED0
jae 0x6dd0
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
addl $0xfffc0140, %eax       # imm = 0xFFFC0140
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0xf, %eax
ja 0x6da8
movq -0x28(%rbp), %rax
leaq 0x48e4(%rip), %rcx      # 0xb504
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movw 0xc(%rax), %ax
movzbl %al, %edi
callq 0x2590
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x20(%rbp), %rdi
callq 0x6460
jmp 0x6dc7
movq -0x10(%rbp), %rax
movw 0xc(%rax), %ax
movzbl %al, %edi
callq 0x2590
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
jmp 0x6dc7
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
andl $0xffff00ff, %eax       # imm = 0xFFFF00FF
movq -0x10(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
orl %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
jmp 0x6dc7
movq -0x10(%rbp), %rax
movw 0xc(%rax), %ax
movzbl %al, %edi
callq 0x2590
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x20(%rbp), %rax
movzwl 0x2(%rax), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0x6cd4
movq -0x20(%rbp), %rax
movw $0xffff, (%rax)         # imm = 0xFFFF
jmp 0x6cdd
movq -0x20(%rbp), %rax
movw $0x0, (%rax)
jmp 0x6dc7
movq -0x20(%rbp), %rax
movzwl 0x2(%rax), %eax
andl $0xffff00ff, %eax       # imm = 0xFFFF00FF
movq -0x10(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
orl %ecx, %eax
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x20(%rbp), %rax
movzwl 0x2(%rax), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0x6d27
movq -0x20(%rbp), %rax
movw $0xffff, (%rax)         # imm = 0xFFFF
jmp 0x6d30
movq -0x20(%rbp), %rax
movw $0x0, (%rax)
jmp 0x6dc7
movq -0x10(%rbp), %rax
movw 0xc(%rax), %ax
movzbl %al, %edi
callq 0x2590
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x20(%rbp), %rdi
callq 0x66e0
jmp 0x6dc7
jmp 0x6dc7
movq -0x20(%rbp), %rdi
callq 0x67d0
jmp 0x6dc7
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x3f, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x6(%rax)
movq -0x20(%rbp), %rdi
callq 0x68c0
jmp 0x6dc7
movq -0x10(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x3f, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x6(%rax)
movq -0x20(%rbp), %rdi
callq 0x6a30
jmp 0x6dc7
jmp 0x6dc7
leaq 0x465c(%rip), %rdi      # 0xb40b
leaq 0x47ca(%rip), %rsi      # 0xb580
movl $0x16b, %edx            # imm = 0x16B
leaq 0x47e1(%rip), %rcx      # 0xb5a3
callq 0x20d0
movl $0x0, -0x4(%rbp)
jmp 0x6dd7
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq