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 support@ccsinfo.com

How to define data structure in ROM?

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



Joined: 10 Nov 2007
Posts: 1

View user's profile Send private message

How to define data structure in ROM?
PostPosted: Sat Nov 10, 2007 2:09 pm     Reply with quote

Could you please show me how to define structure in CCS, but it is located in ROM?
example for assembly:
left db 0x00,0x00
right db 0x00,0x00
roof dw left, right

but example for C:
static const byte left[]={0x00,0x00};
static const byte right[]={0x00,0x00};
static const long roof[]={address of left, address of right};
I do not want to use absolute address by using #org or #locate
I also want to build a TREE structure, but my data is put in ROM. Please show me how to do.
Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 10, 2007 4:37 pm     Reply with quote

In CCS, if you declare a variable as 'const', then it will be put in ROM.

See my post in this thread which shows how to put a structure in ROM,
and also how to initialize it.
http://www.ccsinfo.com/forum/viewtopic.php?t=32604&highlight=const

This post shows how to put an array of structures into ROM:
http://www.ccsinfo.com/forum/viewtopic.php?t=30610&highlight=struct+const
Ttelmah
Guest







PostPosted: Sun Nov 11, 2007 3:41 am     Reply with quote

I think the problem is that he wants to store addresses of constant values. As such, this can be done, but you can't store these addreses in a constant.
Key to understand, is that a 'const' declaration, actually generates a program to retrieve the value. So the value itself, won't reside at the location where the 'program' is declared. The addressof function, allows you to retrieve the 'real' address for the data, but this is a runtime function, and the value it returns,is not therefore available at compile tme.

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