Hi,
SYMBOL is a left over from the BASIC Stamp and is not recommended.
In the BASIC Stamp there are a fixed number of pre-declared variables for you to use. B0 is one of those (a byte variable) and W0 is another (a word variable).
The statement SYMBOL Count = B0 simply creates an alias or a meaningful name to an already declared variable (the exact same thing as Count VAR B0 would) It's correct that it doesn't occupy any (new or more) space in RAM since it refers to an already declared variable (B0). What's important to remember here is that Count and B0 would be the exact same location RAM, translated to an absolute memory adress at compile time. (Well, yes the Basic Stamp is interpreted but anyway...)
(By the way, Count is a reserved word in PBP (and in the BasicStamp programming language) and has been for as long as I can remember so that book doesn't seem very well written but that's a side note).
Now, you can very well create an alias to a port, like myPort VAR PortB or to a pin, like myLED VAR PortB.0 - this works and there are no issues. The problem comes when you try to "alias" two different locations in memory to each other. I mean, I think it's pretty obvious that something like this wouldn't work right:
Code:
PortB.0 VAR PortC.0
PortB.0 = 1 ' Set both PortB.0 and PortC.0....Nope, won't work.
Again, AC VAR BIT[8] creates an array of 8 bits in memory (RAM). You can then, if you want, create meaningful names for the individual bits in that array by aliasing: AC_0 VAR AC[0] (which is not a very meaningful name but you get the idea.) In this case AC_0 refers to the exact same bit in memory as AC[0] does.
What you can not do is say AC[0] VAR PortB.0 or anything like that because (just as with PortB.0 VAR PortC.0 above) both the AC and PortB are already existing - at different memory locations in the PIC. They are two different entites, at two different adresses.
/Henrik.
If you think about it really is quite logical.
Bookmarks