Menu

#3330 ASM warnings

closed-fixed
nobody
None
other
5
2022-03-10
2022-02-24
No

I use this SDCC version
C:\Users\ragozini_a\Documents\SDCC\bin>sdcc -v
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502/mos65c02 4.1.14 #12979 (MINGW64)
published under GNU General Public License (GPL)

I get this kind of warnings while mixing ASM and C

mytest.c:1249: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
'.rept 2'

mytest.c:1249: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
'outi'

mytest.c:1249: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
'.endm'

mytest.c:1258: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
'.endm'

mytest.c:1258: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
'.rept 16'

Related

Patches: #428
Commit: [542b76]

Discussion

  • Philipp Klaus Krause

    The outi will be easy to fix. Not sure about the macro stuff.
    Anyway, the bug will not result in bad code; the worst that can happen is that SDCC uses a few jp where it could have used jr instead.

     
  • Ragozini Arturo

    Ragozini Arturo - 2022-02-24

    In case of need, you can find in attach the whole files generating the warning and the bat file used to run the compiler

     
  • Ragozini Arturo

    Ragozini Arturo - 2022-02-24

    The .h files included are here, but to have a full working binary you need the specific LIB files
    Let me know if you need a complete project

     
  • Sebastian Riedel

    Related to [#3310] and others.
    We currently focus on the mnemonics emitted by sdcc, since peephole rules do not officially support inline assembly.
    But it’s probably better to support as much as possible of the syntax accepted by sdasz80.
    It’s different with general syntax of sdas, since that would need to be handled at a central point. Including simpler directives like .strz might be possible. But with .rept it starts to get complicated, we would need more asm interpretation then is done currently. It can be nested and .endm also ends other macro blocks, which again could be nested inside .rept.

    Minimal reproduction code should be: (not working code)

    //sdcc -mz80 -S bug3330.c
    
    unsigned char func(unsigned char a){
      if(a != 0){
        __asm
          .rept #16
          outi
          .endm
        __endasm;
      }
      return 42;
    }
    
    void main(void){
      func(1);
    }
    
     

    Related

    Bugs: #3310


    Last edit: Maarten Brock 2022-03-07
  • Ragozini Arturo

    Ragozini Arturo - 2022-03-07

    I'm getting the same warning also in these cases:
    src\mytestrom.c:152: warning 158: overflow in implicit constant conversion
    src\mytestrom.c:873: warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
    src\mytestrom.c:914: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
    '.include "data\metadatamap.asm"'

    src\mytestrom.c:967: warning 158: overflow in implicit constant conversion
    src\mytestrom.c:1118: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
    '.rept 2'

    src\mytestrom.c:1118: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
    'outi'

    src\mytestrom.c:1118: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
    '.endm'

    src\mytestrom.c:1127: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
    '.endm'

    src\mytestrom.c:1127: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
    '.rept 16'

    src\intro.c:20: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes
    'b_intro = 42'

    This time some statements are generated by the compiler itself (e.g the last label b_intro).

    The version now is this
    SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502 4.2.0 #13081 (MINGW32)
    published under GNU General Public License (GPL)

    I can attach the sources if needed.
    Interestingly, I have other .include in other ASM segments where I do not get any warning

     

    Last edit: Ragozini Arturo 2022-03-07
    • Sebastian Riedel

      Most of these will get fixed with [patches:#428] (.rept and direct assignment)
      And I will look into accepting mnemonic alternatives.
      But .include won’t be supported as well as .incbin, .irp, macro definitions and macro calls. I tried to support what can be easily calculated or where a worst case maximum size is known.
      Again, this function is only used to determine the distance between a jp and a label, if it fails that just means your code uses less jr than what would be optimal.

      This time some statements are generated by the compiler itself (e.g the last label b_intro).

      Yes, __banked generates direct assignments, which aren’t understood currently and are the main reason why I wrote [patches:#428]

      Interestingly, I have other .include in other ASM segments where I do not get any warning

      If there is no code that tries to jump over it, it won’t be parsed by this function.

       

      Related

      Patches: #428


      Last edit: Sebastian Riedel 2022-03-07
  • Ragozini Arturo

    Ragozini Arturo - 2022-03-07

    ok, thanks!

     
    • Sebastian Riedel

      outi should work now [r13137] in next/

       

      Related

      Commit: [r13137]

  • Sebastian Riedel

    • status: open --> closed-fixed
     
  • Sebastian Riedel

    Finally fixed in [r13187]

     

    Related

    Commit: [r13187]


Log in to post a comment.

MongoDB Logo MongoDB