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.

CCS/AM3354: ERROR MESSAGE, Address must be defined in the current section

Part Number: AM3354


Tool/software: Code Composer Studio

Hello

     I defined a pointer variable uipCurrentTaskTCBPtr in C source file, and I want to use the variable in .s file, so I program like this in the C source file.

uipTask  *uipNextRunningTaskTCBPtr (uipTask is a structure).

I write following code in .h file.

extern  uipTask  *uipCurrentTaskTCBPtr;

And I write following code in .s file

.global uipCurrentTaskTCBPtr

LDR   r3  uipCurrentTaskTCBPtr

then, I compile the program, I got the error message.

(1):   Address must be defined in the current section

(2): Illegal operand

why this fault appear?

Best Regards

Jack

  • Please see the discussion in this forum thread.

    Thanks and regards,

    -George

  • Sorry George

    I still can not understand how to get the address of control block uipNextRunningTaskTCBPtr.

    Best Regards

    Jack

  • can i  write like this?

    .global    uipNextRunningTaskTCBPtr
    uipNextRunningTaskTCBPtrAddr    .field    uipNextRunningTaskTCBPtr,32

    LDR      R1, uipNextRunningTaskTCBPtrAddr

    best regards

    Jack

  • Similar to the method used in the forum thread I referenced, write small piece of C code which does the same thing, then see how the code generated by the compiler does it.  

    Consider this simple source file ...

    /* const_table_example.c */
    
    /* This structure is a stand-in for the real uipTask, which I do not have */
    typedef struct
    {
       int a, b, c;
    } uipTask;
    
    extern  uipTask  *uipCurrentTaskTCBPtr;
    
    /* A simple function which uses the global pointer variable */
    int test_function()
    {
       return uipCurrentTaskTCBPtr->b;
    }

    Build it with a command similar too ...

    % armcl -mv7a8 --src_interlist const_table_example.c

    Because of --src_interlist, the compiler generated assembly code is a file named const_table_example.asm.  Inspect it.  The key lines are ...

    test_function:
    ;* --------------------------------------------------------------------------*
    ;** 14  -----------------------    return (*uipCurrentTaskTCBPtr).b;
            LDR       V9, $C$CON1           ; [DPU_V7A8_PIPE0] |14|
    ...
    
    ;******************************************************************************
    ;* CONSTANT TABLE                                                             *
    ;******************************************************************************
            .sect   ".text"
            .align  4
    ||$C$CON1||:    .bits   uipCurrentTaskTCBPtr,32

    Line 4 loads the address of uipCurrentTaskTCBPtr into the register V9.  This is a reference to a constant table entry.  This constant table, which is in the same section, is written right after the function.  

    You need to do something similar.

    Thanks and regards,

    -George

  • Hi George

    where should I insert the the command line "% armcl -mv7a8 --src_interlist const_table_example.c"? 

    Put the command line in .c file or .s file? Or the command line is just used  for insert the assembler function 

    test_function into const_table_example.c?

    In addition, does "||........||" means the address? If I quote "||$C$CON1||", it means get the address of variable

     $C$CON1?

    So , now I am porting an real time operating system to AM3354, I defined uipCurrentTaskTCBPtr in task.c,

    typedef struct uip_TSK_STRUCT 
    {     
        int a,b,c;
     
    } uipTask;   
    
    typedef uipTask *  uipTaskPtr;

    And I write in .s file like this:

    .sect   ".text"
            .align  4
    ||$C$CON1||:    .bits   uipCurrentTaskTCBPtr,32
    
    uipScheduler
    
       LDR R1, $C$CON1 

    Does this ok?

  • zemin shan said:

    where should I insert the the command line "% armcl -mv7a8 --src_interlist const_table_example.c"? 

    Put the command line in .c file or .s file? Or the command line is just used  for insert the assembler function 

    test_function into const_table_example.c?

    The file const_table_example.c, and the command that builds it, form an example.  It demonstrates a method for you to learn.  Do not use any of it in your system.

    zemin shan said:

    In addition, does "||........||" means the address? If I quote "||$C$CON1||", it means get the address of variable

     $C$CON1?

    The compiler uses the syntax ||label name here||.  But it is best to just ignore the ||.  If you are curious, this forum post has the details.  In this specific case, read this to mean the symbol $C$CON1 corresponds to the address of the constant table entry.  

    This assembly code ...

    zemin shan said:
            .sect   ".text"
            .align  4
    ||$C$CON1||:    .bits   uipCurrentTaskTCBPtr,32
    uipScheduler
       LDR R1, $C$CON1

    ... appears to be correct.  Though, as I explain above, the || around the label name is not needed.

    Thanks and regards,

    -George

  • Since I rewrite my code, download and debug on chip AM3354, I still got the error message :

    why this happen?

    Best Regards

    Jack

  • Hello George

    What I mean is that the command line

     " ||$C$CON1||:   .bits   uipCurrentTaskTCBPtr,32 "  or

     " $C$CON1:  .bits   uipCurrentTaskTCBPtr,32 "

    can not put the value in address uipCurrentTaskTCBPtr into

    varaable $C$CON1.

    And put the value in address in uipCurrentTaskPtr into $C$CON1

    is exact what I need. 

    Best Regards

    Jack

  • I recommend you ignore the CCS display problem, just for now.  I'm not sure, but I think that is typical for hand-coded assembly.

    When you run the code, does it work as expected?  

    Thanks and regards,

    -George

  • No, it is not work as I expected.  I want the type of pointer $C$CON1 is uipTask, and the value of $C$CON is the address of struct uipCurrentTaskTCBPtr. 

    But the type of pointer $S$CON1 is void, and the value of $C$CON is not the address of struct uipCurrentTaskTCBPtr, it is another value.

    Best Regards 

    Jack

  • Hello George

    I think, I find the problem, since I use the code:

         .global  uipNextRunningTaskTCBPtr
    uipNextRunningTaskTCBPtrAddr:     .bits uipNextRunningTaskTCBPtr,32
    
    uipScheduler
         LDR       R1 ,uipNextRunningTaskTCBPtr

    The value in register R1 is the Address of uipNextRunningTaskTCBPtr, it is not the value of uipNextRunningTaskTCBPtr.

    But what I need is that the value in uipNextRunningTaskTCBPtr shift into R1.

    what should I modify?

    Best Regards

    Jack

    
    

  • Instead of ...

    zemin shan said:
    LDR R1 ,uipNextRunningTaskTCBPtr

    .. write ...

         LDR       R1, uipNextRunningTaskTCBPtrAddr

    At this point, R1 does not contain the contents of uipNextRunningTaskTCBPtr, but it's address.  To get the contents requires another instruction similar to ...

        LDR    R1, [R1, #0]

    Thanks and regards,

    -George

  • Thanks George

    It is works, but I want to inquire you another question.

    How can I replace the following code with TI Assembler?

    IF :DEF:MixPreemption
    
        .................
    
    ELSE
    
        .................
    
    ENDIF
    

    MixPreemption is a micro

    Best Regards

    Jack

  • Replace the IF, ELSE, and ENDIF with .if, .else, and .endif.  To learn about those directives, please search the TI ARM assembly tools manual for the sub-chapter titled Assembler Directives.  

    For IF :DEF:MixPreemption, please search the same manual for the sub-chapter titled Defining Symbolic Constants.  Note how the operator $$isdefed is used.

    Thanks and regards,

    -George