// File: /workspace/github_cpp_makefile_star2_O2/sthapliyal37[P]Microprocessor_8085_Updated/arithmetic.cpp
// Function: SUB(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 SUB(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] = hexSub(registers[registerID],registers[0],flag,true);
				
			}
			else{                         
				string address = "";
				address = address + registers[5] + registers[6];
				if(address >= "0000" && address <= "FFFF"){
					registers[0] = hexSub(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 0x5cbe
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 0x5ab9
leaq -0x148(%rbp), %rdi
callq 0x20f0
jmp 0x5af8
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 0x5cbe
leaq 0x4511(%rip), %rsi      # 0xa010
movq %r12, %rdi
callq 0x71be
testb %al, %al
je 0x5baa
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 0x3eba
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 0x5cb9
leaq 0x4651(%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 0x45ce(%rip), %rsi      # 0xa1e8
movq %r12, %rdi
callq 0x722c
testb %al, %al
je 0x5cb5
leaq 0x45bc(%rip), %rsi      # 0xa1ed
leaq -0x48(%rbp), %rdi
callq 0x723c
testb %al, %al
je 0x5cb5
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 0x3eba
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 0x5ce4
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
jmp 0x5cf9
jmp 0x5d11
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x20f0
jmp 0x5d14
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x20f0
jmp 0x5d1d
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
jmp 0x5d52
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0x5d52
movq %rax, %rbx
jmp 0x5d57
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
jmp 0x5d52
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x20f0
jmp 0x5d4b
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2310