// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/ka11.c
// Function: addrop
static int
addrop(KA11 *cpu, int m, int b)
{
	int r;
	int ai;
	r = m&7;
	m >>= 3;
	ai = 1 + (!b || (r&6)==6 || m&1);
	if(m == 0){
//		assert(0);
		return 0;
	}
	switch(m&6){
	case 0:		// REG
		cpu->b = cpu->ba = cpu->r[r];
		return 0;	// this already is mode 1
	case 2:		// INC
		cpu->ba = cpu->r[r];
		cpu->b = cpu->r[r] = cpu->r[r] + ai;
		break;
	case 4:		// DEC
		cpu->b = cpu->ba = cpu->r[r]-ai;
		if(r == 6 && (cpu->ba&~0377) == 0) cpu->traps |= TRAP_STACK;
		cpu->r[r] = cpu->ba;
		break;
	case 6:		// INDEX
		cpu->ba = cpu->r[7];
		cpu->r[7] += 2;
		if(dati(cpu, 0)) return 1;
		cpu->b = cpu->ba = cpu->bus->data + cpu->r[r];
		break;
	}
	if(m&1){
		if(dati(cpu, 0)) return 1;
		cpu->b = cpu->ba = cpu->bus->data;
	}
	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, -0x1c(%rbp)
movl -0x14(%rbp), %eax
sarl $0x3, %eax
movl %eax, -0x14(%rbp)
movb $0x1, %al
cmpl $0x0, -0x18(%rbp)
movb %al, -0x21(%rbp)
je 0x5ede
movl -0x1c(%rbp), %ecx
andl $0x6, %ecx
movb $0x1, %al
cmpl $0x6, %ecx
movb %al, -0x21(%rbp)
je 0x5ede
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x5efe
movl $0x0, -0x4(%rbp)
jmp 0x6097
movl -0x14(%rbp), %eax
andl $0x6, %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x6, %eax
ja 0x6050
movq -0x30(%rbp), %rax
leaq 0x5252(%rip), %rcx      # 0xb170
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movw (%rax,%rcx,2), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x6097
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movw (%rax,%rcx,2), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
addl -0x20(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rdx
movw %cx, (%rax,%rdx,2)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
jmp 0x6050
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
subl -0x20(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
cmpl $0x6, -0x1c(%rbp)
jne 0x5fd5
movq -0x10(%rbp), %rax
movzwl 0x22(%rax), %eax
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x0, %eax
jne 0x5fd5
movq -0x10(%rbp), %rax
movl 0x34(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x34(%rax)
movq -0x10(%rbp), %rax
movw 0x22(%rax), %dx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
jmp 0x6050
movq -0x10(%rbp), %rax
movw 0xe(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movzwl 0xe(%rax), %ecx
addl $0x2, %ecx
movw %cx, 0xe(%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x3010
cmpl $0x0, %eax
je 0x6023
movl $0x1, -0x4(%rbp)
jmp 0x6097
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movzwl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
movzwl (%rcx,%rdx,2), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x6090
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x3010
cmpl $0x0, %eax
je 0x6074
movl $0x1, -0x4(%rbp)
jmp 0x6097
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movw 0xc(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq