Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Seg Fault with asm code.

807575Dec 31 2007 — edited Jan 13 2008
Hi, 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2008
Added on Dec 31 2007
2 comments
175 views