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

			// check if constant is of type integer
			if(typeid(p1) != typeid(*fConstant))
			{
				throw ExecutionError("instruction ldc: type of constant is not of type integer.");
			}
			else
			{
				stack->fStore.push_back(new StackInteger(*(dynamic_cast<StackInteger*>(fConstant))));
			}
				
			break;
		}	
		case real:
		{
			StackReal p1;
			// check if constant is of type real
			if(typeid(p1) != typeid(*fConstant))
			{
				throw ExecutionError("instruction ldc: type of constant is not of type real.");
			}
			else
			{
				stack->fStore.push_back(new StackReal(*(dynamic_cast<StackReal*>(fConstant))));
			}

			break;
		}
		case boolean:
		{
			StackBoolean p1;
			
			// check if constant is of type boolean
			if(typeid(p1) != typeid(*fConstant))
			{
				throw ExecutionError("instruction ldc: type of constant is not of type boolean.");
			}
			else
			{
				stack->fStore.push_back(new StackBoolean(*(dynamic_cast<StackBoolean*>(fConstant))));
			}

			break;
		}
		case character:
		{
			StackCharacter p1;
			
			// check if constant is of type character
			if(typeid(p1) != typeid(*fConstant))
			{
				throw ExecutionError("instruction ldc: type of constant is not of type character.");
			}
			else
			{
				stack->fStore.push_back(new StackCharacter(*(dynamic_cast<StackCharacter*>(fConstant))));
			}

			break;
		}
		case address:
		{
			StackAddress p1;

			// check if constant is of type address
			
			if(typeid(p1) != typeid(*fConstant))
			{
				throw ExecutionError("instruction ldc: type of constant is not of type address.");
			}
			else
			{
				stack->fStore.push_back(new StackAddress(*(dynamic_cast<StackAddress*>(fConstant))));
			}

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

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0xe9ab
movq %rdi, %r14
leaq 0x16011(%rip), %rcx     # 0x2467c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x50(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1aec8
movq 0x10(%r14), %r14
testq %r14, %r14
je 0xebcb
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x2552d(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xe6be
cmpb $0x2a, (%rdi)
je 0xeb10
callq 0x6310
testl %eax, %eax
jne 0xeb10
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x2535a(%rip), %rsi     # 0x33a30
leaq 0x254eb(%rip), %rdx     # 0x33bc8
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x25422(%rip), %rcx     # 0x33b10
addq $0x10, %rcx
movq %rcx, (%r15)
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa3ae
leaq -0x50(%rbp), %rdi
callq 0x1aef6
jmp 0xe9ab
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a3d0
movq 0x10(%r14), %r14
testq %r14, %r14
je 0xebbc
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x2521d(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xe766
cmpb $0x2a, (%rdi)
je 0xea02
callq 0x6310
testl %eax, %eax
jne 0xea02
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x252b2(%rip), %rsi     # 0x33a30
leaq 0x251db(%rip), %rdx     # 0x33960
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x25112(%rip), %rcx     # 0x338a8
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa3ae
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0xe9ab
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1b10c
movq 0x10(%r14), %r14
testq %r14, %r14
je 0xebc1
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x254b1(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xe80a
cmpb $0x2a, (%rdi)
je 0xea5c
callq 0x6310
testl %eax, %eax
jne 0xea5c
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x2520e(%rip), %rsi     # 0x33a30
leaq 0x2546f(%rip), %rdx     # 0x33c98
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x253a6(%rip), %rcx     # 0x33be0
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa3ae
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0xe9ab
leaq -0x50(%rbp), %rdi
movl $0x61, %esi
callq 0x1b308
movq 0x10(%r14), %r14
testq %r14, %r14
je 0xebc6
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x254da(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xe8b1
cmpb $0x2a, (%rdi)
je 0xeab6
callq 0x6310
testl %eax, %eax
jne 0xeab6
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x25167(%rip), %rsi     # 0x33a30
leaq 0x25498(%rip), %rdx     # 0x33d68
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x253cf(%rip), %rcx     # 0x33cb0
addq $0x10, %rcx
movq %rcx, (%r15)
movb 0x8(%rax), %al
movb %al, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa3ae
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0xe9ab
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1aca0
movq 0x10(%r14), %r14
testq %r14, %r14
je 0xebd0
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x251c6(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xe955
cmpb $0x2a, (%rdi)
je 0xeb67
callq 0x6310
testl %eax, %eax
jne 0xeb67
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x250c3(%rip), %rsi     # 0x33a30
leaq 0x25184(%rip), %rdx     # 0x33af8
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x250bb(%rip), %rcx     # 0x33a40
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa3ae
leaq -0x50(%rbp), %rdi
callq 0x1acc4
incl 0xb4(%rbx)
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x15df6(%rip), %rsi     # 0x247b6
leaq 0x15df2(%rip), %rdx     # 0x247b9
leaq -0x40(%rbp), %rdi
callq 0x746c
addq $0x78, %rbx
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x1ce78
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0xe9f5
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x15d5d(%rip), %rsi     # 0x2477c
leaq 0x15d8f(%rip), %rdx     # 0x247b5
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x24040(%rip), %rsi     # 0x32a88
leaq 0xc9e7(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xebbc
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x15c8d(%rip), %rsi     # 0x24706
leaq 0x15cbf(%rip), %rdx     # 0x2473f
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x23fe6(%rip), %rsi     # 0x32a88
leaq 0xc98d(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xebbc
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x15c6d(%rip), %rsi     # 0x24740
leaq 0x15ca1(%rip), %rdx     # 0x2477b
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x23f8c(%rip), %rsi     # 0x32a88
leaq 0xc933(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xebbc
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x15ba2(%rip), %rsi     # 0x246cf
leaq 0x15bd1(%rip), %rdx     # 0x24705
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x23f32(%rip), %rsi     # 0x32a88
leaq 0xc8d9(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xebbc
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x15b11(%rip), %rsi     # 0x24695
leaq 0x15b43(%rip), %rdx     # 0x246ce
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x23edb(%rip), %rsi     # 0x32a88
leaq 0xc882(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xec0f
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xec0f
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xec2b
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xec2b
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xece2
movq %r14, %rdi
callq 0x6170
jmp 0xece2
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xecf0
movq %r14, %rdi
callq 0x6170
jmp 0xecf0
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xec61
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xec61
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xecfe
movq %r14, %rdi
callq 0x6170
jmp 0xecfe
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xec97
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xec97
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xed0c
movq %r14, %rdi
callq 0x6170
jmp 0xed0c
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xecc6
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xecc6
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xed1a
movq %r14, %rdi
callq 0x6170
jmp 0xed1a
jmp 0xecdf
jmp 0xeced
jmp 0xecfb
jmp 0xed09
jmp 0xed17
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1acc4
jmp 0xed42
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1aef6
jmp 0xed42
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0xed42
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0xed42
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0xed42
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0xed42
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xed42
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410