CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

how to make look up table

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
butterfly



Joined: 04 Jun 2006
Posts: 35

View user's profile Send private message

how to make look up table
PostPosted: Tue Jun 06, 2006 2:49 am     Reply with quote

ý'm new in CCS.
I WANT TO MAKE A LOOKUP TABLE. LIKE THAT ASEMBLY.

Saltprog
BANKSEL SSAYICI
MOVFW SSAYICI
Addwf PCL,F
RETLW 0xFF
RETLW 0xFF
RETLW 0xFF
RETLW 0xFF
RETLW 0xFF
RETLW 0xFF
RETLW 0xFF
RETLW 0xFF


ANY ADVICE YOU CAN GIVE ME??
Ttelmah
Guest







PostPosted: Tue Jun 06, 2006 4:37 am     Reply with quote

const int8 val[] = {1,2,3,5,6,7,8};

Then if you access 'val[n]' where 'n' is 0 to 6 in the example given, you get the value requested (you would need '0xff' in each location for the example you show). This generates exactly the version shown in your assembler, for a PIC 12/16 chip (on the 18 chips, the ability to directly access the program memory is used instead, allowing two bytes to be packed per instruction).

Best Wishes
butterfly



Joined: 04 Jun 2006
Posts: 35

View user's profile Send private message

PostPosted: Tue Jun 06, 2006 6:36 am     Reply with quote

i have write

BYTE CONST TABLE [10]= {9,8,7,6,5,4,3,2,1,0};

that error mesaje happen:

a numaric expression must appear here

i could not understand why?

thanks for help
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Jun 06, 2006 6:48 am     Reply with quote

Code:
BYTE CONST TABLE [10]= {9,8,7,6,5,4,3,2,1,0};

change to
Code:
const BYTE TABLE[10]= {9,8,7,6,5,4,3,2,1,0};
Ttelmah
Guest







PostPosted: Tue Jun 06, 2006 6:49 am     Reply with quote

There is nothing wrong with the line as typed. It is probably something on the line(s) in front.
Remember this a 'declaration', and wants to be either outside the code, or at the start of a routine.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group