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?