// File: /workspace/github_cpp_makefile_star2_O3/Escapingbug[P]mos6502-emulator-debugging/mos6502.cpp
// Function: mos6502::DebugCommandline(unsigned short)
void mos6502::DebugCommandline(uint16_t src) {
  std::cout << "Break at " << std::hex << src << std::endl;

  while (1) {
	std::cout << "Debug> ";
	std::string cmd;
	std::getline(std::cin, cmd);

	std::vector<std::string> args;

	SplitString(cmd, args, " ");

	if (args.size() < 1) {
	  std::cout << "Incorrect commands" << std::endl;
	  continue;
	}

	if (args[0] == "c") {
	  std::cout << "continue.." << std::endl;
	  break;
	}

	auto iter = commands.find(args[0][0]);
	if (iter != commands.end()) {
	  auto func = iter->second;
	  (this->*func)(args);
	}
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq 0x7954(%rip), %r15      # 0x9fd0
leaq 0x49ad(%rip), %rsi      # 0x7030
movl $0x9, %edx
movq %r15, %rdi
callq 0x21c0
movq (%r15), %rax
movq -0x18(%rax), %rax
movl 0x18(%r15,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r15,%rax)
movl %ebx, %esi
movq %r15, %rdi
callq 0x20d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq %r14, -0x70(%rbp)
leaq 0x2070(%r14), %rax
movq %rax, -0x78(%rbp)
movq 0x78ef(%rip), %r14      # 0x9fe0
leaq -0x98(%rbp), %r13
leaq -0xb0(%rbp), %r15
leaq -0x68(%rbp), %rbx
movl $0x7, %edx
movq 0x78c1(%rip), %rdi      # 0x9fd0
leaq 0x4924(%rip), %rsi      # 0x703a
callq 0x21c0
leaq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
movq $0x0, -0x90(%rbp)
movb $0x0, -0x88(%rbp)
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2270
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movq $0x0, -0xa0(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
leaq 0x48bb(%rip), %rsi      # 0x7040
leaq 0x48b5(%rip), %rdx      # 0x7041
callq 0x5daa
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rcx
movq %r13, %rdi
xorl %edx, %edx
callq 0x2240
movl $0x0, %r12d
cmpq $-0x1, %rax
je 0x280f
movq %rax, %r14
xorl %r12d, %r12d
movq %r14, %rcx
subq %r12, %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x21a0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5b24
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x27ed
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rcx
movq %r14, %r12
addq %rcx, %r12
movq %r13, %rdi
movq %r12, %rdx
callq 0x2240
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x27b5
cmpq -0x90(%rbp), %r12
je 0x2851
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq $-0x1, %rcx
callq 0x21a0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5b24
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2851
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x286a
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0xb0(%rbp), %rdi
cmpq %rdi, -0xa8(%rbp)
je 0x28f4
leaq 0x47d4(%rip), %rsi      # 0x7055
callq 0x2070
testl %eax, %eax
je 0x2943
movq -0x70(%rbp), %rax
movq 0x2078(%rax), %rcx
testq %rcx, %rcx
je 0x293e
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movb (%rax), %dl
movq -0x78(%rbp), %rax
xorl %esi, %esi
cmpb %dl, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x28b2
cmpq -0x78(%rbp), %rax
je 0x293e
cmpb 0x20(%rax), %dl
jl 0x293e
movq 0x28(%rax), %rcx
movq 0x30(%rax), %rdi
addq -0x70(%rbp), %rdi
testb $0x1, %cl
je 0x28ed
movq (%rdi), %rax
movq -0x1(%rax,%rcx), %rcx
movq %r15, %rsi
callq *%rcx
jmp 0x293e
movl $0x12, %edx
movq 0x76d0(%rip), %rdi      # 0x9fd0
leaq 0x473b(%rip), %rsi      # 0x7042
callq 0x21c0
movq 0x76bd(%rip), %rcx      # 0x9fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq 0x769f(%rip), %rdi      # 0x9fd0
callq 0x2030
movq %rax, %rdi
callq 0x20e0
xorl %r14d, %r14d
jmp 0x2990
movl $0xa, %edx
movq 0x7681(%rip), %rdi      # 0x9fd0
leaq 0x4701(%rip), %rsi      # 0x7057
callq 0x21c0
movq 0x766e(%rip), %rcx      # 0x9fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq 0x7650(%rip), %rdi      # 0x9fd0
callq 0x2030
movb $0x1, %r14b
movq %rax, %rdi
callq 0x20e0
movq %r15, %rdi
callq 0x5ab6
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x29ba
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2190
testb %r14b, %r14b
movq 0x761c(%rip), %r14      # 0x9fe0
je 0x2703
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29e9
jmp 0x29ee
jmp 0x2a0c
jmp 0x29e9
movq %rax, %rbx
jmp 0x2a34
movq %rax, %rbx
jmp 0x2a28
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2a0f
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2190
jmp 0x2a0f
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x2a28
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2190
leaq -0xb0(%rbp), %rdi
callq 0x5ab6
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x2a56
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x2250