注意事项- 汇编代码每行必须要以回车结尾
以回车结尾包括最后一行,否则as86会报错(这个错误提示真让人摸不着头脑)
as: error reading input- 关于加电后第一条指令地址
Intel手册上写了,上电后cpu加载的第一条指令的地址其实是0xFFFFFFF0,原文如下:
The address FFFFFFF0H is beyond the 1-MByte addressable range of the processor while in real-address mode. The
processor is initialized to this starting address as follows. The CS register has two parts: the visible segment
selector part and the hidden base address part. In real-address mode, the base address is normally formed by shifting the 16-bit segment selector value 4 bits to the left to produce a 20-bit base address. However, during a hardware reset, the segment selector in the CS register is loaded with F000H and the base address is loaded with FFFF0000H. The starting address is thus formed by adding the base address to the value in the EIP register (that
is, FFFF0000 + FFF0H = FFFFFFF0H).
只有在修改cs值后才会变成真正的实模式寻址 The first time the CS register is loaded with a new value after a hardware reset, the processor will follow the normal rule for address translation in real-address mode (that is, [CS base address = CS segment selector * 16]). To insure that the base address in the CS register remains unchanged until the EPROM based software-initialization code is completed, the code must not contain a far jump or far call or allow an interrupt to occur (which would cause the CS selector value to be changed).
总感觉还是没说明白,应该还有很多故事,有兴趣的可以挖一下。 参考文档- https://qemu.weilnetz.de/doc/qemu-doc.html
- 《linux内核完全剖析》
- Intel® 64 and IA-32 Architectures Software Developer’s Manual
|