// File: zerolfx[P]P-Machine/dpl.cpp
// Function: Dpl::execute(StackMachine*)
void Dpl::execute(StackMachine *stack)
{
	switch(fType)
	{
		case integer:
		{
			StackInteger p1;

			// check if uppermost stackentry is of type integer
			if(typeid(p1) != typeid(*stack->fStore[stack->fSP]))
			{
				throw ExecutionError("instruction dpl: SP does not point to element of type integer.");
			}
			else
			{
				stack->fStore.push_back(new StackInteger(*(dynamic_cast<StackInteger*>(stack->fStore[stack->fSP]))));
			}
				
			break;
		}	
		case real:
		{
			StackReal p1;
			// check if uppermost stackentry is of type real
			if(typeid(p1) != typeid(*stack->fStore[stack->fSP]))
			{
				throw ExecutionError("instruction dpl: SP does not point to element of type real.");
			}
			else
			{
				stack->fStore.push_back(new StackReal(*(dynamic_cast<StackReal*>(stack->fStore[stack->fSP]))));
			}


			break;
		}
		case boolean:
		{
			StackBoolean p1;
			
			// check if uppermost stackentry is of type boolean
			if(typeid(p1) != typeid(*stack->fStore[stack->fSP]))
			{
				throw ExecutionError("instruction dpl: SP does not point to element of type boolean.");
			}
			else
			{
				stack->fStore.push_back(new StackBoolean(*(dynamic_cast<StackBoolean*>(stack->fStore[stack->fSP]))));
			}


			break;
		}
		case character:
		{
			StackCharacter p1;
			
			// check if uppermost stackentry is of type character
			if(typeid(p1) != typeid(*stack->fStore[stack->fSP]))
			{
				throw ExecutionError("instruction dpl: SP does not point to element of type character.");
			}
			else
			{
				stack->fStore.push_back(new StackCharacter(*(dynamic_cast<StackCharacter*>(stack->fStore[stack->fSP]))));
			}


			break;
		}
		case address:
		{
			StackAddress p1;

			// check if constant is of type address
			if(typeid(p1) != typeid(*stack->fStore[stack->fSP]))
			{
				throw ExecutionError("instruction dpl: SP does not point to element of type address.");
			}
			else
			{
				stack->fStore.push_back(new StackAddress(*(dynamic_cast<StackAddress*>(stack->fStore[stack->fSP]))));
			}

			break;
		}
	}
	
	// fSP = fSP + 1
	++stack->fSP;
	
	// adding cost of this instruction
	stack->fTime.count("dpl");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x190(%rbp)
subq $0x4, %rax
ja 0xd146
movq -0x190(%rbp), %rax
leaq 0x2b09f(%rip), %rcx     # 0x37798
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x27340
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x198(%rbp)
cmpq $0x0, %rax
jne 0xc73c
callq 0x7300
jmp 0xc73c
movq -0x198(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3e39f(%rip), %rdi     # 0x4aaf0
callq 0x9370
testb $0x1, %al
jne 0xc75f
jmp 0xc828
movb $0x1, -0x52(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1a8(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x74f0
movq -0x1a0(%rbp), %rdx
leaq 0x2b01f(%rip), %rsi     # 0x377b1
leaq -0x50(%rbp), %rdi
callq 0x8940
jmp 0xc79d
movq -0x1a8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x283d0
jmp 0xc7af
movq -0x1a8(%rbp), %rdi
movb $0x0, -0x52(%rbp)
leaq 0x3d2bf(%rip), %rsi     # 0x49a80
leaq 0x1bc38(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xd207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xc8e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xc806
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x7170
leaq -0x51(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x52(%rbp)
jne 0xc817
jmp 0xc823
movq -0x1a8(%rbp), %rdi
callq 0x71c0
jmp 0xc8e4
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x1b8(%rbp)
movl $0x10, %edi
callq 0x7270
movq %rax, -0x1b0(%rbp)
jmp 0xc84a
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x1c0(%rbp)
cmpq $0x0, %rax
je 0xc899
movq -0x1c0(%rbp), %rdi
leaq 0x3e1a8(%rip), %rsi     # 0x4aa28
leaq 0x3e269(%rip), %rdx     # 0x4aaf0
xorl %eax, %eax
movl %eax, %ecx
callq 0x7320
movq %rax, -0x1c8(%rbp)
jmp 0xc8a4
xorl %eax, %eax
movq %rax, -0x1c8(%rbp)
jmp 0xc8a4
movq -0x1b0(%rbp), %rdi
movq -0x1c8(%rbp), %rsi
callq 0xd2d0
movq -0x1b0(%rbp), %rax
movq -0x1b8(%rbp), %rdi
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
callq 0xd2a0
jmp 0xc8d4
jmp 0xc8d6
leaq -0x20(%rbp), %rdi
callq 0x27380
jmp 0xd146
leaq -0x20(%rbp), %rdi
callq 0x27380
jmp 0xd1fe
leaq -0x70(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x27840
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x1d0(%rbp)
cmpq $0x0, %rax
jne 0xc92d
callq 0x7300
jmp 0xc92d
movq -0x1d0(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3e27e(%rip), %rdi     # 0x4abc0
callq 0x9370
testb $0x1, %al
jne 0xc950
jmp 0xca31
movb $0x1, -0x92(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1e0(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x74f0
movq -0x1d8(%rbp), %rdx
leaq 0x2ae67(%rip), %rsi     # 0x377f0
leaq -0x90(%rbp), %rdi
callq 0x8940
jmp 0xc997
movq -0x1e0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x283d0
jmp 0xc9ac
movq -0x1e0(%rbp), %rdi
movb $0x0, -0x92(%rbp)
leaq 0x3d0bf(%rip), %rsi     # 0x49a80
leaq 0x1ba38(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xd207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xcaf3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xca09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x7170
leaq -0x91(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x92(%rbp)
jne 0xca20
jmp 0xca2c
movq -0x1e0(%rbp), %rdi
callq 0x71c0
jmp 0xcaf3
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x1f0(%rbp)
movl $0x10, %edi
callq 0x7270
movq %rax, -0x1e8(%rbp)
jmp 0xca53
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x1f8(%rbp)
cmpq $0x0, %rax
je 0xcaa2
movq -0x1f8(%rbp), %rdi
leaq 0x3df9f(%rip), %rsi     # 0x4aa28
leaq 0x3e130(%rip), %rdx     # 0x4abc0
xorl %eax, %eax
movl %eax, %ecx
callq 0x7320
movq %rax, -0x200(%rbp)
jmp 0xcaad
xorl %eax, %eax
movq %rax, -0x200(%rbp)
jmp 0xcaad
movq -0x1e8(%rbp), %rdi
movq -0x200(%rbp), %rsi
callq 0xd320
movq -0x1e8(%rbp), %rax
movq -0x1f0(%rbp), %rdi
movq %rax, -0xa0(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0xd2a0
jmp 0xcae3
jmp 0xcae5
leaq -0x70(%rbp), %rdi
callq 0x27880
jmp 0xd146
leaq -0x70(%rbp), %rdi
callq 0x27880
jmp 0xd1fe
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
callq 0x27d20
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x208(%rbp)
cmpq $0x0, %rax
jne 0xcb3e
callq 0x7300
jmp 0xcb3e
movq -0x208(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3e13d(%rip), %rdi     # 0x4ac90
callq 0x9370
testb $0x1, %al
jne 0xcb61
jmp 0xcc42
movb $0x1, -0xd2(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x218(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x74f0
movq -0x210(%rbp), %rdx
leaq 0x2ac92(%rip), %rsi     # 0x3782c
leaq -0xd0(%rbp), %rdi
callq 0x8940
jmp 0xcba8
movq -0x218(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x283d0
jmp 0xcbbd
movq -0x218(%rbp), %rdi
movb $0x0, -0xd2(%rbp)
leaq 0x3ceae(%rip), %rsi     # 0x49a80
leaq 0x1b827(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xd207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xcd07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xcc1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x7170
leaq -0xd1(%rbp), %rdi
callq 0x72e0
testb $0x1, -0xd2(%rbp)
jne 0xcc31
jmp 0xcc3d
movq -0x218(%rbp), %rdi
callq 0x71c0
jmp 0xcd07
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x228(%rbp)
movl $0x10, %edi
callq 0x7270
movq %rax, -0x220(%rbp)
jmp 0xcc64
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x230(%rbp)
cmpq $0x0, %rax
je 0xccb3
movq -0x230(%rbp), %rdi
leaq 0x3dd8e(%rip), %rsi     # 0x4aa28
leaq 0x3dfef(%rip), %rdx     # 0x4ac90
xorl %eax, %eax
movl %eax, %ecx
callq 0x7320
movq %rax, -0x238(%rbp)
jmp 0xccbe
xorl %eax, %eax
movq %rax, -0x238(%rbp)
jmp 0xccbe
movq -0x220(%rbp), %rdi
movq -0x238(%rbp), %rsi
callq 0xd370
movq -0x220(%rbp), %rax
movq -0x228(%rbp), %rdi
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0xd2a0
jmp 0xccf4
jmp 0xccf6
leaq -0xb0(%rbp), %rdi
callq 0x27d70
jmp 0xd146
leaq -0xb0(%rbp), %rdi
callq 0x27d70
jmp 0xd1fe
leaq -0xf0(%rbp), %rdi
movl $0x61, %esi
callq 0x28170
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x240(%rbp)
cmpq $0x0, %rax
jne 0xcd58
callq 0x7300
jmp 0xcd58
movq -0x240(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3dff3(%rip), %rdi     # 0x4ad60
callq 0x9370
testb $0x1, %al
jne 0xcd7b
jmp 0xce5c
movb $0x1, -0x112(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x250(%rbp)
leaq -0x111(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x74f0
movq -0x248(%rbp), %rdx
leaq 0x2aab7(%rip), %rsi     # 0x3786b
leaq -0x110(%rbp), %rdi
callq 0x8940
jmp 0xcdc2
movq -0x250(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x283d0
jmp 0xcdd7
movq -0x250(%rbp), %rdi
movb $0x0, -0x112(%rbp)
leaq 0x3cc94(%rip), %rsi     # 0x49a80
leaq 0x1b60d(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xd207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xcf21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xce34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x7170
leaq -0x111(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x112(%rbp)
jne 0xce4b
jmp 0xce57
movq -0x250(%rbp), %rdi
callq 0x71c0
jmp 0xcf21
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x260(%rbp)
movl $0x10, %edi
callq 0x7270
movq %rax, -0x258(%rbp)
jmp 0xce7e
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x268(%rbp)
cmpq $0x0, %rax
je 0xcecd
movq -0x268(%rbp), %rdi
leaq 0x3db74(%rip), %rsi     # 0x4aa28
leaq 0x3dea5(%rip), %rdx     # 0x4ad60
xorl %eax, %eax
movl %eax, %ecx
callq 0x7320
movq %rax, -0x270(%rbp)
jmp 0xced8
xorl %eax, %eax
movq %rax, -0x270(%rbp)
jmp 0xced8
movq -0x258(%rbp), %rdi
movq -0x270(%rbp), %rsi
callq 0xd3c0
movq -0x258(%rbp), %rax
movq -0x260(%rbp), %rdi
movq %rax, -0x120(%rbp)
leaq -0x120(%rbp), %rsi
callq 0xd2a0
jmp 0xcf0e
jmp 0xcf10
leaq -0xf0(%rbp), %rdi
callq 0x281b0
jmp 0xd146
leaq -0xf0(%rbp), %rdi
callq 0x281b0
jmp 0xd1fe
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
callq 0x26800
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x278(%rbp)
cmpq $0x0, %rax
jne 0xcf6f
callq 0x7300
jmp 0xcf6f
movq -0x278(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3d9d4(%rip), %rdi     # 0x4a958
callq 0x9370
testb $0x1, %al
jne 0xcf92
jmp 0xd073
movb $0x1, -0x152(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x288(%rbp)
leaq -0x151(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x74f0
movq -0x280(%rbp), %rdx
leaq 0x2a8e1(%rip), %rsi     # 0x378ac
leaq -0x150(%rbp), %rdi
callq 0x8940
jmp 0xcfd9
movq -0x288(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x283d0
jmp 0xcfee
movq -0x288(%rbp), %rdi
movb $0x0, -0x152(%rbp)
leaq 0x3ca7d(%rip), %rsi     # 0x49a80
leaq 0x1b3f6(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xd207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xd135
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xd04b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x7170
leaq -0x151(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x152(%rbp)
jne 0xd062
jmp 0xd06e
movq -0x288(%rbp), %rdi
callq 0x71c0
jmp 0xd135
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x298(%rbp)
movl $0x10, %edi
callq 0x7270
movq %rax, -0x290(%rbp)
jmp 0xd095
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x2a0(%rbp)
cmpq $0x0, %rax
je 0xd0e4
movq -0x2a0(%rbp), %rdi
leaq 0x3d95d(%rip), %rsi     # 0x4aa28
leaq 0x3d886(%rip), %rdx     # 0x4a958
xorl %eax, %eax
movl %eax, %ecx
callq 0x7320
movq %rax, -0x2a8(%rbp)
jmp 0xd0ef
xorl %eax, %eax
movq %rax, -0x2a8(%rbp)
jmp 0xd0ef
movq -0x290(%rbp), %rdi
movq -0x2a8(%rbp), %rsi
callq 0xd410
movq -0x290(%rbp), %rax
movq -0x298(%rbp), %rdi
movq %rax, -0x160(%rbp)
leaq -0x160(%rbp), %rsi
callq 0xd2a0
jmp 0xd125
jmp 0xd127
leaq -0x130(%rbp), %rdi
callq 0x26840
jmp 0xd146
leaq -0x130(%rbp), %rdi
callq 0x26840
jmp 0xd1fe
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %ecx
incl %ecx
movl %ecx, 0xb4(%rax)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x2b8(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x74f0
movq -0x2b0(%rbp), %rdx
leaq 0x2a763(%rip), %rsi     # 0x378eb
leaq -0x180(%rbp), %rdi
callq 0x8940
jmp 0xd196
movq -0x2b8(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x2c4d0
jmp 0xd1ab
leaq -0x180(%rbp), %rdi
callq 0x7170
leaq -0x181(%rbp), %rdi
callq 0x72e0
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xd1f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x7170
leaq -0x181(%rbp), %rdi
callq 0x72e0
movq -0x28(%rbp), %rdi
callq 0x74e0
nopw (%rax,%rax)