// File: sthapliyal37[P]Microprocessor_8085_Updated/arithmetic.cpp
// Function: DCX(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*)
void DCX(string instruction,string* registers,bool* flag)
{
	int length = instruction.length();
	if(length == 1){
	
		if(validityRegisters(instruction)){
			
			int registerID = registerNumber(instruction);
			if(registerID == 1 || registerID == 3 || registerID == 5){
			
				string data16bit = "";
				string temporary = "";
				string s1 = "";
				string s2 = "";
				string x="5000";
				if(validityData(registers[registerID]) == true && validityData(registers[registerID+1]) == true){
					
					data16bit = data16bit + registers[registerID] + registers[registerID + 1];
					temporary = hexSub16bit(data16bit,x,flag,false);
					 s1 = s1 + temporary[0] + temporary[1];		
					 s2 = s2 +temporary[2] + temporary[3];
					registers[registerID] = s1;
					registers[registerID+1] = s2;
				}
				else{
					cout<<"Error: \n";
					exit(0);
				}
			}
			}}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movq %rdi, -0x2a8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
callq 0x33b0
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0xda87
movq -0x2a8(%rbp), %rsi
leaq -0x40(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x3110
movq -0x2b8(%rbp), %rdi
callq 0x3800
movb %al, -0x2a9(%rbp)
jmp 0xd33b
leaq -0x40(%rbp), %rdi
callq 0x3190
movb -0x2a9(%rbp), %al
testb $0x1, %al
jne 0xd353
jmp 0xda85
movq -0x2a8(%rbp), %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x3110
movq -0x2c8(%rbp), %rdi
callq 0x3970
movl %eax, -0x2bc(%rbp)
jmp 0xd37e
leaq -0x70(%rbp), %rdi
callq 0x3190
movl -0x2bc(%rbp), %eax
movl %eax, -0x50(%rbp)
cmpl $0x1, -0x50(%rbp)
je 0xd3a6
cmpl $0x3, -0x50(%rbp)
je 0xd3a6
cmpl $0x5, -0x50(%rbp)
jne 0xda83
leaq -0x91(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x3440
movq -0x2d0(%rbp), %rdx
leaq 0x7e3b(%rip), %rsi      # 0x15202
leaq -0x90(%rbp), %rdi
callq 0x50d0
jmp 0xd3d5
leaq -0x91(%rbp), %rdi
callq 0x32f0
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x3440
movq -0x2d8(%rbp), %rdx
leaq 0x7e00(%rip), %rsi      # 0x15202
leaq -0xb8(%rbp), %rdi
callq 0x50d0
jmp 0xd410
leaq -0xb9(%rbp), %rdi
callq 0x32f0
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x3440
movq -0x2e0(%rbp), %rdx
leaq 0x7dc5(%rip), %rsi      # 0x15202
leaq -0xe0(%rbp), %rdi
callq 0x50d0
jmp 0xd44b
leaq -0xe1(%rbp), %rdi
callq 0x32f0
leaq -0x109(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0x3440
movq -0x2e8(%rbp), %rdx
leaq 0x7d8a(%rip), %rsi      # 0x15202
leaq -0x108(%rbp), %rdi
callq 0x50d0
jmp 0xd486
leaq -0x109(%rbp), %rdi
callq 0x32f0
leaq -0x131(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x3440
movq -0x2f0(%rbp), %rdx
leaq 0x7d50(%rip), %rsi      # 0x15203
leaq -0x130(%rbp), %rdi
callq 0x50d0
jmp 0xd4c1
leaq -0x131(%rbp), %rdi
callq 0x32f0
movq -0x10(%rbp), %rsi
movslq -0x50(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
movb $0x0, -0x179(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x3110
jmp 0xd4f1
leaq -0x158(%rbp), %rdi
callq 0x3cc0
movb %al, -0x2f1(%rbp)
jmp 0xd505
movb -0x2f1(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
movb %al, -0x2f2(%rbp)
jne 0xd56e
movq -0x10(%rbp), %rcx
movslq -0x50(%rbp), %rax
shlq $0x5, %rax
leaq 0x20(%rax,%rcx), %rsi
leaq -0x178(%rbp), %rdi
callq 0x3110
jmp 0xd53c
movb $0x1, -0x179(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x3cc0
movb %al, -0x2f3(%rbp)
jmp 0xd557
movb -0x2f3(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
sete %al
movb %al, -0x2f2(%rbp)
movb -0x2f2(%rbp), %al
movb %al, -0x2f4(%rbp)
testb $0x1, -0x179(%rbp)
jne 0xd585
jmp 0xd591
leaq -0x178(%rbp), %rdi
callq 0x3190
leaq -0x158(%rbp), %rdi
callq 0x3190
movb -0x2f4(%rbp), %al
testb $0x1, %al
jne 0xd5ac
jmp 0xd9eb
movq -0x10(%rbp), %rdx
movslq -0x50(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdx
leaq -0x1c0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xe6b0
jmp 0xd5d0
movq -0x10(%rbp), %rcx
movslq -0x50(%rbp), %rax
shlq $0x5, %rax
leaq 0x20(%rax,%rcx), %rdx
leaq -0x1a0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xe660
jmp 0xd5f6
leaq -0x90(%rbp), %rdi
movq %rdi, -0x300(%rbp)
leaq -0x1a0(%rbp), %rsi
movq %rsi, -0x308(%rbp)
callq 0x3330
movq -0x308(%rbp), %rdi
callq 0x3190
leaq -0x1c0(%rbp), %rdi
callq 0x3190
movq -0x300(%rbp), %rsi
leaq -0x200(%rbp), %rdi
callq 0x3110
jmp 0xd644
leaq -0x220(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3110
jmp 0xd659
movq -0x18(%rbp), %rcx
leaq -0x1e0(%rbp), %rdi
leaq -0x200(%rbp), %rsi
leaq -0x220(%rbp), %rdx
xorl %r8d, %r8d
callq 0x7b00
jmp 0xd67c
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x318(%rbp)
leaq -0x1e0(%rbp), %rsi
movq %rsi, -0x320(%rbp)
callq 0x3330
movq -0x320(%rbp), %rdi
callq 0x3190
leaq -0x220(%rbp), %rdi
callq 0x3190
leaq -0x200(%rbp), %rdi
callq 0x3190
movq -0x318(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x34a0
movq %rax, -0x310(%rbp)
jmp 0xd6da
movq -0x310(%rbp), %rax
movsbl (%rax), %edx
leaq -0x260(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x8270
jmp 0xd6f9
leaq -0xb8(%rbp), %rdi
movl $0x1, %esi
callq 0x34a0
movq %rax, -0x328(%rbp)
jmp 0xd713
movq -0x328(%rbp), %rax
movsbl (%rax), %edx
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0xe870
jmp 0xd732
leaq -0xe0(%rbp), %rdi
leaq -0x240(%rbp), %rsi
movq %rsi, -0x338(%rbp)
callq 0x3330
movq -0x338(%rbp), %rdi
callq 0x3190
leaq -0x260(%rbp), %rdi
callq 0x3190
leaq -0xb8(%rbp), %rdi
movl $0x2, %esi
callq 0x34a0
movq %rax, -0x330(%rbp)
jmp 0xd77e
movq -0x330(%rbp), %rax
movsbl (%rax), %edx
leaq -0x2a0(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x8270
jmp 0xd79d
leaq -0xb8(%rbp), %rdi
movl $0x3, %esi
callq 0x34a0
movq %rax, -0x340(%rbp)
jmp 0xd7b7
movq -0x340(%rbp), %rax
movsbl (%rax), %edx
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0xe870
jmp 0xd7d6
leaq -0x108(%rbp), %rdi
leaq -0x280(%rbp), %rsi
movq %rsi, -0x348(%rbp)
callq 0x3330
movq -0x348(%rbp), %rdi
callq 0x3190
leaq -0x2a0(%rbp), %rdi
callq 0x3190
movq -0x10(%rbp), %rdi
movslq -0x50(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3050
jmp 0xd825
movq -0x10(%rbp), %rcx
movslq -0x50(%rbp), %rax
shlq $0x5, %rax
leaq 0x20(%rax,%rcx), %rdi
leaq -0x108(%rbp), %rsi
callq 0x3050
jmp 0xd844
jmp 0xda07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3190
jmp 0xda90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3190
jmp 0xda90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x32f0
jmp 0xda90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb9(%rbp), %rdi
callq 0x32f0
jmp 0xda75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe1(%rbp), %rdi
callq 0x32f0
jmp 0xda69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x109(%rbp), %rdi
callq 0x32f0
jmp 0xda5d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x131(%rbp), %rdi
callq 0x32f0
jmp 0xda51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xda45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xd952
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
testb $0x1, -0x179(%rbp)
jne 0xd944
jmp 0xd950
leaq -0x178(%rbp), %rdi
callq 0x3190
jmp 0xd952
leaq -0x158(%rbp), %rdi
callq 0x3190
jmp 0xda45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x3190
jmp 0xda45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xd9a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x3190
leaq -0x200(%rbp), %rdi
callq 0x3190
jmp 0xda45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x3190
jmp 0xda45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x3190
jmp 0xda45
movq 0xd5de(%rip), %rdi      # 0x1afd0
leaq 0x7801(%rip), %rsi      # 0x151fa
callq 0x3270
jmp 0xda00
xorl %edi, %edi
callq 0x3320
leaq -0x130(%rbp), %rdi
callq 0x3190
leaq -0x108(%rbp), %rdi
callq 0x3190
leaq -0xe0(%rbp), %rdi
callq 0x3190
leaq -0xb8(%rbp), %rdi
callq 0x3190
leaq -0x90(%rbp), %rdi
callq 0x3190
jmp 0xda83
leaq -0x130(%rbp), %rdi
callq 0x3190
leaq -0x108(%rbp), %rdi
callq 0x3190
leaq -0xe0(%rbp), %rdi
callq 0x3190
leaq -0xb8(%rbp), %rdi
callq 0x3190
leaq -0x90(%rbp), %rdi
callq 0x3190
jmp 0xda90
jmp 0xda85
jmp 0xda87
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x3430
nopl (%rax)