View previous topic :: View next topic |
Author |
Message |
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
byte |
Posted: Sat Jan 28, 2012 12:31 pm |
|
|
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: 9226 Location: Greensville,Ontario
|
|
Posted: Sat Jan 28, 2012 1:46 pm |
|
|
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
|
|
Posted: Sat Jan 28, 2012 2:35 pm |
|
|
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: 19513
|
|
Posted: Sat Jan 28, 2012 2:52 pm |
|
|
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
|
re byte |
Posted: Sat Jan 28, 2012 3:24 pm |
|
|
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: 9226 Location: Greensville,Ontario
|
|
Posted: Sat Jan 28, 2012 3:36 pm |
|
|
You can download the latest manual as a PDF from the CCSinfo website... |
|
|
|