// File: zerolfx[P]P-Machine/sli.cpp
// Function: Sli::execute(StackMachine*)
void Sli::execute(StackMachine *stack)
{
	if(stack->fSP < 1)
		throw ExecutionError("instruction sli: requires 2 stackelements to be present.");

	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 sli: SP does not point to element of type integer.");

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

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

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

			break;
		}
		case address:
		{
			StackAddress p1;

			// check if constant is of type address
			if(typeid(p1) != typeid(*stack->fStore[stack->fSP]))
				throw ExecutionError("instruction sli: SP does not point to element of type address.");

			break;
		}
	}
	
	// actual operation
	delete stack->fStore[stack->fSP - 1];
	stack->fStore[stack->fSP - 1] = 0;
	stack->fStore[stack->fSP - 1] = stack->fStore[stack->fSP];
	stack->fStore.pop_back();
	
	// fSP = fSP - 1
	--stack->fSP;
	
	// adding cost of this instruction
	stack->fTime.count("sli");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0xb4(%rax)
jge 0x1fe67
movb $0x1, -0x45(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1a0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x74f0
movq -0x198(%rbp), %rdx
leaq 0x199eb(%rip), %rsi     # 0x397cd
leaq -0x30(%rbp), %rdi
callq 0x8940
jmp 0x1fded
movq -0x1a0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x283d0
jmp 0x1fdff
movq -0x1a0(%rbp), %rdi
movb $0x0, -0x45(%rbp)
leaq 0x29c6f(%rip), %rsi     # 0x49a80
leaq 0x85e8(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x206ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1fe45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x7170
leaq -0x31(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x45(%rbp)
jne 0x1fe56
jmp 0x1fe62
movq -0x1a0(%rbp), %rdi
callq 0x71c0
jmp 0x206c1
movq -0x190(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x1a8(%rbp)
subq $0x4, %rax
ja 0x2054a
movq -0x1a8(%rbp), %rax
leaq 0x19924(%rip), %rcx     # 0x397b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x58(%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, -0x1b0(%rbp)
cmpq $0x0, %rax
jne 0x1fed3
callq 0x7300
jmp 0x1fed3
movq -0x1b0(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2ac08(%rip), %rdi     # 0x4aaf0
callq 0x9370
testb $0x1, %al
jne 0x1fef6
jmp 0x1ffb9
movb $0x1, -0x7a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1c0(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x74f0
movq -0x1b8(%rbp), %rdx
leaq 0x198dd(%rip), %rsi     # 0x39806
leaq -0x78(%rbp), %rdi
callq 0x8940
jmp 0x1ff34
movq -0x1c0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x283d0
jmp 0x1ff46
movq -0x1c0(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
leaq 0x29b28(%rip), %rsi     # 0x49a80
leaq 0x84a1(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x206ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1ffc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1ff9a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x7170
leaq -0x79(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x7a(%rbp)
jne 0x1ffab
jmp 0x1ffb7
movq -0x1c0(%rbp), %rdi
callq 0x71c0
jmp 0x1ffc7
leaq -0x58(%rbp), %rdi
callq 0x27380
jmp 0x2054a
leaq -0x58(%rbp), %rdi
callq 0x27380
jmp 0x206c1
leaq -0x90(%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, -0x1c8(%rbp)
cmpq $0x0, %rax
jne 0x20013
callq 0x7300
jmp 0x20013
movq -0x1c8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2ab98(%rip), %rdi     # 0x4abc0
callq 0x9370
testb $0x1, %al
jne 0x20036
jmp 0x20111
movb $0x1, -0xb2(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1d8(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x74f0
movq -0x1d0(%rbp), %rdx
leaq 0x197d6(%rip), %rsi     # 0x39845
leaq -0xb0(%rbp), %rdi
callq 0x8940
jmp 0x2007d
movq -0x1d8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x283d0
jmp 0x20092
movq -0x1d8(%rbp), %rdi
movb $0x0, -0xb2(%rbp)
leaq 0x299d9(%rip), %rsi     # 0x49a80
leaq 0x8352(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x206ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20122
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x200ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x7170
leaq -0xb1(%rbp), %rdi
callq 0x72e0
testb $0x1, -0xb2(%rbp)
jne 0x20103
jmp 0x2010f
movq -0x1d8(%rbp), %rdi
callq 0x71c0
jmp 0x20122
leaq -0x90(%rbp), %rdi
callq 0x27880
jmp 0x2054a
leaq -0x90(%rbp), %rdi
callq 0x27880
jmp 0x206c1
leaq -0xc8(%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, -0x1e0(%rbp)
cmpq $0x0, %rax
jne 0x20170
callq 0x7300
jmp 0x20170
movq -0x1e0(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2ab0b(%rip), %rdi     # 0x4ac90
callq 0x9370
testb $0x1, %al
jne 0x20193
jmp 0x2026e
movb $0x1, -0xea(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1f0(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x74f0
movq -0x1e8(%rbp), %rdx
leaq 0x196b5(%rip), %rsi     # 0x39881
leaq -0xe8(%rbp), %rdi
callq 0x8940
jmp 0x201da
movq -0x1f0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x283d0
jmp 0x201ef
movq -0x1f0(%rbp), %rdi
movb $0x0, -0xea(%rbp)
leaq 0x2987c(%rip), %rsi     # 0x49a80
leaq 0x81f5(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x206ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2027f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20249
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x7170
leaq -0xe9(%rbp), %rdi
callq 0x72e0
testb $0x1, -0xea(%rbp)
jne 0x20260
jmp 0x2026c
movq -0x1f0(%rbp), %rdi
callq 0x71c0
jmp 0x2027f
leaq -0xc8(%rbp), %rdi
callq 0x27d70
jmp 0x2054a
leaq -0xc8(%rbp), %rdi
callq 0x27d70
jmp 0x206c1
leaq -0x100(%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, -0x1f8(%rbp)
cmpq $0x0, %rax
jne 0x202d0
callq 0x7300
jmp 0x202d0
movq -0x1f8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2aa7b(%rip), %rdi     # 0x4ad60
callq 0x9370
testb $0x1, %al
jne 0x202f3
jmp 0x203ce
movb $0x1, -0x122(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x208(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x74f0
movq -0x200(%rbp), %rdx
leaq 0x19594(%rip), %rsi     # 0x398c0
leaq -0x120(%rbp), %rdi
callq 0x8940
jmp 0x2033a
movq -0x208(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x283d0
jmp 0x2034f
movq -0x208(%rbp), %rdi
movb $0x0, -0x122(%rbp)
leaq 0x2971c(%rip), %rsi     # 0x49a80
leaq 0x8095(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x206ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x203df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x203a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x7170
leaq -0x121(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x122(%rbp)
jne 0x203c0
jmp 0x203cc
movq -0x208(%rbp), %rdi
callq 0x71c0
jmp 0x203df
leaq -0x100(%rbp), %rdi
callq 0x281b0
jmp 0x2054a
leaq -0x100(%rbp), %rdi
callq 0x281b0
jmp 0x206c1
leaq -0x138(%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, -0x210(%rbp)
cmpq $0x0, %rax
jne 0x2042d
callq 0x7300
jmp 0x2042d
movq -0x210(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2a516(%rip), %rdi     # 0x4a958
callq 0x9370
testb $0x1, %al
jne 0x20450
jmp 0x2052b
movb $0x1, -0x15a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x220(%rbp)
leaq -0x159(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x74f0
movq -0x218(%rbp), %rdx
leaq 0x19478(%rip), %rsi     # 0x39901
leaq -0x158(%rbp), %rdi
callq 0x8940
jmp 0x20497
movq -0x220(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x283d0
jmp 0x204ac
movq -0x220(%rbp), %rdi
movb $0x0, -0x15a(%rbp)
leaq 0x295bf(%rip), %rsi     # 0x49a80
leaq 0x7f38(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x206ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20539
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x20506
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x7170
leaq -0x159(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x15a(%rbp)
jne 0x2051d
jmp 0x20529
movq -0x220(%rbp), %rdi
callq 0x71c0
jmp 0x20539
leaq -0x138(%rbp), %rdi
callq 0x26840
jmp 0x2054a
leaq -0x138(%rbp), %rdi
callq 0x26840
jmp 0x206c1
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x228(%rbp)
cmpq $0x0, %rax
je 0x20594
movq -0x228(%rbp), %rdi
callq 0x26ca0
movq -0x228(%rbp), %rdi
movl $0x8, %esi
callq 0x7280
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl 0xb4(%rax), %eax
decl %eax
movslq %eax, %rsi
callq 0x8e70
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x240(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl 0xb4(%rax), %eax
decl %eax
movslq %eax, %rsi
callq 0x8e70
movq -0x240(%rbp), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
callq 0x8e90
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %ecx
decl %ecx
movl %ecx, 0xb4(%rax)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x238(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x74f0
movq -0x230(%rbp), %rdx
leaq 0x192f5(%rip), %rsi     # 0x39940
leaq -0x180(%rbp), %rdi
callq 0x8940
jmp 0x20659
movq -0x238(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x2c4d0
jmp 0x2066e
leaq -0x180(%rbp), %rdi
callq 0x7170
leaq -0x181(%rbp), %rdi
callq 0x72e0
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x206b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x7170
leaq -0x181(%rbp), %rdi
callq 0x72e0
movq -0x40(%rbp), %rdi
callq 0x74e0
nopw (%rax,%rax)