1

I encounter several problems when I debug boot sector in bochs.

When debug a boot sector in bochs, bochs debugger first pause in the

(0) [0x0000fffffff0] f000:fff0 (unk. ctxt): jmpf 0xf000:e05b      ; ea5be000f0

Q1: Is this instruction jmpf 0xf000:e05b the jump instruction in this last 16 byte memory?

Q2: What instruction in address 0xf000:e05b?

Then we want to let code stop at address 0x7c00

<bochs:1> b 0x7c00
<bochs:2> c
(0) Breakpoint 1, 0x0000000000007c00 in ?? ()  
Next at t=61419250
(0) [0x000000007c00] 0000:7c00 (unk. ctxt): jmpf 0x07c0:0005   ; ea0500c007
<bochs:3> s                                   
Next at t=61419251
(0) [0x000000007c05] 07c0:0005 (unk. ctxt): mov ax, cs         ; 8cc8

These lines of code are generated by jmpi go,#0x7c00 go: move ax,cx.

Q3: instruction jmpi is translated into jmpf and machine code ea, is it right?

Q4: 0x0005 is the offset of label go. When does this offset computated? At link time?

ea0500c007 is the machine code of jmpf. ea is instruction, 07c0:0005 is the operand (because x86 is litten endian). This code is 5 bytes.

Q5: How CPU read this instruction and how PC calculate the size of this instruction? Does CPU encounter ea then read next 4 bytes as its operand?

4

1 回答 1

5

Q1-Q2。是的,这是复位后 CPU 开始执行的位置。是 ROM 中的代码跳转到 BIOS 启动代码。

Q3。不知道是什么jmpi,没有这样的指令。它可能是在别处定义的宏。它似乎产生了一个很大的跳跃。

Q4。如果它在同一个模块中,汇编器可能会为您计算出来。在更一般的情况下,链接器会这样做。

Q5。是的,cpu 解码操作码字节以找出它需要获取的操作数。当它看到它时,ea它知道使用接下来的 4 个字节作为跳转的目标(在 16 位模式下)。

于 2015-08-13T00:22:46.793 回答