JWasm generates reversed operands in mod-reg-r/m byte for XCHG reg,reg. The mod-reg-r/m byte should be generated the same as for other instructions with the same like MOV reg,reg or ADD reg,reg.
mov ah,al ;8AE0
add ah,al ;02E0
xchg ah,al ;86E0
mov al,ah ;8AC4
add al,ah ;02C4
xchg al,ah ;86C4
A similar problem happens with 32-bit SIB byte using two registers. By default index is first followed by base unless an explicit scale is used to force the index.
lea eax, ;8D041A - index is first then base
lea eax, ;8D0413
lea eax, ;8D0413 - scale forces index
lea eax, ;8D041A
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The "scale" issue is more work. Since it's not a true bug but just a (minor) incompatibility I'm a bit reluctant to make changes in this area. It's probably not worth the possible trouble.
japheth
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
JWasm generates reversed operands in mod-reg-r/m byte for XCHG reg,reg. The mod-reg-r/m byte should be generated the same as for other instructions with the same like MOV reg,reg or ADD reg,reg.
mov ah,al ;8AE0
add ah,al ;02E0
xchg ah,al ;86E0
mov al,ah ;8AC4
add al,ah ;02C4
xchg al,ah ;86C4
A similar problem happens with 32-bit SIB byte using two registers. By default index is first followed by base unless an explicit scale is used to force the index.
lea eax, ;8D041A - index is first then base
lea eax, ;8D0413
lea eax, ;8D0413 - scale forces index
lea eax, ;8D041A
the XCHG issue will be fixed in v2.02
The "scale" issue is more work. Since it's not a true bug but just a (minor) incompatibility I'm a bit reluctant to make changes in this area. It's probably not worth the possible trouble.
japheth
XCHG issue confirmed fixed in v2.02pre dated 12/28/09