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

int1 problem

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



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

int1 problem
PostPosted: Wed Mar 09, 2011 6:58 pm     Reply with quote

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??? Sad

Thanks,
Ron
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Mar 10, 2011 2:22 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 10, 2011 10:47 am     Reply with quote

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? Sad
Seems like I don't see through but...
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Mar 10, 2011 11:00 am     Reply with quote

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? Sad
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
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