On Tue, Apr 22, 2003 at 12:17:08PM +0500, dkotian3@vsnl.net wrote:
I checked the pentium manuals, could not find any reference to these statements as listed below.
andl $0x7FFAFFD1, %eax /* PG,AM,WP,NE,TS,EM,MP = 0 */ orl $0x60000001, %eax /* CD, NW, PE = 1 */
The syntax for and is reverse and <register> <immediate value> Whereas the code reads andl <immediate value> <register>
Could someone please help me on this or redirect to exact reference for the above statements.
Hi.
The two instructions you quote are taken out of context and are by themselves completely meaningless.
They are mere bit operations on registers: andl performs a bitwise AND of a register (the eax register, in this case) and the 0x7ffaffd1 immediate value, and stores the result back into the register. orl performs a bitwise OR of a register (again eax) and the 0x60000001 immediate value, and stores the result back into eax.
Before these two instructions I'm guessing that there is a line reading mov %eax, cr0
and following them, there is a line reading mov cr0, %eax
(cr0 above may also be %cr0, I'm more familiar with intel assembly syntax.)
Now, this puts the bit mangling in a totally different perspective. cr0 is the Configuration Register 0, which among other things contains the PE bit, as indicated by the comment following the or instruction. PE controls whether the CPU is in protected mode or not.
To connect the dots for you, your two instructions combined with my two instructions will set a number of different flags in cr0, among other things switching the CPU to protected mode if not already in it.
Hope this helps, and gives a few pointers.
//Peter