// File: /workspace/github_cpp_makefile_star2_O2/sthapliyal37[P]Microprocessor_8085_Updated/DataTransfer.cpp
// Function: MVI(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::__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 MVI (string instruction,string instruction2,string* registers,bool* flags,map<string,string> &memory)
{
	int length=instruction.length();
	int length2=instruction2.length();
	//cout<<instruction<<" "<<instruction2<<endl;	
	if(length==1&&length2==2)
	{
	        if(instruction=="M")
	        {
	            string address=registers[5]+registers[6];
	            if(validityData(instruction))
	                memory[address]=instruction2;
	        }

	else if(validityRegisters(instruction)&&validityData(instruction2))
	{
			
			if(instruction == "A" && instruction2 == "00")
			{
				
				flags[6] = true;
				flags[2] = true;
			}
			else if(instruction=="A" && instruction2!="00")
            		{
				string temp = instruction2;
				int array[2];
        		        hexToDecimal(temp,array);
        		        int value=array[1]*16+array[0];
        		        bitset<8> dataInBinary(value);
        		        int parity = dataInBinary.count();
        		        if(parity%2 == 0 && parity!=0)
        		           flags[2] = true;
        		        else
        		           flags[2] = false;
        		}
			registers[registerNumber(instruction)]=instruction2;
	//	cout<<registerNumber(instruction)<<" "<<registers[registerNumber(instruction)]<<endl;		
	}

}
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
cmpl $0x1, 0x8(%rdi)
jne 0x8543
movq %rsi, %rbx
movl 0x8(%rsi), %eax
cmpl $0x2, %eax
jne 0x8543
movq %r8, %r13
movq %rcx, %r12
movq %rdx, %r14
movq %rdi, %r15
leaq 0x1c93(%rip), %rsi      # 0xa010
callq 0x2f0d
testb %al, %al
je 0x83ef
leaq 0xa0(%r14), %rsi
addq $0xc0, %r14
leaq -0x50(%rbp), %rdi
movq %r14, %rdx
callq 0x71f4
leaq -0xd0(%rbp), %rdi
movq %r15, %rsi
callq 0x2280
leaq -0xd0(%rbp), %rdi
callq 0x28cb
movl %eax, %r14d
leaq -0xd0(%rbp), %rdi
callq 0x20f0
testb %r14b, %r14b
je 0x83e6
leaq -0x50(%rbp), %rsi
movq %r13, %rdi
callq 0x724c
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2120
leaq -0x50(%rbp), %rdi
jmp 0x853e
leaq -0xb0(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x2280
movq %r13, %rdi
callq 0x262c
testb %al, %al
je 0x8483
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
callq 0x2280
leaq -0x90(%rbp), %rdi
callq 0x28cb
movl %eax, %r13d
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq -0xb0(%rbp), %rdi
callq 0x20f0
testb %r13b, %r13b
je 0x8543
leaq 0x1c0f(%rip), %rsi      # 0xa062
movq %r15, %rdi
callq 0x2f0d
testb %al, %al
je 0x848f
leaq 0x1d84(%rip), %rsi      # 0xa1ea
movq %rbx, %rdi
callq 0x2f0d
testb %al, %al
je 0x848f
movb $0x1, %al
movb %al, 0x6(%r12)
movb %al, 0x2(%r12)
jmp 0x8509
leaq -0xb0(%rbp), %rdi
jmp 0x853e
leaq 0x1bcc(%rip), %rsi      # 0xa062
movq %r15, %rdi
callq 0x2f0d
testb %al, %al
je 0x8509
leaq 0x1d41(%rip), %rsi      # 0xa1ea
movq %rbx, %rdi
callq 0x71be
testb %al, %al
je 0x8509
leaq -0x50(%rbp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2280
leaq -0x70(%rbp), %rdi
movq %r13, %rsi
callq 0x2280
leaq -0x70(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3d02
leaq -0x70(%rbp), %rdi
callq 0x20f0
movl -0x2c(%rbp), %eax
shll $0x4, %eax
addl -0x30(%rbp), %eax
testb %al, %al
setp %cl
testb $-0x1, %al
setne %al
andb %cl, %al
movb %al, 0x2(%r12)
leaq -0x50(%rbp), %rdi
callq 0x20f0
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2280
movq %r12, %rdi
callq 0x2740
cltq
shlq $0x5, %rax
addq %rax, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2120
leaq -0xf0(%rbp), %rdi
callq 0x20f0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
jmp 0x8587
jmp 0x859a
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
jmp 0x85a1
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x20f0
jmp 0x8591
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x20f0
jmp 0x859d
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
jmp 0x85a1
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2310