![]() |
| | #1 |
| Registered User Join Date: Jun 2008
Posts: 19
| Inline GCC Help with reading CR4 register 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;
}
|
| raghu2383 is offline | |
| | #2 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| Have you examined the generated code to ensure that the instruction is being assembled as you expect? If it looks correct, then the only reason you'd get a segfault would be that access to the CR4 register is a privileged operation. I don't remember off the top of my head if that's the case.
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot |
| brewbuck is offline | |
| | #3 |
| Registered User Join Date: Jun 2008
Posts: 19
| Yes, you are right, I figured it later on after much sweating. It cannot be accessed from an application and can be accessed through the kernel. thanks for the reply |
| raghu2383 is offline | |
![]() |
| Tags |
| c programming, inline assembly, linux |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading a 16 bit Register | Bladactania | C Programming | 7 | 07-04-2009 03:15 PM |
| brace-enclosed error | jdc18 | C++ Programming | 53 | 05-03-2007 05:49 PM |
| gcc inline asm: illegal instruction (core dump) | Sargnagel | C Programming | 4 | 10-28-2003 01:41 PM |
| register variables | Draco | C Programming | 7 | 08-21-2002 01:01 PM |
| Register | sean345 | C Programming | 7 | 05-08-2002 03:06 PM |