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

#byte

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



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

#byte
PostPosted: Sun Dec 11, 2011 9:19 am     Reply with quote

I was interested by a #byte function and I tested it. But something disturb me.

Code:

int8 fred;
#byte fred = 0x60
fred = 10;
printf("fred = %d  ",fred);   //should display 10, but display 0
printf("freds address = %x ",&fred);


written on the screen: fred = 0 freds address = 60

Why the variable fred dont assume the value 10.
I hope you understand my question.
Thank you again! Smile
Ttelmah



Joined: 11 Mar 2010
Posts: 19437

View user's profile Send private message

PostPosted: Sun Dec 11, 2011 9:59 am     Reply with quote

First, you need to look at the data sheet of your processor. Is there RAM at address 60?.
Then you need to ensure this is not already used for something important. Is there a special function register (SFR) at this address?. Or does the compiler use this area for it's own functions?.

Seriously, the only main uses for #byte, are:
1) To locate a variable to talk to a SFR.
2) To locate two variables to use the same memory area (similar to a union).
3) Because you are working with other code that needs variables placed at a specific location.

Otherwise don't use it, and if you do, you _must_ study the data sheet.

Now, for example, of you are using a chip like the 16F676, this has RAM from address 0x20 to 0x5F, then from 0xA0 to 0xDF. The compiler puts it's own scratch area at 0x20, and allows 20 bytes for this.

Best Wishes
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

re: #byte
PostPosted: Sun Dec 11, 2011 11:52 am     Reply with quote

I see. Thank you for helping me at this beginner level of knowing CCS.
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