DAT vs CON with PASM
DynamoBen
Posts: 366
I'm sure this has been covered before but I can't seem to find the info anywhere. Am I correct in assuming that items in a CON block cannot be used by PASM?
If that is the case then my only option would be to move the items that need to be "seen" by PASM into a DAT block, correct?
If that is the case then my only option would be to move the items that need to be "seen" by PASM into a DAT block, correct?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH
pPropQL: propeller.wikispaces.com/pPropQL
pPropQL020: propeller.wikispaces.com/pPropQL020
OMU for the pPropQL/020 propeller.wikispaces.com/OMU
pPropellerSim - A propeller simulator for ASM development sourceforge.net/projects/ppropellersim
I've been through the manual a number of times over the last 3 days looking for the answer to this question. At no point does it say specifically where the CON block exists in memory (COG or HUB).
All the manual says is:
"The Constant Block is a section of source code that declares global constant symbols and global Propeller configuration settings."
Which implies that any object and any cog can use anything in the CON block. The question was asked to ensure that this is really the case in practice.
Post Edited (DynamoBen) : 3/29/2010 3:33:57 PM GMT
Directives set up the configuration of the Propeller (clock source, etc.).
The values of the Constants are substitued in the first passes of the compiler.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
Click here to see my Nomad Build Log
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH
pPropQL: propeller.wikispaces.com/pPropQL
pPropQL020: propeller.wikispaces.com/pPropQL020
OMU for the pPropQL/020 propeller.wikispaces.com/OMU
pPropellerSim - A propeller simulator for ASM development sourceforge.net/projects/ppropellersim
If you have a constant in another Object you call, you can use the OBJ#Const syntax.
The ansers are indeed in the manual (make sure you have version 1.1, as there are updates and clarifications). This type of thing is not necessarly "crystal clear" in the Prop (or any other) manual. Focus on the section "Scope" under the CON section (I believe, but I don't have ready access to manual at work).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
Click here to see my Nomad Build Log
Dave
CON
· three = 3
· four = 4
PUB dummy
DAT
· mov temp, #three
· add temp, #four
temp res 1
This was going to be my follow on question, thanks for preemptively answering it. So in essence items in CON are similar to true, and false but only to the extent that they function in the current file, not across the entire system.
Thanks all for the responses, this helps me to better understand the CON block.
File testcon.spin:
con
BAUDRATE_9600 = 1
BAUDRATE_56400 = 2
pub whatever( baud_no )
.....
File useit.spin:
obj
TST: "testcon"
main
whatever( TST#BAUDRATE_9600 )
....
As already said, a constant gives a number a defined name. If you don't use a constant it will never end up in any RAM. If you use it it will be stored wherever it's used. A constant's purpose is to give numbers a self explaining name, like in my example. And it allows to have a central place for changing values. For example you'd find pin numbers defined in a CON-block, so they can easily being changed without searching the whole module for ocurrences of the pin numbers.