Author Topic: can I get cr3's value like this?  (Read 21757 times)

Offline junior_study

  • Jr. Member
  • *
  • Posts: 4
can I get cr3's value like this?
« on: July 21, 2012, 01:59:13 PM »
hi:

       this instruction   ?   movl  %cr3  ,  %eax   
       can  this indtruction  load  cr3's value into  eax?

thank you!

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: can I get cr3's value like this?
« Reply #1 on: July 21, 2012, 05:07:02 PM »
No, not in Nasm syntax. Try:
Code: [Select]
mov eax, cr3
... and not in user mode in a protected OS. A "mov" into or out of a control register is a "privileged instruction" - won't work in ring 3. From "real real-mode dos" (or "write my own OS mode", yes. Probably not meaningful until you've loaded something into it... and not effective until you've enabled paging (bit 31 in cr0, I think). Possibly in a kernel module...

You probably want to study the Intel/AMD manual(s), and/or http://www.sandpile.org and/or http://www.osdev.org More of a "senior study", I think. :)

Best,
Frank