Seg Fault with asm code.
807575Dec 31 2007 — edited Jan 13 2008Hi, I'm using Sun Stdio 12 with patch 126997-03 and have a strange problem with some assembly code that causes seg faults in CC if compiled with DEBUG but works fine when compiled with Performance Debug. I'm compiling for 64 bit on an AMD X2 with 64bit Suse10.
The code is:
void unpack(unsigned long b1, unsigned char ref) {
unsigned long mask = 0x0f0f0f0f0f0f0f0f;
asm ("movq %0, %xmm2" : : "m" (*b1): );
//asm ("movq %xmm2, %xmm3");
asm ("movq %0, %xmm1" : : "m" (mask));
asm ("movq %xmm2, %xmm3");
asm ("psrlw $04, %xmm2");
asm ("pand %xmm1, %xmm3");
asm ("pand %xmm1, %xmm2" : : :);
asm ("punpcklbw %xmm2, %xmm3");
asm ("movups %xmm3, %0" : "m" (*ref) :: );
}
int main(int argc, char** argv) {
unsigned char x[] = "ABVD";
unsigned long ul[2];
unpack(ul, x);
return (EXIT_SUCCESS);
}
I'm just learning this embedded asm and wonder if this might be my fault. Any help would be appreciated.
Thanks, Colin