// File: sthapliyal37[P]Microprocessor_8085_Updated/arithmetic.cpp
// Function: ADD(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 ADD(string instruction,string* registers,bool* flag,map<string,string> &memory)
{
	int length=instruction.length();
	if(length == 1){
		
		if(validityRegisters(instruction) || validityRegisterPair(instruction)){
			
			if(instruction != "M"){
				int registerID = registerNumber(instruction);
				registers[0] = hexAdd(registers[registerID],registers[0],flag,true);
				
			}
			else{                         
		
				string address = "";
				address = address + registers[5] + registers[6];
				if(address >= "0000" && address <= "FFFF"){
					registers[0] = hexAdd(memory[address],registers[0],flag,true);				 
				}						
			}
			
			}
			}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x1d0(%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 0xbbe9
movq -0x1d0(%rbp), %rsi
leaq -0x48(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x3110
movq -0x1e0(%rbp), %rdi
movb $0x0, -0x79(%rbp)
callq 0x3800
movb %al, -0x1d1(%rbp)
jmp 0xb7b3
movb -0x1d1(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1e1(%rbp)
jne 0xb7fd
jmp 0xb7c8
movq -0x1d0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x3110
jmp 0xb7da
movb $0x1, -0x79(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x38d0
movb %al, -0x1e2(%rbp)
jmp 0xb7ef
movb -0x1e2(%rbp), %al
movb %al, -0x1e1(%rbp)
jmp 0xb7fd
movb -0x1e1(%rbp), %al
movb %al, -0x1e3(%rbp)
testb $0x1, -0x79(%rbp)
jne 0xb811
jmp 0xb81a
leaq -0x78(%rbp), %rdi
callq 0x3190
leaq -0x48(%rbp), %rdi
callq 0x3190
movb -0x1e3(%rbp), %al
testb $0x1, %al
jne 0xb832
jmp 0xbbe7
movq -0x1d0(%rbp), %rdi
leaq 0x97d0(%rip), %rsi      # 0x15010
callq 0xe630
testb $0x1, %al
jne 0xb84e
jmp 0xb9ac
movq -0x1d0(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x3110
movq -0x1f0(%rbp), %rdi
callq 0x3970
movl %eax, -0x1e8(%rbp)
jmp 0xb87c
leaq -0xa0(%rbp), %rdi
callq 0x3190
movl -0x1e8(%rbp), %eax
movl %eax, -0x80(%rbp)
movq -0x10(%rbp), %rsi
movslq -0x80(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x3110
movq -0x10(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x3110
jmp 0xb8be
movq -0x18(%rbp), %rcx
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0x100(%rbp), %rdx
movl $0x1, %r8d
callq 0x76b0
jmp 0xb8e4
movq -0x10(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3330
leaq -0xc0(%rbp), %rdi
callq 0x3190
leaq -0x100(%rbp), %rdi
callq 0x3190
leaq -0xe0(%rbp), %rdi
callq 0x3190
jmp 0xbbe5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb94a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
testb $0x1, -0x79(%rbp)
jne 0xb93f
jmp 0xb948
leaq -0x78(%rbp), %rdi
callq 0x3190
jmp 0xb94a
leaq -0x48(%rbp), %rdi
callq 0x3190
jmp 0xbbf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3190
jmp 0xbbf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb99b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x3190
leaq -0xe0(%rbp), %rdi
callq 0x3190
jmp 0xbbf2
leaq -0x121(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x3440
movq -0x1f8(%rbp), %rdx
leaq 0x9835(%rip), %rsi      # 0x15202
leaq -0x120(%rbp), %rdi
callq 0x50d0
jmp 0xb9db
leaq -0x121(%rbp), %rdi
callq 0x32f0
movq -0x10(%rbp), %rdx
addq $0xa0, %rdx
leaq -0x168(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xe6b0
jmp 0xba07
movq -0x10(%rbp), %rdx
addq $0xc0, %rdx
leaq -0x148(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0xe660
jmp 0xba27
leaq -0x120(%rbp), %rdi
movq %rdi, -0x208(%rbp)
leaq -0x148(%rbp), %rsi
movq %rsi, -0x210(%rbp)
callq 0x3330
movq -0x210(%rbp), %rdi
callq 0x3190
leaq -0x168(%rbp), %rdi
callq 0x3190
movq -0x208(%rbp), %rdi
leaq 0x977a(%rip), %rsi      # 0x151e8
callq 0xe730
movb %al, -0x1f9(%rbp)
jmp 0xba7b
movb -0x1f9(%rbp), %al
testb $0x1, %al
jne 0xba8a
jmp 0xbbc9
leaq 0x975c(%rip), %rsi      # 0x151ed
leaq -0x120(%rbp), %rdi
callq 0xe760
movb %al, -0x211(%rbp)
jmp 0xbaa5
movb -0x211(%rbp), %al
testb $0x1, %al
jne 0xbab4
jmp 0xbbc9
movq -0x20(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xe790
movq %rax, -0x220(%rbp)
jmp 0xbacd
movq -0x220(%rbp), %rsi
leaq -0x1a8(%rbp), %rdi
callq 0x3110
jmp 0xbae2
movq -0x10(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
callq 0x3110
jmp 0xbaf4
movq -0x18(%rbp), %rcx
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
movl $0x1, %r8d
callq 0x76b0
jmp 0xbb1a
movq -0x10(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x3330
leaq -0x188(%rbp), %rdi
callq 0x3190
leaq -0x1c8(%rbp), %rdi
callq 0x3190
leaq -0x1a8(%rbp), %rdi
callq 0x3190
jmp 0xbbc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x121(%rbp), %rdi
callq 0x32f0
jmp 0xbbf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xbbd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x3190
jmp 0xbbd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xbbbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x3190
leaq -0x1a8(%rbp), %rdi
callq 0x3190
jmp 0xbbd7
leaq -0x120(%rbp), %rdi
callq 0x3190
jmp 0xbbe5
leaq -0x120(%rbp), %rdi
callq 0x3190
jmp 0xbbf2
jmp 0xbbe7
jmp 0xbbe9
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3430
nopl (%rax,%rax)