since nasm 2.09 (tested 2.08 and it works like it should) instruction
add eax, dword 1
is translated to
add eax, byte1
According to the manual this should only happen on -O2.
Overriding with STRICT works, but manual says strict is only needed when using optimization. Has this changed since 2.09? No mention of it in the changelog.
It's that since nasm-2.08.02 where -Ox become a default parameter, so you need to run nasm with -O0 to disable optimization.
Sorry forgot to login when submitting.
Anyway, -O0 helps, but
1, manual says default is -O0
2, when I tell the assembler to use WORD 0x01 I expect it to listen, I mean this is assembly language and I need instructions to look like I want them to look. So if not listening to me is the default, the default is wrong.
If the manual (still) says -O0 is default, then please tell us where or even better submit a patch.
As far as WORD alone being insufficient, it is due to an ambiguity in instructions carrying only a memory operand; there is simply no way to disambiguate the size prefix used for operand size determination and the size prefix to select encoding in that case. STRICT addresses that ambiguity.
Okay I understand the ambiguity but still don't get having optimizations turned on by default.
Anyway the bug is in the manual pages, I have 2.09.08 Gentoo package and 'man nasm' still says:
-O number
Optimize branch offsets.
-O0 :No optimization (default)
-O1 :Minimal optimization
-Ox :Multipass optimization (recommended)
> As far as WORD alone being insufficient, it is due to an ambiguity in
> instructions carrying only a memory operand; there is simply no way to
> disambiguate the size prefix used for operand size determination and the
> size prefix to select encoding in that case.
qualifiers outside (before) the [...] --> operand size
qualifiers inside the [...] (i.e.after [) --> address size/type
instructions without [...] (i.e. no explicit mem op) --> use Axx/Oxx prefixes
Can you provide an example for what you have in mind?
> STRICT addresses that ambiguity.
I thought STRICT was added to prevent optimization?