3 Replies Latest reply on Sep 12, 2010 6:27 AM by user_62720120

    Incrementing a pointer

    user_62720120

      Hi all,

         

      Just looking at the assembler output from PSoC Creator for the PSoC 3. The code:

         

       

         

      uint8 *p=0;
      p++;

         

       

         

      produces this assembler:

         

       

         

      MOV     DPTR,#p+01H
      CLR     A
      MOV     B,#01H
      LCALL   ?C?IILDX
       

         

      A call? To increment a pointer? What's with that?

         

       

         

      Hugo

        • 1. Re: Incrementing a pointer
          user_611219

          Looking at the Map file, shows the function residing in the C51L lib file.

             

          ....\PSOC CREATOR\IMPORT\KEIL\PK51\8.16\C51\LIB\C51L.LIB (?C?IILDX)
           

             

          Using the library manager to create a list of the public functions of C51L.lib, verifies this.

             

          ?C?IILDX
                ?C?IILDX
           

             

          ..and looking at the MAP file again, shows it may be some 21 bytes long:

             

          0100009AH   CODE     ---       ?C?IILDX
          010000B0H   CODE     ---       ?C?ISTPTR
           

             

          My guess it could be some bank switching or address checking code.

             

          You may want to direct this question directly to KEIL.

             

          PS: the \LIB folder contains code for the Lib files, but I can't seem to match the function in question.

          • 2. Re: Incrementing a pointer
            user_62720120

            I don't understand why people aren't more surprised and concerned about this? Incrementing a value is one of the most fundamental operations in any code.

               

             

               

            Even MPLAB's basic C compiler for the PIC18  generates the expected instructions for an increment.

               

             

               

            Are there any better compilers available for the PSoC ?

            • 3. Re: Incrementing a pointer
              user_2405011

              Are you sure the pointer increment isn't optimized out and the lcall belongs to this increment?

                 

              Regards,

                 

              Rolf