Home > Back-end >  What is the action of the GRPL instruction in the I386 instruction set?
What is the action of the GRPL instruction in the I386 instruction set?

Time:07-11

What is the action of the "Grpl" instruction in the I386 instruction set? I am learning about computer instruction and doing instruction simulation experiments. During the simulation I encountered such an instruction 83 F8 01.

To find out what to do with this instruction, I consulted opcode map screenshot

But I don't know what the GRPL means or what the CPU does. I checked the Intel 80386 Instruction Set and couldn't find a description of the Instruction. Instructions that begin with E are followed directly by instructions that begin with H. (enter and hlt)

I also looked up Google and couldn't find a description of the command. Not knowing the actual meaning of this instruction, I had no way to simulate it. How does the CPU implement this? What is the correct query? Do I miss something?

CodePudding user response:

What you read as "GRPL" is actually "Grp 1". It is not an instruction that the CPU executes. It's just a means to group related things together.

Looking up the 83h opcode, you see in the table mentioned "Ev, Ib".

The "A.1 Using opcode tables" chapter explains what these character combinations mean.

E --- A ModR/M byte follows the opcode and specifies the operand.
v --- Word or doubleword, depending on operand-size attribute.
, --- Litteraly a separating comma
I --- Immediate data: the operand value is encoded in subsequent bytes of the instruction.
b --- Byte, regardless of operand size attribute.

Your ModR/M byte is F8h or 11'111'000b in binary notation following the grouping 'mod-TTT-r/m'.

Because your instruction 83h belongs to Grp1, it's the bits 5, 4, and 3 of the ModR/M byte (111b) that inform you of the actual instruction. There's yet another table to look up just that, and you'll see that the instruction is cmp.
Because the 2 most significand bits (11b) are set in the ModR/M byte, the 3 least significand bits (000b) refer to a register. Triple zero means the accumulator, but which one AL, AX, or EAX?

For that we have to look at the opcode 83h or 100000'1'1b in binary notation following the grouping 'TTTTTT-s-w'.

Bit 0 (w) tells us this is a word-sized operation. AL is gone, AX or EAX remain.
Bit 1 (s) tells us that the immediate data that follows will be a byte that the CPU will sign-extend before using it in the word-sized operation.

Therefore the 3-byte instruction will be cmp ax, 1 or cmp eax, 1 depending on the mode of operation being real address mode or protected mode. Or vice-versa if the instruction was prefixed with an operand size prefix 66h.

CodePudding user response:

0x83 / GRP 1 (one) is the starting byte of a variable length instruction. The next byte 0xf8 would represent the end of the instruction specifying the register with an 8 bit immediate (0x01)

Decoding would then yield a compare of the EAX register against 1.

cmp eax,0x1
  • Related