// File: /workspace/github_cpp_makefile_star2_O3/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 0x17ad6
leaq 0xe45d(%rip), %rcx      # 0x25d44
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x50(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1abfc
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x17db3
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1c2a6(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x17945
cmpb $0x2a, (%rdi)
je 0x17cfa
callq 0x6310
testl %eax, %eax
jne 0x17cfa
leaq -0x50(%rbp), %rdi
callq 0x1ac2a
jmp 0x17ad6
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a104
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x17da4
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1bfdc(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x179a7
cmpb $0x2a, (%rdi)
je 0x17bef
callq 0x6310
testl %eax, %eax
jne 0x17bef
leaq -0x50(%rbp), %rdi
callq 0x1a128
jmp 0x17ad6
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1ae40
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x17da9
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1c2b2(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x17a09
cmpb $0x2a, (%rdi)
je 0x17c48
callq 0x6310
testl %eax, %eax
jne 0x17c48
leaq -0x50(%rbp), %rdi
callq 0x1ae64
jmp 0x17ad6
leaq -0x50(%rbp), %rdi
movl $0x61, %esi
callq 0x1b03c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x17dae
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1c31d(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x17a6e
cmpb $0x2a, (%rdi)
je 0x17ca1
callq 0x6310
testl %eax, %eax
jne 0x17ca1
leaq -0x50(%rbp), %rdi
callq 0x1b060
jmp 0x17ad6
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a9d4
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x17db8
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1c04e(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x17acd
cmpb $0x2a, (%rdi)
je 0x17d50
callq 0x6310
testl %eax, %eax
jne 0x17d50
leaq -0x50(%rbp), %rdi
callq 0x1a9f8
movl 0xc(%r14), %esi
movl 0xc0(%rbx), %edx
movq %rbx, %rdi
callq 0x1d550
addl 0x10(%r14), %eax
cmpl 0xb4(%rbx), %eax
jg 0x17b96
testl %eax, %eax
js 0x17b96
movl %eax, %r15d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x17b18
movq %r14, %rdi
callq 0x1a300
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 0xe3b5(%rip), %rsi      # 0x25f09
leaq 0xe3b1(%rip), %rdx      # 0x25f0c
leaq -0x40(%rbp), %rdi
callq 0x746c
addq $0x78, %rbx
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x1cbc8
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x17b89
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), %r15
movq %r15, -0x10(%r15)
leaq 0xe31c(%rip), %rsi      # 0x25ece
leaq 0xe34f(%rip), %rdx      # 0x25f08
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x1aead(%rip), %rsi     # 0x32a88
leaq 0x3588(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x17da4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xe279(%rip), %rsi      # 0x25e84
leaq 0xe2bb(%rip), %rdx      # 0x25ecd
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x1ae54(%rip), %rsi     # 0x32a88
leaq 0x352f(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x17da4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xe18a(%rip), %rsi      # 0x25dee
leaq 0xe1cc(%rip), %rdx      # 0x25e37
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x1adfb(%rip), %rsi     # 0x32a88
leaq 0x34d6(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x17da4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xe17b(%rip), %rsi      # 0x25e38
leaq 0xe1bf(%rip), %rdx      # 0x25e83
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x1ada2(%rip), %rsi     # 0x32a88
leaq 0x347d(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x17da4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xe091(%rip), %rsi      # 0x25da7
leaq 0xe0d0(%rip), %rdx      # 0x25ded
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x1ad49(%rip), %rsi     # 0x32a88
leaq 0x3424(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x17da4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xdff1(%rip), %rsi      # 0x25d5d
leaq 0xe033(%rip), %rdx      # 0x25da6
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x1acf3(%rip), %rsi     # 0x32a88
leaq 0x33ce(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x17dd5
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x17e04
jmp 0x17eab
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x17df7
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x17e14
jmp 0x17ebc
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x17eab
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x17ebc
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x17e39
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x17e46
jmp 0x17eca
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x17eca
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x17e68
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x17e72
jmp 0x17ed8
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x17ed8
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x17e94
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x17e9e
jmp 0x17ee6
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x17ee6
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a9f8
jmp 0x17f3a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1ac2a
jmp 0x17f3a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b060
jmp 0x17f3a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1ae64
jmp 0x17f3a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a128
jmp 0x17f3a
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x17f09
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x17f13
jmp 0x17f3a
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x17f3a
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x17f3a
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x17f3a
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410