Searching \ for 'Inline Assembly in CCS' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=inline+assembly
Search entire site for: 'Inline Assembly in CCS'.

Truncated match.
PICList Thread
'Inline Assembly in CCS'
1999\04\13@194641 by Darlene Magnusson

flavicon
face
I'm trying to do some inline assembly, specifically manipulating the program
counter to jump through a table based on a variable value.

There are 2 asm commands in the book that don't appear in the PIC data books
along with the rest of the commands.  They are movplw and movphw.
movplw implies move pl to w based on the syntax of the rest of the PIC
commands.  Is this correct?  If so, how do I move w to pl or add w to pl.

First, I tried :
#byte PCL =2

#asm
movf    bit,W
addwf   PCL,F
...
#endasm

I got:
Error: expression must evaluate to a constant

Then I tried:
#byte PCL=2

#asm
movplw
addwf   bit,W
movwf   PCL
...
#endasm

I got:
Error: undefined identifier

1999\04\14@103720 by Lawrence Lile

flavicon
face
Darlene wrote:
-----Original Message-----
From: Darlene Magnusson <spam_OUTdarleneTakeThisOuTspamZIRCON.COM>
>First, I tried :
>#byte PCL =2
>
>#asm
>movf    bit,W
>addwf   PCL,F
>...
>#endasm
>
>I got:
>Error: expression must evaluate to a constant


Usually I find that error when I have not defined a variable.  When I tried
this code, CCS returned "UNDEFINED ERROR" and then MPLAB crashed!

Are you defining BIT as an integer variable  ( int bit; ), or as a bit
location (#DEFINE bit  5) ?  If bit is not an integer variable, all hell
might break loose.

{Quote hidden}

Still sounds like a variable not defined.  I still can't figure out what the
movplw is supposed to do. Forget inline assembly and use standard C.

A standard C syntax way of making a lookup table is this:  (and it works in
CCS!) This is copied directly from one of my programs that really does
compile, BTW.

int time;
int index = [ some number between 0 and 32]

static const int lookup[33] =   {   9,   10,   11,   12,   13,   13,   14,
15,   16,   16,   17,   18,   19,   20,   21,   22,
  23,   23,   24,   25,   26,   27,   28,   29,   29,   29,   30,   31,
31,   31,   31,   31,   31     };

time = lookup[index];

1999\04\14@123919 by Darlene Magnusson

flavicon
face
At 09:32 AM 4/14/99 -0500, you wrote:
{Quote hidden}

bit is declared as an integer (int bit;) , sorry I left that line out.

{Quote hidden}

Thank you for the suggestion but I don't think this type of table won't work
for my application, my table is more like a switch statement (ie. if bit is
equal to 5, set the 5th bit). I was trying to find the most efficient way of
doing this.

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...