Question: I am using the following code to set the cr0 bit to disable cache.
When I compile this

```
#include <stdio.h>

int main()
{
        __asm__("pushl  %eax\n\t"
                "mov    %cr0,%eax;\n\t"
                "orl    $(1 << 30),%eax;\n\t"
                "mov    %eax,%cr0;\n\t"
                "wbinvd\n\t"
                "popl   %eax"
);

        return 0;
}

```

I am getting error saying that the operands are invalid for mov.

Can anyone please point me to a good gcc x86-64 guide for doing these kinds of things?
Also what exactly is wrong with the above code?

Answer: 
You cannot do operations like this from user code and even running as root is user code.

You will need to make this into a driver module and load it using insmod.
Try this:
 "mov %%cr0, %%eax \n"

A simple % is interpreted as user argument (I think).

You should read [this](http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html)