Page 1 of 1

Inline assembly in FC7

Posted: Tue Jan 17, 2017 7:23 pm
by Andreas
Hi

I have until now been using FC5, and therefore have a lot of old programs programs, which is programmed in FC5. Unfortunately i do no longer have access to my former FC5 licens, and i am now started to use FC7, starting with the 30 days trial.

In some of my programs i have inline assembly code, but this code made in FC5 seems to create a lot of troubles in FC7.

The code would look something like this:

Code: Select all

asm{
send1:   BSF  _porta, 0
         NOP 
         NOP
         NOP
         BCF _porta, 0
slut1:   END
}
During compiling, something like the following error appeared
"(" expected
string expected
")" expected
I found out that a solution on the error could be found by changing the code to

Code: Select all

asm(
"send1:   BSF  _porta, 0"
         "NOP" 
         "NOP"
         "NOP"
         "BCF _porta, 0"
"slut1:   END"
);
But this just caused another error saying
syntax error
Undefined symbol "0NOPNOPNOPNOPBCF"
And in the generated assembly-code, everything in the assembly-block seems to be squeezed together on 1 single line like:
send1: BSF _porta, 0NOPNOPNOPNOPBCF _porta, 0slut1: END ;#
I hope someone here can tell me what is happening and how to use inline assembly in FC7

Andreas

Re: Inline assembly in FC7

Posted: Wed Jan 18, 2017 12:25 pm
by LeighM
try this...

Code: Select all

asm(
"send1:   BSF  PORTA, 0\n"
         "NOP\n"
         "NOP\n"
         "NOP\n"
         "BCF PORTA, 0\n"
);

Re: Inline assembly in FC7

Posted: Thu Jan 26, 2017 3:41 pm
by Andreas
Hi

Thanks for the answer.

I read the manual for mplab XC8 compiler and found out that using #asm and #endasm was solving my problem. Unfortunately this lead to other syntax-errors, but i found a workaround and now everything works fine.