// File: 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
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 0xc1e9
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 0xbdb3
movb -0x1d1(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1e1(%rbp)
jne 0xbdfd
jmp 0xbdc8
movq -0x1d0(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x3110
jmp 0xbdda
movb $0x1, -0x79(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x38d0
movb %al, -0x1e2(%rbp)
jmp 0xbdef
movb -0x1e2(%rbp), %al
movb %al, -0x1e1(%rbp)
jmp 0xbdfd
movb -0x1e1(%rbp), %al
movb %al, -0x1e3(%rbp)
testb $0x1, -0x79(%rbp)
jne 0xbe11
jmp 0xbe1a
leaq -0x78(%rbp), %rdi
callq 0x3190
leaq -0x48(%rbp), %rdi
callq 0x3190
movb -0x1e3(%rbp), %al
testb $0x1, %al
jne 0xbe32
jmp 0xc1e7
movq -0x1d0(%rbp), %rdi
leaq 0x91d0(%rip), %rsi      # 0x15010
callq 0xe630
testb $0x1, %al
jne 0xbe4e
jmp 0xbfac
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 0xbe7c
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 0xbebe
movq -0x18(%rbp), %rcx
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0x100(%rbp), %rdx
movl $0x1, %r8d
callq 0x7f00
jmp 0xbee4
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 0xc1e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xbf4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
testb $0x1, -0x79(%rbp)
jne 0xbf3f
jmp 0xbf48
leaq -0x78(%rbp), %rdi
callq 0x3190
jmp 0xbf4a
leaq -0x48(%rbp), %rdi
callq 0x3190
jmp 0xc1f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3190
jmp 0xc1f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xbf9b
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 0xc1f2
leaq -0x121(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x3440
movq -0x1f8(%rbp), %rdx
leaq 0x9235(%rip), %rsi      # 0x15202
leaq -0x120(%rbp), %rdi
callq 0x50d0
jmp 0xbfdb
leaq -0x121(%rbp), %rdi
callq 0x32f0
movq -0x10(%rbp), %rdx
addq $0xa0, %rdx
leaq -0x168(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xe6b0
jmp 0xc007
movq -0x10(%rbp), %rdx
addq $0xc0, %rdx
leaq -0x148(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0xe660
jmp 0xc027
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 0x917a(%rip), %rsi      # 0x151e8
callq 0xe730
movb %al, -0x1f9(%rbp)
jmp 0xc07b
movb -0x1f9(%rbp), %al
testb $0x1, %al
jne 0xc08a
jmp 0xc1c9
leaq 0x915c(%rip), %rsi      # 0x151ed
leaq -0x120(%rbp), %rdi
callq 0xe760
movb %al, -0x211(%rbp)
jmp 0xc0a5
movb -0x211(%rbp), %al
testb $0x1, %al
jne 0xc0b4
jmp 0xc1c9
movq -0x20(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xe790
movq %rax, -0x220(%rbp)
jmp 0xc0cd
movq -0x220(%rbp), %rsi
leaq -0x1a8(%rbp), %rdi
callq 0x3110
jmp 0xc0e2
movq -0x10(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
callq 0x3110
jmp 0xc0f4
movq -0x18(%rbp), %rcx
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdx
movl $0x1, %r8d
callq 0x7f00
jmp 0xc11a
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 0xc1c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x121(%rbp), %rdi
callq 0x32f0
jmp 0xc1f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xc1d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x3190
jmp 0xc1d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xc1bb
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 0xc1d7
leaq -0x120(%rbp), %rdi
callq 0x3190
jmp 0xc1e5
leaq -0x120(%rbp), %rdi
callq 0x3190
jmp 0xc1f2
jmp 0xc1e7
jmp 0xc1e9
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3430
nopl (%rax,%rax)