[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: why my program segmentation fault?



Star Liu 写道:
2008/7/14 shell909090 <shell909090@gmail.com>:
Star Liu 写道:
那么各位大侠,有什么办法可以读么?

PS: CPU手册上写的的确是第一条指令是在FFFFFFF0,然后near jump到FFFF0000,因为虽然是在实模式下,但是code
segment的地址被初始化为FFFF0000,而EIP的值被初始化为FFF0

是真的,我专门看Intel CPU手册的,
http://download.intel.com/design/processor/manuals/253668.pdf
chapter 9.1.4

9.1.4         First Instruction Executed
The first instruction that is fetched and executed following a hardware reset is
located at physical address FFFFFFF0H. This address is 16 bytes below the
processor's uppermost physical address. The EPROM containing the software-
initialization code must be located at this address.
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).
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).


首先纠正我刚刚话的一个错误,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。左位移是4位,不是8位。[CS base address = CS segment selector * 16] 很明显,写着话的家伙是昏头了。请看这句,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)。OK,大家算算,CS是F000H,左移4位,加 上FFFF0000H,算式应当是F0000H+FFFF0000H= 1000E0000H。后面那个算式怎么出 来的?


Reply to: