Hi, this is an attempt to read the CR4 register into the A register (rax for 64 bit) on fedora 11 64 bit. The movq operation produces a segment fault.
Code:
typedef unsigned long long UINT64;
typedef union
{
UINT64 value;
struct
{
UINT64 VME0:1;
UINT64 PVI1:1;
UINT64 TSDB2:1;
UINT64 DE3:1;
UINT64 PSE4:1;
UINT64 PAE5:1;
UINT64 MCE6:1;
UINT64 PGE7:1;
UINT64 PCE8:1;
UINT64 OSFXSR9:1;
UINT64 OSXMMEXCPT10:1;
UINT64 bit1112:2; // reserved
UINT64 VMXE13:1;
UINT64 SMXE14:1;
UINT64 bit1517:3; // reserved
UINT64 OSXSAVE18:1;
UINT64 bit1931:13; // reserved
UINT64 bit3264:32; // reserved should be 0
}bits;
}CR4;
int main()
{
unsigned long long result;
//CR4 cr4_reg;
printf("\n size of long long is %x ", sizeof(result));
fflush(NULL);
__asm__("movq %%cr4, %%rax\n"
: "=a"(result) : "a"
);
printf("\n Value of CR4 = %x", result);
return 0;
}
Thanks for helping me out