// File: suzukiplan[P]M6502/test/./../m6502.hpp
// Function: M6502::adc(unsigned char)
inline void adc(unsigned char value)
    {
        if (CB.debugMessage) strcpy(DD.mne, "ADC");
        if (isSupportBCD() && getStatusD()) {
            int aH = ((R.a & 0b11110000) >> 4) % 10;
            int aL = (R.a & 0b00001111) % 10;
            int vH = ((value & 0b11110000) >> 4) % 10;
            int vL = (value & 0b00001111) % 10;
            aL += vL + (getStatusC() ? 1 : 0);
            int halfCarry = aL / 10 ? 1 : 0;
            aL %= 10;
            aH += vH + halfCarry;
            updateStatusC(aH / 10 ? true : false);
            aH %= 10;
            R.a = (aH << 4) + aL;
            updateStatusZ(R.a == 0);
        } else {
            add(value);
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, 0x10(%rax)
je 0x1f519
movq -0x28(%rbp), %rdi
addq $0x60, %rdi
addq $0x2, %rdi
leaq 0x3e22(%rip), %rsi      # 0x23336
callq 0x10c0
movq -0x28(%rbp), %rdi
callq 0x1df60
testb $0x1, %al
jne 0x1f52b
jmp 0x1f6ac
movq -0x28(%rbp), %rdi
callq 0x1f6c0
testb $0x1, %al
jne 0x1f53d
jmp 0x1f6ac
movq -0x28(%rbp), %rdi
movzbl 0x89a(%rdi), %eax
shrl $0x4, %eax
movl %eax, %ecx
imulq $0x1999999a, %rcx, %rcx # imm = 0x1999999A
shrq $0x20, %rcx
movl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
movl %eax, -0x10(%rbp)
movzbl 0x89a(%rdi), %eax
andl $0xf, %eax
movl %eax, %ecx
imulq $0x1999999a, %rcx, %rcx # imm = 0x1999999A
shrq $0x20, %rcx
movl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movzbl -0x9(%rbp), %eax
shrl $0x4, %eax
movl %eax, %ecx
imulq $0x1999999a, %rcx, %rcx # imm = 0x1999999A
shrq $0x20, %rcx
movl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
movl %eax, -0x18(%rbp)
movzbl -0x9(%rbp), %eax
andl $0xf, %eax
movl %eax, %ecx
imulq $0x1999999a, %rcx, %rcx # imm = 0x1999999A
shrq $0x20, %rcx
movl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
callq 0x1f6e0
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rdi
movzbl %al, %eax
addl %eax, %ecx
movl -0x14(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rax
imulq $0x66666667, %rax, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rax
addl %ecx, %eax
setne %al
movzbl %al, %eax
movl %eax, -0x20(%rbp)
movslq -0x14(%rbp), %rcx
movl %ecx, %eax
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rdx
addl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %ecx
movl -0x20(%rbp), %eax
addl %eax, %ecx
movl -0x10(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x10(%rbp)
movslq -0x10(%rbp), %rax
imulq $0x66666667, %rax, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rax
addl %ecx, %eax
setne %al
negb %al
movzbl %al, %esi
andl $0x1, %esi
xorl %edx, %edx
callq 0x1f700
movq -0x28(%rbp), %rdi
movl -0x10(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %edx, -0x10(%rbp)
movl -0x10(%rbp), %eax
shll $0x4, %eax
addl -0x14(%rbp), %eax
movb %al, 0x89a(%rdi)
movzbl 0x89a(%rdi), %eax
cmpl $0x0, %eax
sete %al
movzbl %al, %esi
andl $0x1, %esi
xorl %edx, %edx
callq 0x1e880
jmp 0x1f6b9
movq -0x28(%rbp), %rdi
movzbl -0x9(%rbp), %esi
callq 0x1f7e0
addq $0x30, %rsp
popq %rbp
retq
nop