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

			if(typeid(p) != typeid(*stack->fStore[stack->fSP]))
				throw ExecutionError("instruction str: element you are trying to access is not of type integer.");

			break;
		}	
		case real:
		{
			StackReal p;

			if(typeid(p) != typeid(*stack->fStore[stack->fSP]))
				throw ExecutionError("instruction str: element you are trying to access is not of type real.");


			break;
		}
		case boolean:
		{
			StackBoolean p;
			
			if(typeid(p) != typeid(*stack->fStore[stack->fSP]))
				throw ExecutionError("instruction str: element you are trying to access is not of type boolean.");

			break;
		}
		case character:
		{
			StackCharacter p;

			if(typeid(p) != typeid(*stack->fStore[stack->fSP]))
				throw ExecutionError("instruction str: element you are trying to access is not of type character.");

			break;
		}
		case address:
		{
			StackAddress p;
			
			if(typeid(p) != typeid(*stack->fStore[stack->fSP]))
				throw ExecutionError("instruction str: element you are trying to access is not of type address.");

			break;
		}
	}
	
	int newaddress = stack->base(fP, stack->fMP) + fQ;
	
	if((newaddress > stack->fSP) || (newaddress < 0))
		throw ExecutionError("instruction str: trying to access element above SP or < 0.");
	
	delete stack->fStore[newaddress];
	stack->fStore[newaddress] = stack->fStore[stack->fSP];
	stack->fStore.pop_back();
	
	--stack->fSP;
	
	// adding cost of this instruction
	stack->fTime.count("str");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0x17d36
leaq 0xe1fd(%rip), %rcx      # 0x25d44
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x50(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1aec8
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x18019
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1c046(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x17ba5
cmpb $0x2a, (%rdi)
je 0x17f5e
callq 0x6310
testl %eax, %eax
jne 0x17f5e
leaq -0x50(%rbp), %rdi
callq 0x1aef6
jmp 0x17d36
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a3d0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x1800a
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1bd7c(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x17c07
cmpb $0x2a, (%rdi)
je 0x17e50
callq 0x6310
testl %eax, %eax
jne 0x17e50
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0x17d36
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1b10c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x1800f
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1c052(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x17c69
cmpb $0x2a, (%rdi)
je 0x17eaa
callq 0x6310
testl %eax, %eax
jne 0x17eaa
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0x17d36
leaq -0x50(%rbp), %rdi
movl $0x61, %esi
callq 0x1b308
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x18014
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1c0bd(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x17cce
cmpb $0x2a, (%rdi)
je 0x17f04
callq 0x6310
testl %eax, %eax
jne 0x17f04
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0x17d36
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1aca0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x1801e
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1bdee(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x17d2d
cmpb $0x2a, (%rdi)
je 0x17fb5
callq 0x6310
testl %eax, %eax
jne 0x17fb5
leaq -0x50(%rbp), %rdi
callq 0x1acc4
movl 0xc(%r14), %esi
movl 0xc0(%rbx), %edx
movq %rbx, %rdi
callq 0x1d7fc
addl 0x10(%r14), %eax
cmpl 0xb4(%rbx), %eax
jg 0x17df6
testl %eax, %eax
js 0x17df6
movl %eax, %r15d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x17d85
movq %r14, %rdi
callq 0x1a5cc
movl $0x8, %esi
movq %r14, %rdi
callq 0x6210
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rdx
movq %rdx, (%rcx,%r15,8)
addq $-0x8, 0x20(%rbx)
decl %eax
movl %eax, 0xb4(%rbx)
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xe155(%rip), %rsi      # 0x25f09
leaq 0xe151(%rip), %rdx      # 0x25f0c
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 0x17de9
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 0xe0bb(%rip), %rsi      # 0x25ece
leaq 0xe0ee(%rip), %rdx      # 0x25f08
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x1ac4c(%rip), %rsi     # 0x32a88
leaq 0x35f3(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1800a
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xe017(%rip), %rsi      # 0x25e84
leaq 0xe059(%rip), %rdx      # 0x25ecd
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x1abf2(%rip), %rsi     # 0x32a88
leaq 0x3599(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1800a
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xdf27(%rip), %rsi      # 0x25dee
leaq 0xdf69(%rip), %rdx      # 0x25e37
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x1ab98(%rip), %rsi     # 0x32a88
leaq 0x353f(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1800a
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xdf17(%rip), %rsi      # 0x25e38
leaq 0xdf5b(%rip), %rdx      # 0x25e83
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x1ab3e(%rip), %rsi     # 0x32a88
leaq 0x34e5(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1800a
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xde2c(%rip), %rsi      # 0x25da7
leaq 0xde6b(%rip), %rdx      # 0x25ded
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x1aae4(%rip), %rsi     # 0x32a88
leaq 0x348b(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1800a
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xdd8b(%rip), %rsi      # 0x25d5d
leaq 0xddcd(%rip), %rdx      # 0x25da6
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x1aa8d(%rip), %rsi     # 0x32a88
leaq 0x3434(%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 0x1805d
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1805d
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x18079
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x18079
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x18126
movq %r14, %rdi
callq 0x6170
jmp 0x18126
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x18137
movq %r14, %rdi
callq 0x6170
jmp 0x18137
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x180af
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x180af
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x18145
movq %r14, %rdi
callq 0x6170
jmp 0x18145
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x180e5
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x180e5
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x18153
movq %r14, %rdi
callq 0x6170
jmp 0x18153
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x18114
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x18114
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x18161
movq %r14, %rdi
callq 0x6170
jmp 0x18161
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1acc4
jmp 0x181b8
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1aef6
jmp 0x181b8
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0x181b8
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0x181b8
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0x181b8
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x1818c
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1818c
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x181b8
movq %r14, %rdi
callq 0x6170
jmp 0x181b8
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x181b8
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x181b8
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410