I was working with HotBasic, which has its own built-in Assembler. I found it did not make a distinction between words and dwords, although
it is suppose to. A number of inquiries through the HotBasic Group finally resulted in a programmer telling me that a mnemonic like movsd
consisted on one byte, and for movsw a prefix of 66h was inserted. I later confirmed this is true, for the most part. What varies is if the
instruction defaults to 16 bits, in which case the 66h changes it to 32 bits. If the default is to 32 bits, the 66h changes it to 16 bits.
Unless you know the default state of an instruction, it's hard to judge if a 66h prefix is needed or not. You pretty much have to depend on the
Assembler to make the choice for you. Except with the HotBasic built-in assember, that doesn't handle the problem at all. You need to find
out somewhere else and come back and do a asm db 66h if needed before the mnemonic.
So , to find out on an instruction by instruction basis, I rigged up a simploe program in HotBasic to use three Assemblers to find out what all
three recommend. NASM and FASM usually agree, but are 180 degrees out from what MASM32 recommends. However, MASM32 is told that
it is to use .486, meaning its default is 32 bits, not 16 bits. At least I think that is why the difference right now.
But I have a case where Nasm apparently makes a serious mistake. Here is a copy-and-paste from a running instance of my program:
Enter an 80x86 instruction mnemonic to convert: add eax,1
ml.exe says "add eax,1" translates to " 83 C0 01 "
nasm.exe says "add eax,1" translates to " 66 05 01 00 00 00 "
fasm.exe says "add eax,1" translates to " 66 83 C0 01 "
Note that ml.exe (Masm32) and Fasm only differ by whether the 66h prefix byte is required. The rest of the instruction is a match. But
Nasm does something quite different, and according to one follower of my post on the PureBasic forums, the instruction of "66 05 01 00 00 00" is invalid, causes an error on execution. Thought I would pass this along.