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 CCS Technical Support

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: Sat Jan 28, 2012 12:31 pm     Reply with quote

What is the difference between byte and variable?
For Example:
Code:

int var_name  //its a 8bit variable at the ram.
byte byte_name  //what is this

And why we use it instead of variable?
I hope you understand my question?
Thx in advance!
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jan 28, 2012 1:46 pm     Reply with quote

press F11 when your project is open, and you'll get the onscreen HELP files that CCS kindly supplies....the answer to both your questions are there....
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jan 28, 2012 2:35 pm     Reply with quote

Look in the .h file for your PIC. It will be in this directory:
Quote:

c:\program files\picc\devices

The 'byte' symbol is defined in that file. Look for it. You can see what it is.


Quote:
And why we use it instead of variable?

I think the person who wrote the example programs for CCS simply
likes to use 'byte' to declare 8-bit variables. Most people use the
data type of 'int8', because it's built-in to the compiler.
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Sat Jan 28, 2012 2:52 pm     Reply with quote

You can't declare something as a 'variable'.

Variable is a 'generic' term (like - say - 'car). It is just the word for any _named_ location in memory where you can store values. Since the value can 'vary', it is a 'variable'.

Now in C, all variables then have to have a 'type'. So if you were going to collect a large fish tank, and somebody said "oh that's alright, I have a car', you would have to ask 'what type', to find out if your tank was going to fit.
Big difference between a Fiat 500, and a pickup....

The 'basic' types in CCS, are:

int1 - a single bit
int - an integer 8bit value
long - a 16bit integer value
long long - a 32bit integer value
float - a 32bit floating point representation

Then each of these has aliases, generally designed to possibly make the use slightly more 'self explanatory'. So 'int', is the same as 'int8', and as 'char'. If you are storing a string of characters, using 'char' rather than 'int', is much more explanatory. These include int8, int16, int32 (which are much more easy to remember just what size your variable is), and a number of 'non intrinsic' similar aliases.
#BYTE (capitals), is intrinsic, and used to allow you to locate a variable 'at' a specific memory location (to perhaps talk to a 'byte' sized register in the processor), and 'byte' (lower case), is an alias for int8, defined in the processor include file (not intrinsic) used to help remind you that you are dealing with a 'byte' sized object.

So, all variables have a type, and as temtronic says, pressing F11, will allow you to see the names, and the associated sizes of these.

Best Wishes
rikotech8



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

View user's profile Send private message

re byte
PostPosted: Sat Jan 28, 2012 3:24 pm     Reply with quote

Thx!
In my compiler nothing occur when I press F11.
Maybe its the same like F1 in my unlicensed product :D.
There is an index (submenu) and explanation for pretty much functions and data types.
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jan 28, 2012 3:36 pm     Reply with quote

You can download the latest manual as a PDF from the CCSinfo website...
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