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.

Array allocation in assembly for C66x

Hello, 

I am doing a hand code assembly. I want to know where should the local variables be allocated. Should it be on the stack ?

I have the code in following format. Both func1 and func2 are supposed to be hand coded assembly.

main ()

{

  func1();

}

func1()

{

   int array 1[10];

   func2(&array1[8]);

}

How do i manage the passing parameter and the allocate array1[]

Thanks

  • Hi unicorn,

    In general, a stack is used to store local variables in C programming model.  It allows a function is called in different context, and also recursive calls.  I did not find a tutorial but the following page provides links to some useful textbooks in PDF format.

    However, if the func1() and func2() are used in the shown context only, an easier idea is treating the array1[] as a global variable by .bss or .usect assembler directives.

    My personal opinion is, we should avoid assembler programming for C6000 as much as possible.  The above text covers software optimization by C compiler very well.

    Best Regards,
    Atsushi

  • Hello Atsushi,

    Thanks for the detail reply.

    I can not consider array1[] as a part of global variables. I will go on to the stack. After examining the assembler generated code it is I understood as to how to allocate the local variable on to the stack.

    Yes I agree with your point of view that assembler programming needs to be avoided, but I feel that hand coding will surely give me better performance.

    I will surely look into the optimization workshop as it will be useful for me in project ahead.

    Regards,

    unicorn

  • unicorn,

    Yes, reading the assembly code which compiler generated is helpful very often.

    Please don't hesitate to ask us when you have other questions.

    Best Regards,
    Atsushi