View previous topic :: View next topic |
Author |
Message |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
enum with 16-bit values |
Posted: Fri Dec 05, 2008 1:30 am |
|
|
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
|
|
Posted: Fri Dec 05, 2008 1:35 am |
|
|
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
|
|
Posted: Fri Dec 05, 2008 1:50 am |
|
|
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
|
|
Posted: Fri Dec 05, 2008 3:31 am |
|
|
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 |
|
|
|