// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
cmpl $0x1, 0x8(%rdi)
jne 0x58db
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r12
leaq -0x148(%rbp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x2280
movq %r13, %rdi
callq 0x262c
testb %al, %al
je 0x56d6
leaq -0x148(%rbp), %rdi
callq 0x20f0
jmp 0x5715
leaq -0x128(%rbp), %rdi
movq %r12, %rsi
callq 0x2280
leaq -0x128(%rbp), %rdi
callq 0x26da
movl %eax, %r13d
leaq -0x128(%rbp), %rdi
callq 0x20f0
leaq -0x148(%rbp), %rdi
callq 0x20f0
testb %r13b, %r13b
je 0x58db
leaq 0x48f4(%rip), %rsi      # 0xa010
movq %r12, %rdi
callq 0x71be
testb %al, %al
je 0x57c7
leaq -0x168(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2280
movq %r15, %rdi
callq 0x2740
movl %eax, %r15d
leaq -0x168(%rbp), %rdi
callq 0x20f0
movslq %r15d, %rsi
shlq $0x5, %rsi
addq %rbx, %rsi
leaq -0x108(%rbp), %rdi
callq 0x2280
leaq -0xe8(%rbp), %rdi
movq %rbx, %rsi
callq 0x2280
leaq -0x48(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
pushq $0x1
popq %r8
movq %r14, %rcx
callq 0x3b76
leaq -0x48(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2250
movq %r14, %rdi
callq 0x20f0
leaq -0xe8(%rbp), %rdi
callq 0x20f0
leaq -0x108(%rbp), %rdi
jmp 0x58d6
leaq 0x4a34(%rip), %rsi      # 0xa202
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2f1e
leaq 0xa0(%rbx), %rdx
leaq -0xc8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x71f4
leaq 0xc0(%rbx), %rdx
leaq -0x68(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x71cb
leaq -0x48(%rbp), %r12
leaq -0x68(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x2250
movq %r13, %rdi
callq 0x20f0
leaq -0xc8(%rbp), %rdi
callq 0x20f0
leaq 0x49b1(%rip), %rsi      # 0xa1e8
movq %r12, %rdi
callq 0x722c
testb %al, %al
je 0x58d2
leaq 0x499f(%rip), %rsi      # 0xa1ed
leaq -0x48(%rbp), %rdi
callq 0x723c
testb %al, %al
je 0x58d2
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x724c
leaq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x2280
leaq -0x88(%rbp), %rdi
movq %rbx, %rsi
callq 0x2280
leaq -0x68(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
leaq -0x88(%rbp), %rdx
pushq $0x1
popq %r8
movq %r14, %rcx
callq 0x3b76
leaq -0x68(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2250
movq %r14, %rdi
callq 0x20f0
leaq -0x88(%rbp), %rdi
callq 0x20f0
leaq -0xa8(%rbp), %rdi
callq 0x20f0
leaq -0x48(%rbp), %rdi
callq 0x20f0
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x20f0
jmp 0x5901
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
jmp 0x5916
jmp 0x592e
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x20f0
jmp 0x5931
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x20f0
jmp 0x593a
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
jmp 0x596f
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0x596f
movq %rax, %rbx
jmp 0x5974
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
jmp 0x596f
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x20f0
jmp 0x5968
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2310