// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/rk11.c
// Function: datox_rk11
static int
datox_rk11(Bus *bus, RK11 *rk, word mask)
{
	rk->bus = bus;
	if(bus->addr >= 0777400 && bus->addr < 0777420){
		switch(bus->addr&017){
		case 000:	// RKDS
		case 001:
		case 002:	// RKER
		case 003:
			break;	// read only

		case 004:	// RKCS
		case 005:
			SETMASK(rk->rkcs, bus->data, mask&0017577);
			break;
		case 006:	// RKWC
		case 007:
			SETMASK(rk->rkwc, bus->data, mask);
			break;
		case 010:	// RKBA
		case 011:
			SETMASK(rk->rkba, bus->data, mask);
			break;
		case 012:	// RKDA
		case 013:
			if(rk->rkcs & RDY){
				SETMASK(rk->rkda, bus->data, mask);
				rk->d = (rk->rkda>>13) & 7;
			}else if((rk->rkcs & GO)==0)
				rk->done = 1;
			break;
		case 014:	// RKMR
		case 015:
			// not implemented
			break;
		case 016:	// RKDB
		case 017:
			// read only
			break;
		default: assert(0);	/* can't happen */
		}
		return 0;
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %dx, %ax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x3ff00, 0x8(%rax)     # imm = 0x3FF00
jb 0x8815
movq -0x10(%rbp), %rax
cmpl $0x3ff10, 0x8(%rax)     # imm = 0x3FF10
jae 0x8815
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0xf, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0xf, %eax
ja 0x87ed
movq -0x28(%rbp), %rax
leaq 0x30ec(%rip), %rcx      # 0xb7b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x880c
movq -0x18(%rbp), %rax
movzwl 0xc(%rax), %eax
movzwl -0x1a(%rbp), %ecx
andl $0x1f7f, %ecx           # imm = 0x1F7F
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x10(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
movzwl -0x1a(%rbp), %edx
andl $0x1f7f, %edx           # imm = 0x1F7F
andl %edx, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0xc(%rax)
jmp 0x880c
movq -0x18(%rbp), %rax
movzwl 0xe(%rax), %eax
movzwl -0x1a(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x10(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
movzwl -0x1a(%rbp), %edx
andl %edx, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0xe(%rax)
jmp 0x880c
movq -0x18(%rbp), %rax
movzwl 0x10(%rax), %eax
movzwl -0x1a(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x10(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
movzwl -0x1a(%rbp), %edx
andl %edx, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x10(%rax)
jmp 0x880c
movq -0x18(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x87ca
movq -0x18(%rbp), %rax
movzwl 0x12(%rax), %eax
movzwl -0x1a(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x10(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
movzwl -0x1a(%rbp), %edx
andl %edx, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x12(%rax)
movq -0x18(%rbp), %rax
movzwl 0x12(%rax), %ecx
sarl $0xd, %ecx
andl $0x7, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x20(%rax)
jmp 0x87e7
movq -0x18(%rbp), %rax
movzwl 0xc(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x87e5
movq -0x18(%rbp), %rax
movl $0x1, 0x1c(%rax)
jmp 0x87e7
jmp 0x880c
jmp 0x880c
jmp 0x880c
leaq 0x2c17(%rip), %rdi      # 0xb40b
leaq 0x3019(%rip), %rsi      # 0xb814
movl $0x83, %edx
leaq 0x3031(%rip), %rcx      # 0xb838
callq 0x20d0
movl $0x0, -0x4(%rbp)
jmp 0x881c
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)