This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C28xx's Compiling Result Different between .lib projcet and .out project

Other Parts Discussed in Thread: CCSTUDIO

Dear,

I'd been confused with C28xx's compiler. There was a project for 28232, which composed by a .lib project and a .out project, A function(say _AllocEvent()) was called by both the .lib project and the .out project in different .C files, it's strange the result from the called function(_AllocEvent()) were different. The following were the details:
 
  1)the C language:

      (a)my_memory.c

        void *AllocEvent()
        {
          U16 *ptr;
       
          ...
       
         
          return (void *)ptr;
        }

 

       (b)fuzzypid.c

       ptTempStartEvent = (T_TIMER_EVENT*)AllocEvent();       // ptTempStartEvent - a pointer to a structure type(T_TIMER_EVENT)
                                                                // AllocEvent - to allocate a block memory from a memory pool(Start Addr = 0xC000)

      Both the Cfiles in .lib project.


  2)The result for fuzzypid.c (in .lib project) after assembly :
        .dwpsn    file "fuzzypid.c",line 559,column 2,is_stmt
            LCR       #_AllocEvent          ; |559|
            ; call occurs [#_AllocEvent] ; |559|
            SETC      SXM
            MOVW      DP,#_ptTempStartEvent
            MOV       ACC,AL                ; |559|
            MOVL      @_ptTempStartEvent,ACC ; |559|
    
    Result: ptTempStartEvent = 0x2B0(it should be 0xC2B0, It lost the start address of the memory pool and only keep the offset)

    view: It was XAR4 not AL should be used as the retrun register when calling function AllocEvent().


                                                                         
  2)The result for controller-protocol.c (in .out project) after assembly :
        .dwpsn    file "controller-protocol.c",line 462,column 2,is_stmt
            LCR       #_AllocEvent          ; |462|
            ; call occurs [#_AllocEvent] ; |462|
            MOVW      DP,#_ptTempStartEvent
            MOVL      @_ptTempStartEvent,XAR4 ; |462|

    Result: ptTempStartEvent = 0xC2B0(it was right)

    view: It did was XAR4 used as the retrun register ,so the result was right.

    
The .lib project and .out project had the same compiler options:
1) for fuzzypid.c(in .lib project)
   "C:\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -k -fr"D:/TEMP/Upc200_work/2)upc200_lib/lib_prj/Debug" -fs"D:/TEMP/Upc200_work/2)upc200_lib/lib_prj/Debug" -i"../../2)upc200_lib/common_headers" -i"../../2)upc200_lib/lib_include" -i"../../2)upc200_lib/include" -d"LARGE_MODEL" -ml -v28 -@"../lib_prj/Debug.lkf" "fuzzypid.c"    

2) for controller-protocol.c(in .out project)
   "C:\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -k -fr"D:/TEMP/Upc200_work/1)upc200_work/prj/Debug" -fs"D:/TEMP/Upc200_work/1)upc200_work/prj/Debug" -i"../include" -i"../../2)upc200_lib/lib_include" -d"LARGE_MODEL" -ml -v28 -@"../prj/Debug.lkf" "controller-protocol.c"
  

Thanks a lot!

 

albert

 

  • Gong Huang said:

    Dear,

    I'd been confused with C28xx's compiler. There was a project for 28232, which composed by a .lib project and a .out project, A function(say _AllocEvent()) was called by both the .lib project and the .out project in different .C files, it's strange the result from the called function(_AllocEvent()) were different. The following were the details:
     
      1)the C language:

          (a)my_memory.c

            void *AllocEvent()
            {
              U16 *ptr;
           
              ...
           
             
              return (void *)ptr;
            }

     

           (b)fuzzypid.c

           ptTempStartEvent = (T_TIMER_EVENT*)AllocEvent();       // ptTempStartEvent - a pointer to a structure type(T_TIMER_EVENT)
                                                                    // AllocEvent - to allocate a block memory from a memory pool(Start Addr = 0xC000)

          Both the Cfiles in .lib project.


      2)The result for fuzzypid.c (in .lib project) after assembly :
            .dwpsn    file "fuzzypid.c",line 559,column 2,is_stmt
                LCR       #_AllocEvent          ; |559|
                ; call occurs [#_AllocEvent] ; |559|
                SETC      SXM
                MOVW      DP,#_ptTempStartEvent
                MOV       ACC,AL                ; |559|
                MOVL      @_ptTempStartEvent,ACC ; |559|
        
        Result: ptTempStartEvent = 0x2B0(it should be 0xC2B0, It lost the start address of the memory pool and only keep the offset)

        view: It was XAR4 not AL should be used as the retrun register when calling function AllocEvent().


                                                                             
      2)The result for controller-protocol.c (in .out project) after assembly :
            .dwpsn    file "controller-protocol.c",line 462,column 2,is_stmt
                LCR       #_AllocEvent          ; |462|
                ; call occurs [#_AllocEvent] ; |462|
                MOVW      DP,#_ptTempStartEvent
                MOVL      @_ptTempStartEvent,XAR4 ; |462|

        Result: ptTempStartEvent = 0xC2B0(it was right)

        view: It did was XAR4 used as the retrun register ,so the result was right.

        
    The .lib project and .out project had the same compiler options:
    1) for fuzzypid.c(in .lib project)
       "C:\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -k -fr"D:/TEMP/Upc200_work/2)upc200_lib/lib_prj/Debug" -fs"D:/TEMP/Upc200_work/2)upc200_lib/lib_prj/Debug" -i"../../2)upc200_lib/common_headers" -i"../../2)upc200_lib/lib_include" -i"../../2)upc200_lib/include" -d"LARGE_MODEL" -ml -v28 -@"../lib_prj/Debug.lkf" "fuzzypid.c"    

    2) for controller-protocol.c(in .out project)
       "C:\CCStudio_v3.3\C2000\cgtools\bin\cl2000" -g -k -fr"D:/TEMP/Upc200_work/1)upc200_work/prj/Debug" -fs"D:/TEMP/Upc200_work/1)upc200_work/prj/Debug" -i"../include" -i"../../2)upc200_lib/lib_include" -d"LARGE_MODEL" -ml -v28 -@"../prj/Debug.lkf" "controller-protocol.c"
      

    Thanks a lot!

     

    albert

     

     

     

    Is there a function prototype in both cases?  If you add -pdr as a build option, does the compiler complain "function declared implicitly?"

    Without a prototype the compiler will make assumptions about what data type is being passed/returned which may not be correct.

    Regards

    Lori

  • Lori,

           You're right!

            In the .lib project no prototype include about the function(void *AllocEvent()).

           Thanks!

     

    Albert

     

     

     

  • Lori,

           The compiler didn't recognize the build option -pdr, anyone else?

           Thanks!

    Albert