Shop OBEX P1 Docs P2 Docs Learn Events
DAT vs CON with PASM — Parallax Forums

DAT vs CON with PASM

DynamoBenDynamoBen Posts: 366
edited 2010-03-30 04:03 in Propeller 1
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?

Comments

  • AleAle Posts: 2,363
    edited 2010-03-29 15:14
    Yes, they can be used. Just look at some examples or why not at the propeller manual.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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
  • DynamoBenDynamoBen Posts: 366
    edited 2010-03-29 15:26
    Ale said...
    Yes, they can be used. Just look at some examples or why not at the propeller manual.

    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
  • John R.John R. Posts: 1,376
    edited 2010-03-29 15:32
    Items in the CON block are either directives or "constants", and either case are dealt with at compile time. The items in the CON block never get to RAM, they are dealt with before the compiled instructions are sent to the Prop/EEPROM.

    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
  • AleAle Posts: 2,363
    edited 2010-03-29 15:47
    Dynamo, the manual actually says it, and you cited it. I think the missing part (for you at least) is what John said: They are only used during compilation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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
  • John R.John R. Posts: 1,376
    edited 2010-03-29 15:55
    Also, items in the CON block are only available in the file they are in. In other words, if you define a constant for a value, e.g. XAxis = 0, the name "XAxis" will be replaced by the value zero, but only in the current file/object. This is to prevent conflicts in different files that might have a common name, but different meanings/values.

    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 HeinDave Hein Posts: 6,347
    edited 2010-03-29 16:12
    The code shown below will load a value of 3 into "temp" and add 4 to it.· Values defined in a CON section are just symbolic representations of numbers.· You would used the symbolic labels the same way you use numbers.

    Dave

    CON
    · three = 3
    · four = 4
    PUB dummy
    DAT
    · mov temp, #three
    · add temp, #four
    temp res 1
  • DynamoBenDynamoBen Posts: 366
    edited 2010-03-29 17:24
    John R. said...
    Also, items in the CON block are only available in the file they are in. In other words, if you define a constant for a value, e.g. XAxis = 0, the name "XAxis" will be replaced by the value zero, but only in the current file/object. This is to prevent conflicts in different files that might have a common name, but different meanings/values.

    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.
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-03-30 04:03
    That's not a 100% true. You can use a CON value defined in an object in the code that uses this object:

    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.
Sign In or Register to comment.