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/TMS320F28023: Compiler not adding constants, addition happening in run code

Part Number: TMS320F28023


Tool/software: Code Composer Studio

CCS V6, Win7 32 bit, F28023.

I have been trying to get CCS to add two constants together then use the result in a function call.

For example I want to write an assembly routine to set the stack to a value so I can see now much is actually used.

Here is the prototype...

extern MyMemSet(uint16 *start, uint16 size, uint16 value);

Here is the Func call.

MyMemSet( &stackStart + 8, (uint16) &_STACK_SIZE - 8, 0xa55a);

stackStart is defined in the linker,

_STACK_SIZE comes from the linker command line arg   --stack_size=.

The issue:

The &stackStart + 8  and &_STACK_SIZE - 8 are happening at run time. Examining the assembly code shows the addition and subtraction assembly instructions.

Everything here is a constant, how do I get this math to happen at compile time?

Thanks,
Mark.

  • Cool Javelin said:
    Everything here is a constant

    I understand why you say that.  But it is not completely accurate.  

    When the expression

    &stackStart + 8

    is processed by the compiler, it is not constant.  stackStart is a symbol.  The address is not determined until link time.  After the linker is done, there is no mechanism which re-processes the code generated for this expression to determine the final constant value, and replace that code with this value.  

    Thanks and regards,

    -George

  • Of course, George, now that you remind me I wonder why I didn't think of that earlier. Thank you.

    I guess since this is a one time call to init the stack, I can live with the 2 instruction inefficiency in this case.

    I tried to remove the --stack_size= option from the linker, and create my own stack buffer in the C code, but or course the linker complained because the RTL probably uses it, so I will have to live with it.

    M.