// File: 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
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x158(%rbp)
movq %rsi, -0x150(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
callq 0x33b0
movq -0x150(%rbp), %rdi
movl %eax, -0x2c(%rbp)
callq 0x33b0
movl %eax, -0x30(%rbp)
cmpl $0x1, -0x2c(%rbp)
jne 0x1186b
cmpl $0x2, -0x30(%rbp)
jne 0x1186b
movq -0x158(%rbp), %rdi
leaq 0x3b8a(%rip), %rsi      # 0x15010
callq 0x50a0
testb $0x1, %al
jne 0x11494
jmp 0x11558
movq -0x18(%rbp), %rdx
movq %rdx, %rsi
addq $0xa0, %rsi
addq $0xc0, %rdx
leaq -0x50(%rbp), %rdi
callq 0xe6b0
movq -0x158(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x3110
jmp 0x114c4
leaq -0x70(%rbp), %rdi
callq 0x3cc0
movb %al, -0x159(%rbp)
jmp 0x114d5
leaq -0x70(%rbp), %rdi
callq 0x3190
movb -0x159(%rbp), %al
testb $0x1, %al
jne 0x114ea
jmp 0x1153c
movq -0x28(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xe790
movq %rax, -0x168(%rbp)
jmp 0x11500
movq -0x150(%rbp), %rsi
movq -0x168(%rbp), %rdi
callq 0x3050
jmp 0x11515
jmp 0x1153c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1154a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3190
jmp 0x1154a
leaq -0x50(%rbp), %rdi
callq 0x3190
jmp 0x11869
leaq -0x50(%rbp), %rdi
callq 0x3190
jmp 0x11874
movq -0x158(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x3110
movq -0x178(%rbp), %rdi
movb $0x0, -0xc1(%rbp)
callq 0x3800
movb %al, -0x169(%rbp)
jmp 0x1158d
movb -0x169(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x179(%rbp)
jne 0x115a2
jmp 0x115e0
movq -0x150(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x3110
jmp 0x115b7
movb $0x1, -0xc1(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x3cc0
movb %al, -0x17a(%rbp)
jmp 0x115d2
movb -0x17a(%rbp), %al
movb %al, -0x179(%rbp)
jmp 0x115e0
movb -0x179(%rbp), %al
movb %al, -0x17b(%rbp)
testb $0x1, -0xc1(%rbp)
jne 0x115f7
jmp 0x11603
leaq -0xc0(%rbp), %rdi
callq 0x3190
leaq -0xa0(%rbp), %rdi
callq 0x3190
movb -0x17b(%rbp), %al
testb $0x1, %al
jne 0x1161e
jmp 0x11867
movq -0x158(%rbp), %rdi
leaq 0x3a36(%rip), %rsi      # 0x15062
callq 0x50a0
testb $0x1, %al
jne 0x11637
jmp 0x116a9
movq -0x150(%rbp), %rdi
leaq 0x3ba5(%rip), %rsi      # 0x151ea
callq 0x50a0
testb $0x1, %al
jne 0x11650
jmp 0x116a9
movq -0x20(%rbp), %rax
movb $0x1, 0x6(%rax)
movq -0x20(%rbp), %rax
movb $0x1, 0x2(%rax)
jmp 0x117e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x11698
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
testb $0x1, -0xc1(%rbp)
jne 0x1168a
jmp 0x11696
leaq -0xc0(%rbp), %rdi
callq 0x3190
jmp 0x11698
leaq -0xa0(%rbp), %rdi
callq 0x3190
jmp 0x11874
movq -0x158(%rbp), %rdi
leaq 0x39ab(%rip), %rsi      # 0x15062
callq 0x50a0
testb $0x1, %al
jne 0x116c5
jmp 0x117e0
movq -0x150(%rbp), %rdi
leaq 0x3b17(%rip), %rsi      # 0x151ea
callq 0xe630
testb $0x1, %al
jne 0x116e1
jmp 0x117e0
movq -0x150(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x3110
movq -0x188(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x3110
jmp 0x11710
leaq -0x110(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x7a50
jmp 0x11725
leaq -0x110(%rbp), %rdi
callq 0x3190
movl -0xec(%rbp), %eax
shll $0x4, %eax
addl -0xf0(%rbp), %eax
movl %eax, -0x114(%rbp)
movslq -0x114(%rbp), %rsi
leaq -0x120(%rbp), %rdi
callq 0x83f0
leaq -0x120(%rbp), %rdi
callq 0x8440
movl %eax, -0x124(%rbp)
movl -0x124(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x117b9
cmpl $0x0, -0x124(%rbp)
je 0x117b9
movq -0x20(%rbp), %rax
movb $0x1, 0x2(%rax)
jmp 0x117c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x117cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x3190
jmp 0x117cf
movq -0x20(%rbp), %rax
movb $0x0, 0x2(%rax)
leaq -0xe8(%rbp), %rdi
callq 0x3190
jmp 0x117e0
leaq -0xe8(%rbp), %rdi
callq 0x3190
jmp 0x11874
jmp 0x117e2
movq -0x158(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x148(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x3110
movq -0x198(%rbp), %rdi
callq 0x3970
movl %eax, -0x18c(%rbp)
jmp 0x1181b
movq -0x150(%rbp), %rsi
movq -0x1a0(%rbp), %rdi
movl -0x18c(%rbp), %eax
cltq
shlq $0x5, %rax
addq %rax, %rdi
callq 0x3050
jmp 0x1183f
leaq -0x148(%rbp), %rdi
callq 0x3190
jmp 0x11867
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x3190
jmp 0x11874
jmp 0x11869
jmp 0x1186b
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x3430
nopl (%rax)