0

I am trying to read debug registers on Linux, but I get an unsupported instruction mov error, when compiling my inline assembler code with gcc. My code is:

asm __volatile__ (
  "movl %eax, %dr0\n"
  );

Reading other registers such as esp works fine.

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
Mr.H
  • 1
  • 1
    src on left, dst on right in at&t syntax (your code would be writing to the register not reading it). The code is 32-bit, won't compile with 64-bit. But beyond that you really should look at [extended assembler templates](https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html) in GCC because you are going to have to properly get the value returned from a register and placed into an appropriate variable without clobbering anything. This is of course if you are mixing _C_ and assembly. – Michael Petch Apr 18 '16 at 15:25
  • 3
    Also note that the debug registers are privileged so you can't access them directly from user mode. – Jester Apr 18 '16 at 15:38
  • Thank you. Managed to solve the problem by adjusting it to 64bit and proper src/dst selection – Mr.H Apr 20 '16 at 09:29

0 Answers0