Menu

#545 implicit operand sizes optimized even with -O0

open-invalid
nobody
Assembler (85)
5
2011-08-02
2011-07-28
Anonymous
No

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.

Discussion

  • Nobody/Anonymous

    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.

     
  • Jaromir Smrcek

    Jaromir Smrcek - 2011-08-01

    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.

     
  • H. Peter Anvin

    H. Peter Anvin - 2011-08-01

    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.

     
  • H. Peter Anvin

    H. Peter Anvin - 2011-08-01
    • status: open --> closed-invalid
     
  • Jaromir Smrcek

    Jaromir Smrcek - 2011-08-02

    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)

     
  • Jaromir Smrcek

    Jaromir Smrcek - 2011-08-02
    • status: closed-invalid --> open-invalid
     
  • nasm64developer

    nasm64developer - 2011-08-04

    > 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?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.