是否可以在实模式下使用 32 位寄存器/指令? [英] Is it possible to use 32 bits registers/instructions in real mode?

查看:24
本文介绍了是否可以在实模式下使用 32 位寄存器/指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在研究一些简单的os源代码时,我对一个简单的汇编问题感到困惑.

I'm confused about a simple assembly problem when studying some simple os source code.

在这个网站:http://wiki.osdev.org/Babystep7下面的代码是从实模式切换到保护模式

In this website: http://wiki.osdev.org/Babystep7 the following code is to switch from real mode to protected mode

mov  eax, cr0
or al,1
mov  cr0, eax

我知道如何从实模式切换到保护模式.
但我的问题是,既然程序还在实模式下,怎么能用32位的寄存器或指令呢?

I know how to switch from real mode to protected mode.
But my question is since the program is still in the real mode, how can it use the 32 bit registers or instructions?

是否可以在实模式下使用 32 位寄存器/指令?

Is it possible to use 32 bits registers/instructions in real mode?

推荐答案

当处理器在实模式下运行时(因为它是在启动后立即运行的),它默认为 16 位代码.但是,这意味着您无法使用 32 位指令.

When the processor operates in real mode (as it is immediately after booting), it defaults to 16-bit code. However, this does not mean that you are unable to use 32-bit instructions.

有一个操作数大小覆盖"前缀 (66h) 可以更改单个指令的默认模式.当此前缀与在 16 位实模式下执行的指令一起使用时,它会将指令切换到 32 位.相反,当此前缀与在 32 位保护模式下执行的指令一起使用时,它会将指令切换为 16 位.(类似的前缀 67h 用于覆盖地址大小.)

There is an "operand size override" prefix (66h) that changes the default mode for a single instruction. When this prefix is used with an instruction executed in 16-bit real mode, it will switch the instruction to 32-bit. Conversely, when this prefix is used with an instruction executed in 32-bit protected mode, it will switch the instruction to 16 bit. (A similar prefix, 67h, works to override address sizes.)

然后,使用此前缀允许您在 16 位实模式下使用 32 位寄存器.当您在汇编 16 位代码时尝试将 32 位操作数与指令一起使用时,您的汇编器几乎肯定会自动发出此前缀.

Using this prefix, then, allows you to use 32-bit registers in 16-bit real mode. Your assembler will almost certainly emit this prefix automatically when you try and use 32-bit operands with an instruction when assembling 16-bit code.

不幸的是,64 位指令没有这样的覆盖前缀,所以这些不能在实模式下使用.您需要切换到长模式"才能允许这些.

Unfortunately, there is no such override prefix for 64-bit instructions, so these cannot be used in real mode. You need to switch into "long mode" to allow these.

这篇关于是否可以在实模式下使用 32 位寄存器/指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆