At school, we used bootstrap to run stand-alone programs without an operating system. I studied this program, and when protected mode is enabled, there is a down-jump performed by directly compiling the operation code and operands as data in the program. This was for the GNU assembler:
/* this code immediately follows the setting of the PE flag in CR0 */
.byte 0x66, 0xEA .long TARGET_ADDRESS .word 0x0010 /* descriptor #2, GDT, RPL=0 */
code>
First of all, why do this (instead of the mnemonics command)?
I looked at Intel manuals, but I'm still a bit confused by the code. In particular, in Volume 2A, p. 3-549, there is a table of operation codes. Corresponding entry:
EA * cp * JMP ptr16: 32 Inv. Valid Jump far, absolute, address given in
operand
The actual operation code is obvious, but the first byte, 0x66, confuses me. Referring to the table in the Intel manual, cp obviously means that a 6-byte operand will follow. And, obviously, 6 bytes follow in the next two lines. 0x66 encodes the "operand override prefix". What does this have to do with cp in the table? I expected cp to have some kind of hex value, but there is an override prefix instead. Can someone clarify this for me?
Here is a dump from od:
c022 ** ea66 0000 0001 0010 ** ba52 03f2 c030
TARGET_ADDRESS has been defined as 0x00010000.
I am also a little confused by the value of the last two bytes. However, this seems to be another question. This happens quite late, and I have been looking at Intel code and manuals for several hours, so hopefully I have a point.
Thanks for watching!
assembly x86 gnu protected-mode opcode
Mr. Shickadance
source share