// File: /workspace/github_cpp_makefile_star2_O2/mdpkh[P]retro6k/src/main.cpp
// Function: DisplayArgs(char*, unsigned char, char*, char**)
inline void DisplayArgs(char* dest, unsigned char opc, char* args, char** end)
{
	const enum amode : char {
		AM_IMP,
		AM_ACC,
		AM_IMM,
		AM_REL,
		AM_ZP,
		AM_ZPX,
		AM_ZPY,
		AM_INDX,
		AM_INDY,
		AM_ABS,
		AM_ABSX,
		AM_ABSY,
		AM_IND
	} amodes[256] = {
		AM_IMP, AM_INDX, AM_IMP, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_ACC,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_ABS, AM_INDX, AM_IMP, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_ACC,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_IMP, AM_INDX, AM_IMP, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_ACC,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_IMP, AM_INDX, AM_IMP, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_ACC,  AM_IMM,  AM_IND,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_IMM, AM_INDX, AM_IMM, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_IMP,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPY, AM_ZPY, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSY, AM_ABSY,
		AM_IMM, AM_INDX, AM_IMM, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_IMP,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPY, AM_ZPY, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSY, AM_ABSY,
		AM_IMM, AM_INDX, AM_IMM, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_IMP,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_IMM, AM_INDX, AM_IMM, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_IMP,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX 
	};
	switch (amodes[opc])
	{
	case AM_IMP:
		*end = dest;
		break;
	case AM_ACC:
		*dest = 0x41;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_IMM:
		*dest = 0x23;
		*++dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x20;
		*end = dest + 1;
		break;
	case AM_REL:
	case AM_ZP:
		*dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ZPX:
		*dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x58;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ZPY:
		*dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x59;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_INDX:
		*dest = 0x28;
		*++dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x58;
		*++dest = 0x29;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_INDY:
		*dest = 0x28;
		*++dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x29;
		*++dest = 0x2c;
		*++dest = 0x59;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ABS:
		*dest = 0x24;
		DisplayHexByte(++dest, args[1]);
		dest += 2;
		DisplayHexByte(dest, args[0]);
		dest += 2;
		*dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ABSX:
		*dest = 0x24;
		DisplayHexByte(++dest, args[1]);
		dest += 2;
		DisplayHexByte(dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x58;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ABSY:
		*dest = 0x24;
		DisplayHexByte(++dest, args[1]);
		dest += 2;
		DisplayHexByte(dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x59;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_IND:
		*dest = 0x28;
		*++dest = 0x24;
		DisplayHexByte(++dest, args[1]);
		dest += 2;
		DisplayHexByte(dest, args[0]);
		dest += 2;
		*dest = 0x29;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	}
}

// Assembly:
movl %esi, %eax
leaq 0x4f3d(%rip), %rsi      # 0x12030
movzbl (%rax,%rsi), %eax
cmpq $0xc, %rax
ja 0xd353
leaq 0x7428(%rip), %rsi      # 0x14530
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
movb $0x24, (%rdi)
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
leaq 0x3f7d(%rip), %rsi      # 0x110a0
movb (%rdx,%rsi), %dl
movb %dl, 0x1(%rdi)
andl $0xf, %eax
movb (%rax,%rsi), %al
movb %al, 0x2(%rdi)
pushq $0x4
popq %rax
pushq $0x3
jmp 0xd348
movb $0x24, (%rdi)
movzbl 0x1(%rdx), %eax
movl %eax, %esi
shrl $0x4, %esi
leaq 0x3f51(%rip), %r8       # 0x110a0
movb (%rsi,%r8), %sil
movb %sil, 0x1(%rdi)
andl $0xf, %eax
movb (%rax,%r8), %al
movb %al, 0x2(%rdi)
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
movb (%rdx,%r8), %dl
movb %dl, 0x3(%rdi)
andl $0xf, %eax
movb (%rax,%r8), %al
movb %al, 0x4(%rdi)
movw $0x592c, 0x5(%rdi)      # imm = 0x592C
jmp 0xd343
movw $0x2428, (%rdi)         # imm = 0x2428
movzbl 0x1(%rdx), %eax
movl %eax, %esi
shrl $0x4, %esi
leaq 0x3f06(%rip), %r8       # 0x110a0
movb (%rsi,%r8), %sil
movb %sil, 0x2(%rdi)
andl $0xf, %eax
movb (%rax,%r8), %al
movb %al, 0x3(%rdi)
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
movb (%rdx,%r8), %dl
movb %dl, 0x4(%rdi)
andl $0xf, %eax
movb (%rax,%r8), %al
movb %al, 0x5(%rdi)
jmp 0xd270
movw $0x2423, (%rdi)         # imm = 0x2423
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
leaq 0x3ec2(%rip), %rsi      # 0x110a0
movb (%rdx,%rsi), %dl
movb %dl, 0x2(%rdi)
andl $0xf, %eax
movb (%rax,%rsi), %al
movb %al, 0x3(%rdi)
pushq $0x5
popq %rax
pushq $0x4
jmp 0xd348
movb $0x24, (%rdi)
movzbl 0x1(%rdx), %eax
movl %eax, %esi
shrl $0x4, %esi
leaq 0x3e96(%rip), %r8       # 0x110a0
movb (%rsi,%r8), %sil
movb %sil, 0x1(%rdi)
andl $0xf, %eax
movb (%rax,%r8), %al
movb %al, 0x2(%rdi)
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
movb (%rdx,%r8), %dl
movb %dl, 0x3(%rdi)
andl $0xf, %eax
movb (%rax,%r8), %al
movb %al, 0x4(%rdi)
jmp 0xd2c9
movb $0x41, (%rdi)
pushq $0x2
popq %rax
pushq $0x1
jmp 0xd348
movw $0x2428, (%rdi)         # imm = 0x2428
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
leaq 0x3e45(%rip), %rsi      # 0x110a0
movb (%rdx,%rsi), %dl
movb %dl, 0x2(%rdi)
andl $0xf, %eax
movb (%rax,%rsi), %al
movb %al, 0x3(%rdi)
movw $0x582c, 0x4(%rdi)      # imm = 0x582C
movb $0x29, 0x6(%rdi)
jmp 0xd343
movb $0x24, (%rdi)
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
leaq 0x3e15(%rip), %rsi      # 0x110a0
movb (%rdx,%rsi), %dl
movb %dl, 0x1(%rdi)
andl $0xf, %eax
movb (%rax,%rsi), %al
movb %al, 0x2(%rdi)
movw $0x582c, 0x3(%rdi)      # imm = 0x582C
jmp 0xd2c9
movb $0x24, (%rdi)
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
leaq 0x3dec(%rip), %rsi      # 0x110a0
movb (%rdx,%rsi), %dl
movb %dl, 0x1(%rdi)
andl $0xf, %eax
movb (%rax,%rsi), %al
movb %al, 0x2(%rdi)
movw $0x592c, 0x3(%rdi)      # imm = 0x592C
pushq $0x6
popq %rax
pushq $0x5
jmp 0xd348
movb $0x24, (%rdi)
movzbl 0x1(%rdx), %eax
movl %eax, %esi
shrl $0x4, %esi
leaq 0x3dbd(%rip), %r8       # 0x110a0
movb (%rsi,%r8), %sil
movb %sil, 0x1(%rdi)
andl $0xf, %eax
movb (%rax,%r8), %al
movb %al, 0x2(%rdi)
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
movb (%rdx,%r8), %dl
movb %dl, 0x3(%rdi)
andl $0xf, %eax
movb (%rax,%r8), %al
movb %al, 0x4(%rdi)
movw $0x582c, 0x5(%rdi)      # imm = 0x582C
jmp 0xd343
movw $0x2428, (%rdi)         # imm = 0x2428
movzbl (%rdx), %eax
movl %eax, %edx
shrl $0x4, %edx
leaq 0x3d76(%rip), %rsi      # 0x110a0
movb (%rdx,%rsi), %dl
movb %dl, 0x2(%rdi)
andl $0xf, %eax
movb (%rax,%rsi), %al
movb %al, 0x3(%rdi)
movw $0x2c29, 0x4(%rdi)      # imm = 0x2C29
movb $0x59, 0x6(%rdi)
pushq $0x8
popq %rax
pushq $0x7
popq %rdx
movb $0x20, (%rdi,%rdx)
addq %rax, %rdi
movq %rdi, (%rcx)
retq