// File: /workspace/github_cpp_makefile_star2_O2/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 $0xa8, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq 0x6964(%rip), %rdi      # 0x8fd0
leaq 0x39bd(%rip), %rsi      # 0x6030
callq 0x2190
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x18(%rax,%rcx)
movq %rax, %rdi
movl %ebx, %esi
callq 0x2270
movq %rax, %rdi
callq 0x20d0
leaq 0x2068(%r14), %rax
movq %rax, -0x68(%rbp)
movq %r14, -0x58(%rbp)
leaq 0x2070(%r14), %rax
movq %rax, -0x60(%rbp)
leaq -0x88(%rbp), %rbx
leaq -0xa8(%rbp), %r13
leaq -0xc8(%rbp), %r15
movq 0x68fb(%rip), %rdi      # 0x8fd0
leaq 0x395e(%rip), %rsi      # 0x603a
callq 0x2190
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
andq $0x0, -0x80(%rbp)
movb $0x0, -0x78(%rbp)
movq 0x68e4(%rip), %rdi      # 0x8fe0
movq %rbx, %rsi
callq 0x2050
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
movq %r13, %rdi
leaq 0x3926(%rip), %rsi      # 0x6040
leaq -0x29(%rbp), %rdx
callq 0x544e
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x22a0
cmpq $-0x1, %rax
je 0x2771
movq %rax, %r14
movq %rax, %rcx
subq %r12, %rcx
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x21c0
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x5550
movq %r15, %rdi
callq 0x20c0
addq -0xa0(%rbp), %r14
movq %r14, %r12
jmp 0x2726
cmpq -0x80(%rbp), %r12
je 0x279c
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
pushq $-0x1
popq %rcx
callq 0x21c0
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x5550
movq %r15, %rdi
callq 0x20c0
movq %r13, %rdi
callq 0x20c0
movq -0x50(%rbp), %rdi
cmpq %rdi, -0x48(%rbp)
je 0x27f5
leaq 0x38a0(%rip), %rsi      # 0x6055
callq 0x5489
testb %al, %al
jne 0x2826
movq -0x50(%rbp), %rax
movq (%rax), %rsi
movq -0x68(%rbp), %rdi
callq 0x5842
cmpq -0x60(%rbp), %rax
je 0x2810
movq 0x28(%rax), %rcx
movq 0x30(%rax), %rdi
addq -0x58(%rbp), %rdi
testb $0x1, %cl
je 0x27ed
movq (%rdi), %rax
movq -0x1(%rax,%rcx), %rcx
leaq -0x50(%rbp), %rsi
callq *%rcx
jmp 0x2810
movq 0x67d4(%rip), %rdi      # 0x8fd0
leaq 0x383f(%rip), %rsi      # 0x6042
callq 0x2190
movq %rax, %rdi
callq 0x20d0
leaq -0x50(%rbp), %rdi
callq 0x549a
movq %rbx, %rdi
callq 0x20c0
jmp 0x26ce
movq 0x67a3(%rip), %rdi      # 0x8fd0
leaq 0x3823(%rip), %rsi      # 0x6057
callq 0x2190
movq %rax, %rdi
callq 0x20d0
leaq -0x50(%rbp), %rdi
callq 0x549a
leaq -0x88(%rbp), %rdi
callq 0x20c0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2874
jmp 0x2874
jmp 0x2883
jmp 0x287e
jmp 0x2874
jmp 0x2874
movq %rax, %rbx
jmp 0x289e
movq %rax, %rbx
jmp 0x28a7
movq %rax, %rbx
jmp 0x2892
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x20c0
leaq -0xa8(%rbp), %rdi
callq 0x20c0
leaq -0x50(%rbp), %rdi
callq 0x549a
leaq -0x88(%rbp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2280
nop