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.

CC430F5137 Code Composer C to Assembler nested subroutine calls

Other Parts Discussed in Thread: CC430F5137

I am using Code Composer to develop programs for CC430F5137 which belongs to the MSP430 family.

the problem I encountered is Nesting subroutine calls from C to assemblers: a call to subroutine in C, that subroutine then call another subroutine in Assembler

and that's it, no return.

will appreciate   if someone can light me up.

 

htovan

  • Could you please be a bit more descriptive about what you want to do and what the problem is?
    Do you have a problem with Code Compose or with this processor or with generally intermixing C and ASM function or what else?

  • the problem is intermixing C ands Asm : a program in main C called a subroutine in C, this subroutine called another subroutine in Asm but did not get return.

  • Well calling ASM function from within C is a difficult thing, since every compiler has its own conventions for calling functions.

    e.g. mspgcc will place the first parameter of a function in R15 8char) R14/R15 (word) or R12-R15 (long), the second into the next free and if all four registers are used up, the rest is placed on stack. The return value will be in R15 (char)... again.
    Other compilers will do differently. So you have to know how the compiler passes values to functions, so you know where your ASM function has to expect its parameters.

    Then there is the ASM fsnytax. Here again different compilers (or rather assemblers, since the compiler doesn't handle the ASM files) have different syntax for generating labels (including funciton names), local variables etc.

    Easiest is if the ASM function takes no parameters. Then you can define it in the C code as

    void asmfunction(void);

    and just call it as any other C funciton. Th elinker will do the job.

    How the ASM function has to be declared in the ASM file, how the ASM file needs to be named (extension) and included into the compile and link process depends on the IDE you use.

    Some compilers (including the mspgcc) allow the use of inline assembly code.
    If the function isn't too complex, you can just write a C function and fill its body with inlined ASM code.
    mspgcc has some addiitonal hints to tell the compiler which registers are clobbered or in which format the ASM code expects certain parameters it uses. So the compiler will automatically generate entry and exit code for saving used registers, moving constants into registers if the ASM code requires it etc.

    For your compiler/assembler/linker combo, you might want to look at one fo the demo projects with assembly parts. There you can see how the file mus tbe named, how the ASM functions are declared and how the project needs to be set up.

**Attention** This is a public forum