// File: mlugo2[P]SunshineGPU/src/gpu.cpp
// Function: gpu::mov_instr(unsigned long long)
void gpu::mov_instr(u64 instr)
{

	u128 temp;

	// Determine destination and source paths
	u8 dest = get_dest_type(instr);
	u8 destIndex = get_dest_index(instr);
	u8 destW = get_dest_w(instr);
	u8 destZ = get_dest_z(instr);
	u8 destY = get_dest_y(instr);
	u8 destX = get_dest_x(instr);

	u8 src = get_srcN_type(instr, 0);
	u8 srcIndex = get_srcN_index(instr, 0);
	u8 srcW = get_srcN_w(instr, 0);
	u8 srcZ = get_srcN_z(instr, 0);
	u8 srcY = get_srcN_y(instr, 0);
	u8 srcX = get_srcN_x(instr, 0);

	// Swizzle it
	temp = swizzle(main_mem[src][srcIndex], srcW, srcZ, srcY, srcX);

	// Negate it
	if (get_srcN_neg(instr, 0))
	{
		temp.x = -temp.x;
		temp.y = -temp.y;
		temp.z = -temp.z;
		temp.w = -temp.w;
	}

	// Bop it..
	if ( dest == TEMP_REG )
	{
		if (destW) main_mem[dest][destIndex].w = temp.w;
		if (destZ) main_mem[dest][destIndex].z = temp.z;
		if (destY) main_mem[dest][destIndex].y = temp.y;
		if (destX) main_mem[dest][destIndex].x = temp.x;
	}
	else
	{
		if (destW) VOB[destIndex].w = temp.w;
		if (destZ) VOB[destIndex].z = temp.z;
		if (destY) VOB[destIndex].y = temp.y;
		if (destX) VOB[destIndex].x = temp.x;
	}

}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x14ac0
movq 0x8(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x13c50
movq 0x8(%rsp), %rdi
movb %al, 0x47(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13c90
movq 0x8(%rsp), %rdi
movb %al, 0x46(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13cd0
movq 0x8(%rsp), %rdi
movb %al, 0x45(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13d10
movq 0x8(%rsp), %rdi
movb %al, 0x44(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13d50
movq 0x8(%rsp), %rdi
movb %al, 0x43(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13d90
movq 0x8(%rsp), %rdi
movb %al, 0x42(%rsp)
movq 0x58(%rsp), %rsi
xorl %edx, %edx
movl %edx, 0x4(%rsp)
callq 0x13e30
movl 0x4(%rsp), %edx
movq 0x8(%rsp), %rdi
movb %al, 0x41(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13e90
movl 0x4(%rsp), %edx
movq 0x8(%rsp), %rdi
movb %al, 0x40(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13ef0
movl 0x4(%rsp), %edx
movq 0x8(%rsp), %rdi
movb %al, 0x3f(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13f50
movl 0x4(%rsp), %edx
movq 0x8(%rsp), %rdi
movb %al, 0x3e(%rsp)
movq 0x58(%rsp), %rsi
callq 0x13fb0
movl 0x4(%rsp), %edx
movq 0x8(%rsp), %rdi
movb %al, 0x3d(%rsp)
movq 0x58(%rsp), %rsi
callq 0x14010
movq 0x8(%rsp), %rdi
movb %al, 0x3c(%rsp)
movzbl 0x41(%rsp), %eax
shll $0x8, %eax
movq %rdi, %rcx
addq %rax, %rcx
movzbl 0x40(%rsp), %eax
shll $0x4, %eax
movups 0x7d6c0(%rax,%rcx), %xmm0
movaps %xmm0, 0x10(%rsp)
movzbl 0x3f(%rsp), %esi
movzbl 0x3e(%rsp), %edx
movzbl 0x3d(%rsp), %ecx
movzbl 0x3c(%rsp), %r8d
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
callq 0x14840
movq 0x8(%rsp), %rdi
movlpd %xmm0, 0x2c(%rsp)
movlpd %xmm1, 0x34(%rsp)
movq 0x2c(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x34(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rsi
xorl %edx, %edx
callq 0x13dd0
cmpb $0x0, %al
je 0xd787
movss 0x54(%rsp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, 0x54(%rsp)
movss 0x50(%rsp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, 0x50(%rsp)
movss 0x4c(%rsp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, 0x4c(%rsp)
movss 0x48(%rsp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, 0x48(%rsp)
movzbl 0x47(%rsp), %eax
cmpl $0x0, %eax
jne 0xd86d
cmpb $0x0, 0x45(%rsp)
je 0xd7c9
movq 0x8(%rsp), %rax
movss 0x48(%rsp), %xmm0
addq $0x7d6c0, %rax          # imm = 0x7D6C0
movzbl 0x47(%rsp), %ecx
shlq $0x8, %rcx
addq %rcx, %rax
movzbl 0x46(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
cmpb $0x0, 0x44(%rsp)
je 0xd7fe
movq 0x8(%rsp), %rax
movss 0x4c(%rsp), %xmm0
addq $0x7d6c0, %rax          # imm = 0x7D6C0
movzbl 0x47(%rsp), %ecx
shlq $0x8, %rcx
addq %rcx, %rax
movzbl 0x46(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
cmpb $0x0, 0x43(%rsp)
je 0xd833
movq 0x8(%rsp), %rax
movss 0x50(%rsp), %xmm0
addq $0x7d6c0, %rax          # imm = 0x7D6C0
movzbl 0x47(%rsp), %ecx
shlq $0x8, %rcx
addq %rcx, %rax
movzbl 0x46(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
cmpb $0x0, 0x42(%rsp)
je 0xd868
movq 0x8(%rsp), %rax
movss 0x54(%rsp), %xmm0
addq $0x7d6c0, %rax          # imm = 0x7D6C0
movzbl 0x47(%rsp), %ecx
shlq $0x8, %rcx
addq %rcx, %rax
movzbl 0x46(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movss %xmm0, 0xc(%rax)
jmp 0xd912
cmpb $0x0, 0x45(%rsp)
je 0xd895
movq 0x8(%rsp), %rax
movss 0x48(%rsp), %xmm0
addq $0x7dec0, %rax          # imm = 0x7DEC0
movzbl 0x46(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
cmpb $0x0, 0x44(%rsp)
je 0xd8be
movq 0x8(%rsp), %rax
movss 0x4c(%rsp), %xmm0
addq $0x7dec0, %rax          # imm = 0x7DEC0
movzbl 0x46(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
cmpb $0x0, 0x43(%rsp)
je 0xd8e7
movq 0x8(%rsp), %rax
movss 0x50(%rsp), %xmm0
addq $0x7dec0, %rax          # imm = 0x7DEC0
movzbl 0x46(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
cmpb $0x0, 0x42(%rsp)
je 0xd910
movq 0x8(%rsp), %rax
movss 0x54(%rsp), %xmm0
addq $0x7dec0, %rax          # imm = 0x7DEC0
movzbl 0x46(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movss %xmm0, 0xc(%rax)
jmp 0xd912
addq $0x68, %rsp
retq
nopw (%rax,%rax)