Barebit / x86reference

X86 Opcode and Instruction Reference
http://ref.x86asm.net
GNU Lesser General Public License v3.0
238 stars 54 forks source link

LOOP use wrong operand types #42

Closed Kashio closed 5 months ago

Kashio commented 1 year ago

Right now LOOPNZ, LOOPNE, LOOPZ, LOOPE, LOOP encoded with opcodes E0-E2 use operand type bs for its operand of addressing J which is defined as:

Byte, sign-extended to the size of the destination operand.

The problem is that the immediate is always sign extended to the size of the stack pointer, the address size prefix can only determine what register is used as the counter (eCX or rCX) and not the size of the immediate which is the relative address to jump to which is to be extended to the size of the stack pointer. Therefore the most appropriate operand type for these should be bss:

Byte, sign-extended to the size of the stack pointer (for example, PUSH (6A)).

mazegen commented 1 year ago

Explained in #44.