在grub2的文件acinclude.m4文件中有这样两段话:
Older versions of GAS interpret “.code16” to mean “generate 32-bit instructions, but implicitly insert addr32 and data32 bytes so that the code works in real mode”.
Newer versions of GAS interpret “.code16” to mean “generate 16-bit instructions”, which seems right. This requires the programmer to explicitly insert addr32 and data32 instructions when they want them.
这两段话的中文意思是:
旧版本的GAS把”.code16”解释为“生成32位指令,但是隐式地插入addr32(Address-Size Prefix 67H)和data32(Operand-Size Prefix 66H)指令来使代码工作在实模式下”。
新版本得GAS把”.code16”解释为“生成看似正确的16位指令”。这要求,当程序员想要使用32位得地址或是数据时,自己显示地插入addr32和data32指令。
示例如下:
.code16
l1:
addr32 movb %al, l1