View previous topic :: View next topic |
Author |
Message |
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
int1 problem |
Posted: Wed Mar 09, 2011 6:58 pm |
|
|
Hi There,
I have an int1 in a function and initialize it with 0 and in MPLAB debugger (ICD3) it shows me a value of 0x5C - how can that be???
Thanks,
Ron |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Mar 10, 2011 2:22 am |
|
|
if I remember right, CCS packs INT1's into a byte...
MPLAB shows you the byte... can you expand it to see the bits within?
I'd have to do a check myself to see.. but off the top of my head...
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
|
Posted: Thu Mar 10, 2011 10:47 am |
|
|
Yes I can see the bits withinand okay, 0x5C bit0 is 0 but you cant expect this to go the way you would expect:
int1 x=0;
if (x){
// it'll go here;
}else{
// but i would expect it here;
}
Why would I need to apply a mask 0x01 to a variable I declared to be 1 bit long only?
Seems like I don't see through but... |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Mar 10, 2011 11:00 am |
|
|
cerr wrote: | Yes I can see the bits withinand okay, 0x5C bit0 is 0 but you cant expect this to go the way you would expect:
int1 x=0;
if (x){
// it'll go here;
}else{
// but i would expect it here;
}
Why would I need to apply a mask 0x01 to a variable I declared to be 1 bit long only?
Seems like I don't see through but... |
You don't need to mask. It's MPLAB's interpretation to display.
I use 1bit int's all the time in CCS and they work fine as you'd expect.
If you want.... do that If-Then and then look at the asm.. you'll see it's as efficient as you'd expect with a bit testing instructions rather than loading up WREG and testing that.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|