开发者

Setting processor to 32-bit mode

开发者 https://www.devze.com 2022-12-25 20:36 出处:网络
It seems that the following is a common method given in many tutorials on switching a processor from 16-bit to 32-bit:

It seems that the following is a common method given in many tutorials on switching a processor from 16-bit to 32-bit:

    mov     eax, cr0            ; set bit 0 in CR0-go to pmode
    or      eax, 1
    mov     cr0, eax

Why wouldn't I simply do the following:开发者_开发百科

    or      cr0, 1

Is there something I'm missing? Possibly the only thing I can think of is that I cannot perform an operation like this on the cr0 register.


The or operator doesn't have an op-code in which it can access the CR0 register. (It's not possible to perform this operation on the CR0 register.)

That's why the mov is there: there exists an op-code which can access the CR0 register.


or is a comparison operator where it actually takes two values and creates a solution. The solution is stored in eax after the or operation is completed. Or can not be used a a storage register as it is a specialized operation and is ruled by scope and that is why it is good practice to take its results and immediately store the new value right after the process completes.

Elaborating on what was said about using or with operands, it has no capacity for storage it merely performs an operation on data that id already present. Think of or like a button on a calculator where it has one operation like add, subtract, multiply or divide. The code is the calculator that manages the memory buffers; etc. and utilizes the services of an operator/operation on data within its memory stores and when finished gets the return results for further operations or finished output to the user.

The question here is a logical one as well as the code being well thought out and concise -- nice stuff.


Try this and force 1 to cr0 in 1 command:

MOV cr0, 1
0

精彩评论

暂无评论...
验证码 换一张
取 消