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

enum with 16-bit values

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



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

enum with 16-bit values
PostPosted: Fri Dec 05, 2008 1:30 am     Reply with quote

Colleagues,

I have a quick question (unfortunately, I couldn't find the answer in online help). Can enum have 16-bit values? I've tried enum {C = 0xFFFF}; and it compiled, however I still want to check with the community.

Thanks,
- Nick
_________________
Read the label, before opening a can of worms.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Dec 05, 2008 1:35 am     Reply with quote

I don't know, but would take a look at the code, the expression compiles to.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Fri Dec 05, 2008 1:50 am     Reply with quote

FvM wrote:
... look at the code, the expression compiles to.

None of my enums (including the 8-bit ones that have been proven to work), consts and #defines show ASM code next to them in the C/ASM listing.
_________________
Read the label, before opening a can of worms.
Ttelmah
Guest







PostPosted: Fri Dec 05, 2008 3:31 am     Reply with quote

No, the code will be where you use it.
Code:

 enum test {C = 0xFFFF};


 test val;
 int16 dummy;
 dummy=(int16)test;

If you look at the list, and the sym file, you will find that 'val', is declared using 16bits, and two bytes are copied:
Code:

....................  dummy=(int16)val;
*
0031:  MOVF   22,W
0032:  MOVWF  24
0033:  MOVF   21,W
0034:  MOVWF  23


So, yes.

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