// File: /workspace/github_c_makefile_star2_O0/algodesigner[P]z80/z80.c
// Function: disasm
uint8_t disasm(z80 *cpu, uint16_t pos) {
    const char *txt;
    char jr;
    uint8_t ch = _RamRead(pos);
    uint8_t count = 1;
    uint8_t C;

    switch (ch) {
    case 0xCB: ++pos; txt = MnemonicsCB[_RamRead(pos++)]; count++; break;
    case 0xED: ++pos; txt = MnemonicsED[_RamRead(pos++)]; count++; break;
    case 0xDD: ++pos; C = 'X';
        if (_RamRead(pos) != 0xCB) {
            txt = MnemonicsXX[_RamRead(pos++)]; ++count;
        } else {
            ++pos; txt = MnemonicsXCB[_RamRead(pos++)]; count += 2;
        }
        break;
    case 0xFD: ++pos; C = 'Y';
        if (_RamRead(pos) != 0xCB) {
            txt = MnemonicsXX[_RamRead(pos++)]; ++count;
        } else {
            ++pos; txt = MnemonicsXCB[_RamRead(pos++)]; count += 2;
        }
        break;
    default:   txt = Mnemonics[_RamRead(pos++)];
    }
    while (*txt != 0) {
        switch (*txt) {
        case '*':
            txt += 2;
            ++count;
            _puthex8(_RamRead(pos++));
            break;
        case '^':
            txt += 2;
            ++count;
            _puthex8(_RamRead(pos++));
            break;
        case '#':
            txt += 2;
            count += 2;
            _puthex8(_RamRead(pos + 1));
            _puthex8(_RamRead(pos));
            break;
        case '@':
            txt += 2;
            ++count;
            jr = _RamRead(pos++);
            _puthex16(pos + jr);
            break;
        case '%':
            _putch(C);
            ++txt;
            break;
        default:
            _putch(*txt);
            ++txt;
        }
    }

    return(count);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %si, %ax
movq %rdi, -0x8(%rbp)
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rax
movzwl -0xa(%rbp), %ecx
movb 0x60(%rax,%rcx), %al
movb %al, -0x1a(%rbp)
movb $0x1, -0x1b(%rbp)
movzbl -0x1a(%rbp), %eax
movl %eax, -0x20(%rbp)
subl $0xcb, %eax
je 0x9865
jmp 0x9836
movl -0x20(%rbp), %eax
subl $0xdd, %eax
je 0x98ef
jmp 0x9846
movl -0x20(%rbp), %eax
subl $0xed, %eax
je 0x98aa
jmp 0x9852
movl -0x20(%rbp), %eax
subl $0xfd, %eax
je 0x9990
jmp 0x9a2e
movw -0xa(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movzbl 0x60(%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x147fb(%rip), %rax     # 0x1e090
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movb -0x1b(%rbp), %al
addb $0x1, %al
movb %al, -0x1b(%rbp)
jmp 0x9a5a
movw -0xa(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movzbl 0x60(%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x14fb6(%rip), %rax     # 0x1e890
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movb -0x1b(%rbp), %al
addb $0x1, %al
movb %al, -0x1b(%rbp)
jmp 0x9a5a
movw -0xa(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xa(%rbp)
movb $0x58, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movzwl -0xa(%rbp), %ecx
movzbl 0x60(%rax,%rcx), %eax
cmpl $0xcb, %eax
je 0x9949
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movzbl 0x60(%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x15759(%rip), %rax     # 0x1f090
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movb -0x1b(%rbp), %al
addb $0x1, %al
movb %al, -0x1b(%rbp)
jmp 0x998b
movw -0xa(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movzbl 0x60(%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x15f17(%rip), %rax     # 0x1f890
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movzbl -0x1b(%rbp), %eax
addl $0x2, %eax
movb %al, -0x1b(%rbp)
jmp 0x9a5a
movw -0xa(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xa(%rbp)
movb $0x59, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movzwl -0xa(%rbp), %ecx
movzbl 0x60(%rax,%rcx), %eax
cmpl $0xcb, %eax
je 0x99ea
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movzbl 0x60(%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x156b8(%rip), %rax     # 0x1f090
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movb -0x1b(%rbp), %al
addb $0x1, %al
movb %al, -0x1b(%rbp)
jmp 0x9a2c
movw -0xa(%rbp), %ax
addw $0x1, %ax
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movzbl 0x60(%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x15e76(%rip), %rax     # 0x1f890
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movzbl -0x1b(%rbp), %eax
addl $0x2, %eax
movb %al, -0x1b(%rbp)
jmp 0x9a5a
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movzbl 0x60(%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x1663e(%rip), %rax     # 0x20090
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
jmp 0x9a5c
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x9be1
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x24(%rbp)
subl $0x23, %eax
je 0x9b26
jmp 0x9a81
movl -0x24(%rbp), %eax
subl $0x25, %eax
je 0x9bad
jmp 0x9a8f
movl -0x24(%rbp), %eax
subl $0x2a, %eax
je 0x9ab4
jmp 0x9a99
movl -0x24(%rbp), %eax
subl $0x40, %eax
je 0x9b68
jmp 0x9aa7
movl -0x24(%rbp), %eax
subl $0x5e, %eax
je 0x9aed
jmp 0x9bc4
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
movb -0x1b(%rbp), %al
addb $0x1, %al
movb %al, -0x1b(%rbp)
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movzbl 0x60(%rax,%rcx), %edi
callq 0x9330
jmp 0x9bdc
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
movb -0x1b(%rbp), %al
addb $0x1, %al
movb %al, -0x1b(%rbp)
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movzbl 0x60(%rax,%rcx), %edi
callq 0x9330
jmp 0x9bdc
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
movzbl -0x1b(%rbp), %eax
addl $0x2, %eax
movb %al, -0x1b(%rbp)
movq -0x8(%rbp), %rax
movzwl -0xa(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl 0x60(%rax,%rcx), %edi
callq 0x9330
movq -0x8(%rbp), %rax
movzwl -0xa(%rbp), %ecx
movzbl 0x60(%rax,%rcx), %edi
callq 0x9330
jmp 0x9bdc
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
movb -0x1b(%rbp), %al
addb $0x1, %al
movb %al, -0x1b(%rbp)
movq -0x8(%rbp), %rax
movw -0xa(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0xa(%rbp)
movzwl %cx, %ecx
movb 0x60(%rax,%rcx), %al
movb %al, -0x19(%rbp)
movzwl -0xa(%rbp), %eax
movsbl -0x19(%rbp), %ecx
addl %ecx, %eax
movzwl %ax, %edi
callq 0x93b0
jmp 0x9bdc
movzbl -0x1c(%rbp), %edi
callq 0x92a0
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x9bdc
movq -0x18(%rbp), %rax
movzbl (%rax), %edi
callq 0x92a0
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x9a5c
movb -0x1b(%rbp), %al
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)