These opcodes are "not used" on 8086/8088 according to this manual: [...] but the meaning of "not used" is unclear [...]
Err... what of 'not used' is unclear? For a CPU, its manual is holy scripture, to be taken word for word. If it says something then it must be. Assuming otherwise, even if it can be proven, is blasphemous.
Not each opcode combination possible does make sense. In this case they are simply not assigned to any functionality, because it would not make much sense for the basic 16 bit CPU. They are essentially duplicates.
The block 80..83 must be seen as one encoding case. The the basic opcode is 1000.00sw
, marking an ALU operation with
w
defining whether it's an 8 or 16 bit operation and
s
defining whether a sign extension is to be applied or not
83h is a bit special, as with a 16 bit target and a 16 bit immediate, a sign extension wouldn't make much sense, would it? So having both set (word and sign extension) marks a signed 8 bit immediate to follow instead of a 16 bit one.
- w=0; s=0 -> 8 bit target and 8 bit immediate
- w=0; s=1 -> 8 bit target and 8 bit immediate
- w=1; s=0 -> 16 bit target and 16 bit immediate
- w=1; s=1 -> 16 bit target and 8 bit immediate
The ALU operation to be used is specified in the second byte as xxxOOOxx
:
- 000 -> ADD
- 001 -> OR
- 010 -> ADC
- 011 -> SBB
- 100 -> AND
- 101 -> SUB
- 110 -> XOR
- 111 -> CMP
So, while sign extension does make much sense for arithmetic operation, it isn't as useful for logical operations.
No matter if it's about byte handling (82h, <op> rm8,i8
) or word handling (83h, <op> rm16,i16
) sign extension would be of no difference to non-sign-extending opcodes (80h/81h). They are simply the same operation.
There are two oddities here:
The whole 82h opcodes are kind of redundant with the 80h range. Only the 8086 manual marks them in that single table as explicit opcodes. Later manuals (186, 286) still list the S/W encoding for arithmetic immediate operations, but no longer list the 82h opcodes (or any unassigned opcode at all). The 386 manual also drops the entire description of the S/W encoding.
Why only the logic operation within 82/83h have been marked as unused in the 8086 manual can only be speculated. It's possible that the structure of the ALU simply didn't allow the use of sign extension and bit operations at the same time.
So, why were they introduced with the 80386?
For space reasons. Regardless of target size selected, 83h always uses an 8 bit immediate. While this is not a really big thing in an 8/16 bit environment, it becomes more useful when target size depends on modal operation - not to mention substantial space savings in 32 bit code, at least as long as operations are fine with only 7 usable bits.
XLAT with a segment override prefix: Manuals for 8086 and 80286 only mention that it uses the DS register. It was first mentioned in the 80386 manual that it accepts segment prefixes.
Oh, that's an easy one. The operand of XLAT
is not a memory location, which has a segment assigned, but the register AL
. One can't overwrite a non-existent segment. The ability to use a segment is simply an addition introduced with the 80386.
Does somebody have any information on what these instructions actually do on CPUs where they are undocumented (8086/8088/80286/NEC V20)?
Not really sure what that should be good for, as it's simply not defined.