// File: /workspace/github_cpp_makefile_star2_O1/czmccrory[P]ManchesterBaby/assembler.cpp
// Function: Assembler::encodeInstructionValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
string Assembler::encodeInstructionValue(string mne, int value)
{
	//get opcode (make it a binary string)
	string opcode = getOpcode(mne);
	cout << "mne: " << mne << " -> opcode: " << opcode << endl;
	//get memory address of operand
	string operand = decToBinaryString(value, 6);
	cout << "operand: " << operand << endl;
	//initialises templine to be 32 0s
	string tempLine = "";
	for (int i = 0; i < 32; i++)
	{
		tempLine += "0";
	}
	// 6 for 64x32 store
	// 4 for 4 bit opcode (0-15)
	tempLine.replace(0, 6, operand);
	tempLine.replace(13, 4, opcode);
	tempLine.replace(31,1, "1");
	return tempLine;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x5ee4
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x5716
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x54f2
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x4ad7(%rip), %rdi      # 0x9fd0
leaq 0x1c6d(%rip), %rsi      # 0x716d
movl $0x5, %edx
callq 0x2230
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x4ab8(%rip), %rdi      # 0x9fd0
callq 0x2230
movq %rax, %r14
leaq 0x1c4c(%rip), %rsi      # 0x7173
movl $0xc, %edx
movq %rax, %rdi
callq 0x2230
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r14, %rdi
callq 0x2230
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq 0x8(%rsp), %rdi
movl %ebp, %esi
movl $0x6, %edx
callq 0x3414
movq 0x4a48(%rip), %rdi      # 0x9fd0
leaq 0x1bf1(%rip), %rsi      # 0x7180
movl $0x9, %edx
callq 0x2230
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x4a26(%rip), %rdi      # 0x9fd0
callq 0x2230
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq 0x10(%rbx), %r15
movq %r15, (%rbx)
leaq 0x1b19(%rip), %rdx      # 0x7100
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x6088
movl $0x20, %ebp
leaq 0x1a9e(%rip), %r14      # 0x709c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2370
decl %ebp
jne 0x55fe
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
movl $0x6, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2220
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %r8
movl $0xd, %esi
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2220
leaq 0x1a55(%rip), %rcx      # 0x709e
movl $0x1f, %esi
movl $0x1, %edx
movl $0x1, %r8d
movq %rbx, %rdi
callq 0x2220
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x567c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5697
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x56b9
jmp 0x56be
movq %rax, %r14
movq 0x48(%rsp), %rdi
jmp 0x56fd
jmp 0x56c3
movq %rax, %r14
jmp 0x56d9
movq %rax, %r14
jmp 0x56f4
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r15, %rdi
je 0x56d9
movq (%r15), %rsi
incq %rsi
callq 0x21f0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x56f4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x38(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x570e
movq (%r13), %rsi
incq %rsi
callq 0x21f0
movq %r14, %rdi
callq 0x2330