Run trace command at startup

I have my own dream about programming my OS. While this will probably never be implemented, I suppose it can be fun and educated to at least achieve this goal. And I figured the best way to do it was to start by figuring out what my own computer was doing. To this end, I downloaded the RW-Everything program, which shows me what is in memory, and the AMD Processor Programmer's Reference Guide (all 5 volumes). My problem, in fact, is that what RW-Everything says that my computer really doesn't match what the manual should do. So I would like to know who or what is wrong.

According to the manual, the processor starts with FFFFFFF0. Instructions here

90 (nop) 90 (nop) E9 23 F6 (jmp around -09DD) which goes to FFFFFFF5 - 9DD = FFFFF618

Now in FFFFF618 instructions FA (cli) 30 C0 (xor al, al) E6 80 (out 80, al) 66 8B E0 (mov esp, eax) 66 8B EA (mov ebp, edx) 66 BB 80 FD FF FF (mov ebx, FFFFFD80) 66 2E 0F 01 17 (lgdt cs: [edi])

Now the problem is that the base cs address is still at the initial value of FFFF0000, and the edi is still at the initial value of 0. So the GDTR has to be loaded with 6 bytes starting at FFFF0000. But there is an FF sea at this location, which means that the base address of the GDT is set to FFFFFFFF, which is an extremely unlikely address where the GDT starts. So ... what gives? Am I wrong somewhere?

+3


source to share


1 answer


You figured out FFFFF618h and found the following instructions:

FA                (cli)
30 C0             (xor al, al)
E6 80             (out 80, al)
66 8B E0          (mov esp, eax)
66 8B EA          (mov ebp, edx)
66 BB 80 FD FF FF (mov ebx, FFFFFD80)
66 2E 0F 01 17    (lgdt cs:[edi])

      

Did I make a mistake somewhere?



Your last line is wrong. Since the CPU is still running in real address mode at runtime and the instruction was not encoded with an explicit address size prefix (byte 67h), the correct translation is:

lgdt [cs:bx]   ;An R/M field of 111 denotes [BX] in 16-bit addressing.

      

The register has now BX

been initialized to 0FD80h, so you should look there!

+1


source







All Articles