Dear All, 
I have a problem with the following simple code when use Sun Studio C 12 upd. 1:

-------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>


void my_cpuid(uint32_t toAX, uint32_t * myEAX, uint32_t * myEBX, uint32_t * 
myECX, uint32_t * myEDX)
{

#define CPUID   ".byte 0x0f, 0xa2; "
 __asm__ __volatile__ ("mov %%rbx, %%rsi\n\t"
                       CPUID"\n\t"
                       "xchg %%rsi, %%rbx\n\t"
                       : "=a" (*myEAX), "=S" (*myEBX), "=c" (*myECX), "=d" 
(*myEDX)
                       : "a" (toAX)); 
}


int main(void)
{ 
uint32_t myEAX=0, myEBX=0, myECX=0, myEDX=0; 
uint32_t reg[4]; 
char vendor[100]; 
 
 my_cpuid(0, &myEAX, &myEBX, &myECX, &myEDX); 

 reg[0] = myEBX; 
 reg[1] = myEDX; 
 reg[2] = myECX; 
 reg[3] = 0; 
 strcpy(vendor, (char*)reg); 
 printf("%s\n", vendor); 

 return(0); 
}
-------------------------

When I use gcc-4.3.2, it prints "GenuineIntel" as expected on my Intel CPU.
But when I use SunStudio 12 upd. 1, it prints nothing.

Here are the compile commands:
gcc-4.3.2 -m64 -march=core2 test.c
and
cc -m64 -xarch=sse4_1 -xchip=core2 test.c

My OS and CPU are OpenSolaris 2009.06 and Intel Core2 Quad.

This is a pretty standard code. What can be wrong with it?

It should be also noted that if I place _asm_ code directly into the main 
function then everything works fine.
-- 
This message posted from opensolaris.org

Reply via email to