Shop OBEX P1 Docs P2 Docs Learn Events
Where should the DAT section be? — Parallax Forums

Where should the DAT section be?

william chanwilliam chan Posts: 1,326
edited 2008-09-11 17:13 in Propeller 1
Should the DAT section preferably be before the SPIN code or at the end of all the SPIN codes?

I am afraid that if I declare a DAT section with strings above the VAR section like

strName     BYTE "Hello",0



the variables in the VAR section (that is placed after the DAT section) may no longer be aligned by LONG.

That means that if I do a
eeprom.WriteLong(eeprom#bootpin,eeprom#eeprom, @mylongnum,mylongnum)



it may hit a page boundary and cause problems b'cos the address of the variable mylongnum is no longer aligned by long.

What you guys think?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my

Comments

  • BradCBradC Posts: 2,601
    edited 2008-09-11 16:45
    The compiler takes care of all of it for you.
    You can pretty much put anything anywhere and it will sort it out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-11 16:47
    The compiler makes sure that things that are declared as long get aligned as long. You don't need to worry about it. Put your DAT section anywhere you want.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • hippyhippy Posts: 1,981
    edited 2008-09-11 17:13
    It depends on what else is in the code. If the data isn't long aligned then there will be problems using it as if it were long aligned no matter where it's placed.

    Put a "long" in front if you're not sure ...

                LONG
    strName     BYTE "Hello",0
    
    
    
Sign In or Register to comment.