// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0x14ffa
leaq 0xbec9(%rip), %rcx      # 0x20d44
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x30(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x177d4
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x150f2
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x19d12(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0x15194
leaq -0x30(%rbp), %rdi
callq 0x17802
jmp 0x14ffa
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0x1704c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x150e3
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x19a5e(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0x150fc
leaq -0x30(%rbp), %rdi
callq 0x17070
jmp 0x14ffa
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0x17a18
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x150e8
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x19d4a(%rip), %rdi     # 0x2ec98
callq 0x76ba
testb %al, %al
jne 0x15148
leaq -0x30(%rbp), %rdi
callq 0x17a3c
jmp 0x14ffa
leaq -0x30(%rbp), %rdi
pushq $0x61
popq %rsi
callq 0x17c08
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x150ed
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x19dcd(%rip), %rdi     # 0x2ed68
callq 0x76ba
testb %al, %al
jne 0x151e0
leaq -0x30(%rbp), %rdi
callq 0x17c2c
jmp 0x14ffa
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0x175ac
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x150f7
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x19b14(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0x15229
leaq -0x30(%rbp), %rdi
callq 0x175d0
movl 0xc(%r14), %esi
movl 0xc0(%rbx), %edx
movq %rbx, %rdi
callq 0x1995a
addl 0x10(%r14), %eax
cmpl 0xb4(%rbx), %eax
jg 0x15097
testl %eax, %eax
js 0x15097
movl %eax, %r15d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x15034
movq %r14, %rdi
callq 0x17248
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x61e0
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 0xbea3(%rip), %rsi      # 0x20f09
leaq -0x50(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x72a6
addq $0x78, %rbx
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x1925e
leaq -0x50(%rbp), %rdi
callq 0x60d0
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xbe25(%rip), %rsi      # 0x20ece
leaq -0x50(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x189b9(%rip), %rsi     # 0x2da88
leaq 0x2c44(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x15270
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xbd76(%rip), %rsi      # 0x20e84
leaq -0x50(%rbp), %rdi
leaq -0x19(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x18954(%rip), %rsi     # 0x2da88
leaq 0x2bdf(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x15270
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xbc94(%rip), %rsi      # 0x20dee
leaq -0x50(%rbp), %rdi
leaq -0x19(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x18908(%rip), %rsi     # 0x2da88
leaq 0x2b93(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x15270
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xbc01(%rip), %rsi      # 0x20da7
leaq -0x50(%rbp), %rdi
leaq -0x19(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x188bc(%rip), %rsi     # 0x2da88
leaq 0x2b47(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x15270
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xbc46(%rip), %rsi      # 0x20e38
leaq -0x50(%rbp), %rdi
leaq -0x19(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x18870(%rip), %rsi     # 0x2da88
leaq 0x2afb(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x15270
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xbb22(%rip), %rsi      # 0x20d5d
leaq -0x50(%rbp), %rdi
leaq -0x19(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x18827(%rip), %rsi     # 0x2da88
leaq 0x2ab2(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x15289
jmp 0x1531c
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x1531c
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x152af
jmp 0x15338
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x15338
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x152cf
jmp 0x1532a
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x1532a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x152ef
jmp 0x15346
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x15346
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x1530f
jmp 0x15354
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x15354
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x175d0
jmp 0x15390
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x17802
jmp 0x15390
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x17c2c
jmp 0x15390
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x17a3c
jmp 0x15390
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x17070
jmp 0x15390
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x15375
jmp 0x15390
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x15390
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x60d0
jmp 0x15390
movq %rax, %rbx
movq %rbx, %rdi
callq 0x63f0