将处理器设置为 32 位模式
似乎以下是许多关于将处理器从 16 位切换到 32 位的教程中给出的常见方法:
mov eax, cr0 ; set bit 0 in CR0-go to pmode
or eax, 1
mov cr0, eax
为什么我不简单地执行以下操作:
or cr0, 1
我缺少什么吗?可能我唯一能想到的是我不能在 cr0 寄存器上执行这样的操作。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
or
运算符没有可以访问 CR0 寄存器的操作码。 (不可能在 CR0 寄存器上执行此操作。)这就是
mov
存在的原因:存在可以访问 CR0 寄存器的操作码。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 是一个比较运算符,它实际上采用两个值并创建一个解决方案。或运算完成后,解存储在eax中。或者不能使用存储寄存器,因为它是专门的操作并且受范围支配,这就是为什么最好在过程完成后立即获取其结果并立即存储新值。
详细说明关于使用或操作数的内容,它没有存储能力,它只是对已经存在的数据执行操作。想象或像计算器上的一个按钮,它具有加、减、乘或除等一项操作。代码是管理内存缓冲区的计算器;等等,并利用对其内存存储中的数据进行操作/操作的服务,并在完成时获取返回结果以进行进一步的操作或完成向用户的输出。
这里的问题是一个合乎逻辑的问题,而且代码经过深思熟虑且简洁——很好的东西。
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.
试试这个并在 1 个命令中强制 1 到 cr0:
Try this and force 1 to cr0 in 1 command: