Using variables in embedded asm code?

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Using variables in embedded asm code?

Post by jadiflow »

Hi,

I am trying to read the contents of a PIC timer register into a variable bMains_period I defined in Flowcode. Tried several ways to address the variable, with _FCV_ or FCV_ or just _ prepended, no success. Always get an ' undefined symbol' error message.

This is the code fragment:

Code: Select all

#asm
// read T0
banksel TMR0
move TMR0, 0
movwf FCV_bMains_period
#endasm
What am I missing?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Using variables in embedded asm code?

Post by kersing »

Variable names are all upper case. So TesT would be FCV_TEST (for a global variable) or FCL_TEST (for a local variable)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Using variables in embedded asm code?

Post by jadiflow »

I did try that, no joy:

Code: Select all

#asm
// read T0
banksel T0
move T0, 0
movwf FCV_BMAINS_PERIOD
#endasm
eDD SMS-1 freq test.c: 533: (876) syntax error
eDD SMS-1 freq test.c: 534: (800) undefined symbol "FCV_BMAINS_PERIOD"
(908) exit status = 1
(908) exit status = 1

Byte bMains_period IS defined; I use it elsewhere in the program with no issues.

Jan

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Using variables in embedded asm code?

Post by kersing »

Assuming your are using FC7 things are a bit more complicated:

For local variables within a macro the variable name seems to be:
c:FCM_<macroname>@FCM_<upper case variable name>
(This applies to local variables in the main macro as well)

For global variables:
c:_FCV_<upper case variable name>

If you want to check for your code, make sure it compiles to chip (disable any code generating compile errors), open de generated <project name>.AS file and search for the variable name.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Using variables in embedded asm code?

Post by jadiflow »

I only have global variables (no parameter passing), and the c: prefix doesn't work in my assembly block within the C block.

Anyway, how is one to know all this?? I looked in the help file for C-block and there's a nice video going not much further than showing how to drag a C block onto the flowchart. Looked like FC4 or FC5, 2014. Duh.

There's a reason why I paid for FC4, FC5, FC6, FC7 - I have no ambition to dive into C or assembly.

I know, not your fault Kersing, but it's frustrating.

Jan Didden

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Using variables in embedded asm code?

Post by LeighM »

Is there any reason you need to use asm?
You could do this in C, in a C icon block...

Code: Select all

FCV_BMAINS_PERIOD = TMR0;

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Using variables in embedded asm code?

Post by jadiflow »

Yes that seems to work. Thanks.

Jan Didden
Linear Audio

Post Reply