关于CPU加电自检的时候CS:IP 的问题

2019-04-13 14:09发布

CPU加电的时候,CS被设置成F000h,于是段基址是FFFF0000h,闹不明白,查了下文档。 文档上的说法应该是这样的: 《IA-32 Intel Architecture Software Developer 's Manual》: In realaddress 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). CPU强行把CS的影子寄存器的base(descriptor的bit16 ~ bit38 + bit56 ~ bit63)设置成FFFF0000h,IP设置成FFF0h(eip = 0000FFF0h)。 在实模式下,cs的影子寄存器会被如此设置:base = cs << 4; limit = FFFFh。p,dpl,s,type,g,d/b等位根据是cs/ds/es/fs/gs 来设置(除了cs外其余段寄存器的base全部是0)。 这样的好处就是不用为实模式和保护模式分别设计电路,电路完全不用考虑实模式和保护模式的区别从来直接找出关键数据,提高了效率。 这样可以在16位段上使用32位偏移来工作,于是CS的影子寄存器的base 成了FFFF0000h之后,就可以寻址32位地址(big real mode),可以理解成一开机系统处于一种奇怪的保护模式之下。 个人理解,随便写点东西,不对了请果断喷一下。 另外这个月基本没敲代码,魔兽世界 S10赛季开始了忙活竞技场混分,另外收集各种坐骑还有各种武器,为4.3幻化做准备。不久前宿舍被翘了本本没了,我艹了 - -b