// File: sthapliyal37[P]Microprocessor_8085_Updated/Logical.cpp
// Function: CMP(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&)
void CMP(string instruction,string registers[],bool flag[],map<string,string>& memory)
{
	int l1=instruction.length();
	if(l1==1)
	{
		if(instruction=="M")
		{
		    string address=registers[5]+registers[6];
			if(registers[0]<memory[address])
			{
			    flag[0]=true;
			}
			else if(registers[0]==memory[address])
			{
				flag[6]=true;
			}
			else
			{
				flag[0]=false;
				flag[6]=false;
			}
		}
		else if(validityRegisters(instruction))
		{
			int index=registerNumber(instruction);
    		if(registers[0]<registers[index])
    		{
				flag[0]=true;
			}
			else if(registers[0]==registers[index])
			{
				flag[6]=true;
			}
			else
			{
			    flag[0]=false;
				flag[6]=false;
			}
		}
		else{
			
			cout<<"Error: "<<instruction<<"\nInvalid registers\nThe program will quit\n";
			exit(0);
		}
	}


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xa8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
callq 0x33b0
movl %eax, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
jne 0xfec3
movq -0xa8(%rbp), %rdi
leaq 0x539e(%rip), %rsi      # 0x15010
callq 0x50a0
testb $0x1, %al
jne 0xfc80
jmp 0xfd68
movq -0x10(%rbp), %rdx
movq %rdx, %rsi
addq $0xa0, %rsi
addq $0xc0, %rdx
leaq -0x48(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0xe6b0
movq -0xc0(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x20(%rbp), %rdi
callq 0xe790
movq %rax, -0xb0(%rbp)
jmp 0xfcc9
movq -0xb0(%rbp), %rsi
movq -0xb8(%rbp), %rdi
callq 0xeee0
testb $0x1, %al
jne 0xfce2
jmp 0xfd05
movq -0x18(%rbp), %rax
movb $0x1, (%rax)
jmp 0xfd5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3190
jmp 0xfecc
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xe790
movq %rax, -0xc8(%rbp)
jmp 0xfd26
movq -0xc8(%rbp), %rsi
movq -0xd0(%rbp), %rdi
callq 0x100c0
testb $0x1, %al
jne 0xfd3f
jmp 0xfd49
movq -0x18(%rbp), %rax
movb $0x1, 0x6(%rax)
jmp 0xfd58
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x6(%rax)
jmp 0xfd5a
leaq -0x48(%rbp), %rdi
callq 0x3190
jmp 0xfec1
movq -0xa8(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x3110
movq -0xe0(%rbp), %rdi
callq 0x3800
movb %al, -0xd1(%rbp)
jmp 0xfd93
leaq -0x78(%rbp), %rdi
callq 0x3190
movb -0xd1(%rbp), %al
testb $0x1, %al
jne 0xfdab
jmp 0xfe87
movq -0xa8(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x3110
movq -0xf0(%rbp), %rdi
callq 0x3970
movl %eax, -0xe4(%rbp)
jmp 0xfdd9
leaq -0xa0(%rbp), %rdi
callq 0x3190
movl -0xe4(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x7c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
callq 0xeee0
testb $0x1, %al
jne 0xfe0c
jmp 0xfe4c
movq -0x18(%rbp), %rax
movb $0x1, (%rax)
jmp 0xfe85
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3190
jmp 0xfecc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3190
jmp 0xfecc
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x7c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
callq 0x100c0
testb $0x1, %al
jne 0xfe6a
jmp 0xfe74
movq -0x18(%rbp), %rax
movb $0x1, 0x6(%rax)
jmp 0xfe83
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x6(%rax)
jmp 0xfe85
jmp 0xfebf
movq 0xb142(%rip), %rdi      # 0x1afd0
leaq 0x5374(%rip), %rsi      # 0x15209
callq 0x3270
movq -0xa8(%rbp), %rsi
movq %rax, %rdi
callq 0x3260
movq %rax, %rdi
leaq 0x535e(%rip), %rsi      # 0x15211
callq 0x3270
xorl %edi, %edi
callq 0x3320
jmp 0xfec1
jmp 0xfec3
addq $0xf0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3430
nopw %cs:(%rax,%rax)