// File: /workspace/github_c_makefile_star2_O0/juliuswwj[P]emch55x/opcodes.c
// Function: orl_c_bitaddr
static int orl_c_bitaddr(struct em8051 *aCPU)
{
    int address = OPERAND1;
    int carry = CARRY;
    if (address > 0x7f)
    {
        int bit = address & 7;
        int bitmask = (1 << bit);
        int value;
        address &= 0xf8;        
        if (aCPU->sfrread)
            value = aCPU->sfrread(aCPU, address);
        else
            value = aCPU->mSFR[address - 0x80];

        value = (value & bitmask) ? 1 : carry;

        PSW = (PSW & ~PSWMASK_C) | (PSWMASK_C * value);
    }
    else
    {
        int bit = address & 7;
        int bitmask = (1 << bit);
        int value;
        address >>= 3;
        address += 0x20;
        value = (aCPU->mLowerData[address] & bitmask) ? 1 : carry;
        PSW = (PSW & ~PSWMASK_C) | (PSWMASK_C * value);
    }
    PC += 2;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x38(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movl 0x8(%rdx), %edx
subl $0x1, %edx
andl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movzbl 0x50(%rax), %eax
andl $0x80, %eax
sarl $0x7, %eax
movl %eax, -0x10(%rbp)
cmpl $0x7f, -0xc(%rbp)
jle 0xe470
movl -0xc(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x18(%rbp)
movl -0xc(%rbp), %eax
andl $0xf8, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1048(%rax)
je 0xe40c
movq -0x8(%rbp), %rax
movq 0x1048(%rax), %rax
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq *%rax
movl %eax, -0x1c(%rbp)
jmp 0xe427
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl -0xc(%rbp), %ecx
subl $0x80, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
andl -0x18(%rbp), %eax
cmpl $0x0, %eax
je 0xe43c
movl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xe442
movl -0x10(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movzbl 0x50(%rax), %eax
andl $0xffffff7f, %eax       # imm = 0xFFFFFF7F
movl -0x1c(%rbp), %ecx
shll $0x7, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movb %cl, 0x50(%rax)
jmp 0xe4ec
movl -0xc(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x24(%rbp)
movl -0xc(%rbp), %eax
sarl $0x3, %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
addl $0x20, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0xc(%rbp), %rcx
movzbl (%rax,%rcx), %eax
andl -0x24(%rbp), %eax
cmpl $0x0, %eax
je 0xe4ba
movl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xe4c0
movl -0x10(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movzbl 0x50(%rax), %eax
andl $0xffffff7f, %eax       # imm = 0xFFFFFF7F
movl -0x28(%rbp), %ecx
shll $0x7, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movb %cl, 0x50(%rax)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x2, %ecx
movl %ecx, 0x38(%rax)
movl $0x1, %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)