1

What's the difference between normal opcodes and opcodes with their MSB (Most Significant Bit) set?

Example:

0036  5E000001           [4] return     1   2
003A  1E008000           [5] return     0   1

The first opcode (0x5E/1011110) has its MSB set and the second opcode (0x1E/0011110) hasn't.

Edit: Corrected 'byte' to 'bit', duh.

Kara
  • 6,115
  • 16
  • 50
  • 57
lesderid
  • 3,388
  • 8
  • 39
  • 65

1 Answers1

1

After some googling, I found a header of the Lua source (lopcodes.h) explaining the instruction format a bit better.

It looks like it's wrong to read the opcode as a byte, it should be read as 6 bits:

All instructions have an opcode in the first 6 bits.
Instructions can have the following fields:
`A' : 8 bits
`B' : 9 bits
`C' : 9 bits
`Bx' : 18 bits (`B' and `C' together)
`sBx' : signed Bx
lesderid
  • 3,388
  • 8
  • 39
  • 65
  • Did you read this doc? http://luaforge.net/docman/view.php/83/98/ANoFrillsIntroToLua51VMInstructions.pdf – Alexander Gladysh Jul 25 '11 at 04:07
  • Yes, I did. It didn't really explain it though. Edit: I reread some parts and noticed this: "The details can be found in lopcodes.h, while the Instruction type definition is defined in llimits.h." – lesderid Jul 25 '11 at 09:14