1. 11

Instead of jumping over a few bytes, you can make them parameters to some dummy operation, by creating overlapping machine code.

  1.  

  2. 3

    I knew that the x86 instruction set was a bit irregular, but I find this really disgusting. Not the hack itself, it’s a neat hack given the circumstances … but the circumstances.

    So there are some instructions that take up five bytes including operands, some that take up seven bytes … shudder

    1. 9

      Intel capped the instruction length of the x86 to 15 bytes. That’s not the worse offender though. The 68K family has one instruction that can be 22 bytes in length (MOVE from memory to memory, each argument using one of the more esoteric addressing modes). The VAX might win this though, as there is one instruction that can take 31 bytes to encode (ADDP6—add packed 6-operand) and another one that can take up to all available memory (CASEL [1]).

      And 5-byte instructions are not limited to 32-bit machines. My favorite 8-bit CPU, the 6809, also has a few 5-byte instructions (although most are two to three bytes).

      [1] The instruction takes four parameters, one of which is a table of displacements immediately following the instruction. Given that you can’t locate this table elsewhere is what makes me say this instruction is the longest encoded instruction on the VAX.

      1. 2

        I’ve worked on a machine that maxes at 28 bytes per instruction. It’s still shipping in consumer products

      2. 4

        Then I guess you’ve got to be disgusted by a lot of ISAs, looking at https://en.wikipedia.org/wiki/Comparison_of_instruction_set_architectures and how many of them have variable length instruction encoding.

        1. 1

          I expect you to be right about that. Some are worse than others, though.