// File: /workspace/github_cpp_makefile_star2_O1/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 $0x98, %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)
addq $0x2070, %r14           # imm = 0x2070
leaq -0x90(%rbp), %r13
leaq -0xb0(%rbp), %r15
leaq -0x68(%rbp), %rbx
movq %r14, -0xb8(%rbp)
movl $0x7, %edx
movq 0x78c5(%rip), %rdi      # 0x9fd0
leaq 0x4928(%rip), %rsi      # 0x703a
callq 0x21c0
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
movq $0x0, -0x88(%rbp)
movb $0x0, -0x80(%rbp)
movq 0x78a8(%rip), %r12      # 0x9fe0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %edx
movq %r12, %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 0x48bd(%rip), %rsi      # 0x7040
leaq 0x48b7(%rip), %rdx      # 0x7041
callq 0x5d80
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rcx
movq %r13, %rdi
xorl %edx, %edx
callq 0x2240
movl $0x0, %r12d
cmpq $-0x1, %rax
je 0x280d
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 0x5b02
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x27eb
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 0x27b3
cmpq -0x88(%rbp), %r12
movq -0xb8(%rbp), %r14
je 0x2856
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq $-0x1, %rcx
callq 0x21a0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5b02
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2856
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x286f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0xb0(%rbp), %rdi
cmpq %rdi, -0xa8(%rbp)
je 0x290a
leaq 0x47cb(%rip), %rsi      # 0x7055
callq 0x2070
testl %eax, %eax
je 0x2959
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movq -0x70(%rbp), %rcx
movq 0x2078(%rcx), %rdx
movq %r14, %rcx
testq %rdx, %rdx
je 0x28d2
movb (%rax), %sil
movq %r14, %rcx
xorl %edi, %edi
cmpb %sil, 0x20(%rdx)
setl %dil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x28ba
movq %r14, %rdx
cmpq %r14, %rcx
je 0x28e6
movb (%rax), %al
cmpb 0x20(%rcx), %al
cmovlq %r14, %rcx
movq %rcx, %rdx
cmpq %r14, %rdx
je 0x2954
movq 0x28(%rdx), %rax
movq 0x30(%rdx), %rdi
addq -0x70(%rbp), %rdi
testb $0x1, %al
je 0x2903
movq (%rdi), %rcx
movq -0x1(%rcx,%rax), %rax
movq %r15, %rsi
callq *%rax
jmp 0x2954
movl $0x12, %edx
movq 0x76ba(%rip), %rdi      # 0x9fd0
leaq 0x4725(%rip), %rsi      # 0x7042
callq 0x21c0
movq 0x76a7(%rip), %rcx      # 0x9fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq 0x7689(%rip), %rdi      # 0x9fd0
callq 0x2030
movq %rax, %rdi
callq 0x20e0
xorl %r14d, %r14d
jmp 0x29a6
movl $0xa, %edx
movq 0x766b(%rip), %rdi      # 0x9fd0
leaq 0x46eb(%rip), %rsi      # 0x7057
callq 0x21c0
movq 0x7658(%rip), %rcx      # 0x9fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq 0x763a(%rip), %rdi      # 0x9fd0
callq 0x2030
movb $0x1, %r14b
movq %rax, %rdi
callq 0x20e0
movq %r15, %rdi
callq 0x5a98
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x29ca
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2190
testb %r14b, %r14b
je 0x26ff
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29f2
jmp 0x29fc
jmp 0x29f7
jmp 0x29f2
movq %rax, %rbx
jmp 0x2a3d
movq %rax, %rbx
jmp 0x2a31
movq %rax, %rbx
jmp 0x2a18
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x2a18
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2190
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x2a31
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2190
leaq -0xb0(%rbp), %rdi
callq 0x5a98
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x2a59
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x2250
nop