Nops on hex output file

jpremor
2007-11-26
2013-03-12
  • jpremor
    jpremor
    2007-11-26

    Hello all,

    im having a very good experience with sdcc and pic18, but some things is not clear at all.
    When i compile, the lst (a little piece) file looks like this:

    05D2           02406 _01095_DS_:
    05D2 A0D8      02407         BTFSS   STATUS, 0
    05D4 EF00 F000 02408         GOTO    _00868_DS_
    05D8 5000      02409         MOVF    r0x16, W
    05DA 5C00      02410         SUBWF   r0x23, W
    05DC 6E00      02411         MOVWF   r0x28
    05DE 5000      02412         MOVF    r0x17, W
    05E0 5800      02413         SUBWFB  r0x24, W
    05E2 6E00      02414         MOVWF   r0x29
    05E4 6AE8      02415         CLRF    WREG
    05E6 BE00      02416         BTFSC   r0x29, 7
    05E8 0EFF      02417         MOVLW   0xff
    05EA 6E00      02418         MOVWF   r0x2a
    05EC 6E00      02419         MOVWF   r0x2b
    05EE 5000      02420         MOVF    r0x2b, W
    05F0 0F80      02421         ADDLW   0x80
    05F2 6EF3      02422         MOVWF   PRODL
    05F4 5000      02423         MOVF    r0x22, W
    05F6 0F80      02424         ADDLW   0x80
    05F8 5CF3      02425         SUBWF   PRODL, W
    05FA E100      02426         BNZ     _01096_DS_
    05FC 5000      02427         MOVF    r0x21, W
    05FE 5C00      02428         SUBWF   r0x2a, W
    0600 E100      02429         BNZ     _01096_DS_
    0602 5000      02430         MOVF    r0x1d, W
    gpasm-0.13.4 beta               output\XXX.asm11-26-2007  09:06:43         PAGE 46

    LOC  OBJECT CODE     LINE SOURCE TEXT
      VALUE

    0604 5C00      02431         SUBWF   r0x29, W
    0606 E100      02432         BNZ     _01096_DS_
    0608 5000      02433         MOVF    r0x1c, W
    060A 5C00      02434         SUBWF   r0x28, W

    The asm output looks a quite similar,
    but when i look at the generated HEX file in MPLAB program view data, it have a lot (it is too much) NOPs between the instructions generated by the hex.

    Example:
    GOTO 0xc1e
    NOP
    MOVLW 0x19

    This NOP between goto and mov instructions is not necessary, right? To me it looks like spaces. There is any optimize instruction to clean this up? Normally it appears next goto and call instructions.

    thanks
    and Best Regards.

     
    • jpremor
      jpremor
      2007-11-26

      Comparing the PIC18 hex with PIC16 hex, i notice that PIC16 doesnt have nops in the middle...

      and more, a empty program memory full of FFs... at PIC18 is NOP (FFFF, 16 bits) and at PIC16 it is ADDLW 0xFF (3FFF, 14 bits)

      best regards

       
      • 0xFF is the most common filler byte in hex files as it is the value of an erased FLASH byte. It's therefore also commonly chosen as the NOP instruction, as it means that the behaviour when executing blank memory is benign.

        I suspect that the disassembler is disassembling filler bytes, and it's quite possible that the PIC doesn't actually execute them.

         
        • jpremor
          jpremor
          2007-11-28

          I know that this is not a problem during execution, but for memory space is. With a fast look at program memory space i can see that the 24kb inicially occupied, maybe 2k is NOPs...

          thats not good. And as posted before, it doesnt happen at 16F family.

          best regards

           
          • I suspect that it's only a filler byte in the hex file, not in the actual FLASH memory.

             
    • jpremor
      jpremor
      2007-11-28

      any comments?

       
    • jpremor
      jpremor
      2007-11-28

      in the middle of the functions call??
      normally at the end of the program memory yes, its a filler,

      05FA E100 02426 BNZ _01096_DS_
      05FC 5000 02427 MOVF r0x21, W
      05FE 5C00 02428 SUBWF r0x2a, W
      0600 E100 02429 BNZ _01096_DS_
      0602 5000 02430 MOVF r0x1d, W
      gpasm-0.13.4 beta output\XXX.asm11-26-2007 09:06:43 PAGE 46

      NOP   <--- the nops appears here... between two functions If i have 100 functions, itll ve 200bytes lost with nops

      LOC OBJECT CODE LINE SOURCE TEXT
      VALUE

      0604 5C00 02431 SUBWF r0x29, W
      0606 E100 02432 BNZ _01096_DS_
      0608 5000 02433 MOVF r0x1c, W