Shop OBEX P1 Docs P2 Docs Learn Events
PASAM - PAR Register — Parallax Forums

PASAM - PAR Register

SiriSiri Posts: 220
edited 2008-09-17 14:16 in Propeller 1
I am trying to understand the basic principles of PASAM.

My question is - In the course of the boot up procedure The DATA is first copied to Main RAM(HUB) and then copied to COG RAM.
When the data is copied does the data is copied in the same sequence as they are written by the programmer.

Example:

pin1 long
pin 2 long
time long


pin5 res
stock res

If they are not copied how does one - in the following code know where the variables are located.



{ mov p,par ' load parameter pointer into p (points to global variables)
' p is just a copy and keeps par unchanged for later.
rdlong _pin1,p ' load first parameter into _pin1 (cog ram)
add p,#4 ' Increment address to next global variable, the address is in bytes(8-bit) so
' it needs 4 adding to get to the next long(32-bit/4 bytes)
rdlong _pin2,p ' Load second parameter pin2 into _pin2
add p,#4
rdlong _on_time,p ' get the on time
add p,#4
rdlong _off_time,p ' and the off
}

Hoe did he know that the long after "PIN1" was the long containing the address of "PIN2" etc. so he could move up to find the other addresses.


The second Question is what is the difference when you declare variables as "long" and "Res". Is it when declared as "Longs" you can
access from "SPIN" and as "RES" only by assembly.

Thank you

SIRI

Comments

  • BradCBradC Posts: 2,601
    edited 2008-09-16 13:43
    If you declare variables in your object

    VAR
    long Pin1, Pin2, On, Off

    they will be in memory in the same order they are declared. (For the same size of variable byte/word/long).

    In PASM Res reserves a location in COG ram, however it is not occupied in the hub, so when the cog is loaded the data initially in a RES location is whatever came after the last real allocation in the DAT block. This is why you must :

    a) always place your RES variables after anything else in your assembler code.
    b) always assume they are going to be full of garbage when the cog boots.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • SiriSiri Posts: 220
    edited 2008-09-17 14:16
    Thanks Bradc
    I think now I have most of the questions answered.

    Siri
Sign In or Register to comment.