Other Parts Discussed in Thread: MSP430F5529
Dear Sir:
I am new to the CCS6 IDE. I am using CCS5, MSP430F5529 Launchphad , and I am trying to call an assembly language function from the C integrated development environment.
I am using as a guide I am using a Texas Instruments publication, The MSP430 Optimizing C/C++ Compiler User's Guide, SLAU132j. I have posted a link to the publication for your convenience below:
http://www.ti.com/lit/ug/slau132j/slau132j.pdf
Please go to page 127.
I have copied and pasted the code below as a guide as a reference for out discussion:
The C program that calls the assembly language function:
extern "C" {
extern int asmfunc(int a); /* declare external asm function */
int gvar = 0; /* define global variable */
}
void main()
{
int var = 5;
var = asmfunc(var); /* call function normally */
The called assembly language function:
.global asmfunc
.global gvar
asmfunc:
MOV &gvar,R11
ADD R11,R12
RET
I believe this discussion would be fruitful if someone could, first, get this program working and reply with working code that I can directly cut and paste directly into CCS6 because there are a lot of problems if one copies and pastes the code directly from the TI publication.
For example, the compiler does not like the extern C {} method of coding (this can be remedied by not writing the code in shorthand) and the assembly language program does not appear to accept instructions such as ADD without a bit length appended to it (for example ADD.w) . I could go on and on with all the small problems I have encountered and if we went over every little problem this discussion would take an unreasonably long time.
Therefore, first, sending me the working code would be efficient. It is possible that, maybe, my compiler settings are not correct, in addition to, the incompatible format of code that I have been trying to work with. I would like to look into this first because I have encountered some linking errors when I managed to get parts of the code to compile.
Can someone please help me get this program working so that I can step through the program? Thank you for your consideration.