Hi,
I'm newbie on the msp430 and I need to embed some asm in my C code. I'm working w/ the msp430F2418 and using the IAR Workbench as a developing environment.
I've spent some time googling and looking at some forum discussions. Currently, I've already tried some ideas that i saw on the web: e.g. to break my code into multiples as("instr") lines, to use the #pragma asm #pragma endasm,.... I know there's the possibility of writing the entire function in assembly, but in my case i really need to mix it w/ C language.
I've also couldn't find answers in the manual (I'm pretty sure they might be there, but i couldn't figure out everything i've read though -- as i said, i'm new on this platform).
I'm trying to run the following inline assembly code (in fact, i've got two versions, the second is a gcc-based). The IAR outputs that:
for the first i got sth like this: Error[Og006]: Syntax error in inline assembly: "Error[0]: Invalid syntax" Error[Og006]: Syntax error in inline assembly: "Error[0]: Error[Og005]: Unknown symbol in inline assembly: "c" Error[Og005]: Unknown symbol in inline assembly: "carry" Error while running C/C++ compiler
and for the 2nd like that: "Error[Pe018]: expected a ")" "
__asm ( "MOV &a,r10\n" "MOV &b,r11\n" "MOV &c,r12\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADD r13,r15\n" "MOV r15,(2*0)(r12)\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADDC r13,r15\n" "MOV r15,(2*1)(r12)\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADDC r13,r15\n" "MOV r15,(2*2)(r12)\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADDC r13,r15\n" "MOV r15,(2*3)(r12)\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADDC r13,r15\n" "MOV r15,(2*4)(r12)\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADDC r13,r15\n" "MOV r15,(2*5)(r12)\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADDC r13,r15\n" "MOV r15,(2*6)(r12)\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADDC r13,r15\n" "MOV r15,(2*7)(r12)\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADDC r13,r15\n" "MOV r15,(2*8)(r12)\n" "MOV @r10+,r15\n" "MOV @r11+,r13\n" "ADDC r13,r15\n" "MOV r15,(2*9)(r12)\n" "CLR r15\n" "ADC r15\n" "MOV r15,&carry\n" );
asm( "mov %[a],r11\n\t" "mov %[b],r12\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "add r14,r13\n\t" "mov %[c],r15\n\t" "mov r13,2*0(r15)\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "addc r14,r13\n\t" "mov r13,2*1(r15)\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "addc r14,r13\n\t" "mov r13,2*2(r15)\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "addc r14,r13\n\t" "mov r13,2*3(r15)\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "addc r14,r13\n\t" "mov r13,2*4(r15)\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "addc r14,r13\n\t" "mov r13,2*5(r15)\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "addc r14,r13\n\t" "mov r13,2*6(r15)\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "addc r14,r13\n\t" "mov r13,2*7(r15)\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "addc r14,r13\n\t" "mov r13,2*8(r15)\n\t" "mov @r11+,r13\n\t" "mov @r12+,r14\n\t" "addc r14,r13\n\t" "mov r13,2*9(r15)\n\t" "clr r14\n\t" "adc r14\n\t" "mov r14,%[carry]\n\t" : [carry] "=m" (carry) : [a] "m" (a), [b] "m" (b), [c] "m" (c), "[carry]" (carry) :"r11","r12","r13","r14","r15" );
In the latter, I've also tried sth like that in the end: "mov r14,%[carry]\n\t"); // : [carry] "=m" (carry) // : [a] "m" (a), [b] "m" (b), [c] "m" (c), "[carry]" (carry) // :"r11","r12","r13","r14","r15" // );
But then i've got the following:
mrcomba.c Error[Og006]: Syntax error in inline assembly: "Error[0]: Error[Og006]: Syntax error in inline assembly: "Error[0]: Error[Og006]: Syntax error in inline assembly: "Error[0]: Error[Og006]: Syntax error in inline assembly: "Error[0]: Error while running C/C++ compiler
Any help will be much appreciated
Cheers
Leo