Shop OBEX P1 Docs P2 Docs Learn Events
PTRA Data pointer passed from COGINIT . PTRB Code pointer passed from COGINIT. — Parallax Forums

PTRA Data pointer passed from COGINIT . PTRB Code pointer passed from COGINIT.

PTRA is loaded with with a value when COGINIT used. Documentation says PTRB code pointer passed
from COGINIT. What does that mean?
Regards
Bob (WRD)

Comments

  • Bob,

    From the COGINIT section of the 'Parallax Propeller 2 Documentation':
    S/# = address This value is either the hub address from which the target cog will
    load from, or it is the cog/hub address from which the target cog
    will begin executing at, depending on D[5]. This 32-bit value will be
    written into the target cog's PTRB register
    .

  • So PTRA is used for what PAR was used in P1, to give a Parameter value to the started COG.

    PTRB contains the Address the COG code is started from.

    Mike

  • I posted a comment about PTRA yesterday, but it probably got lost due to the server issue. The SETQ instruction is used to pass a value in PTRA. If used, the SETQ must immediately precede COGINIT.

  • RaymanRayman Posts: 14,641

    I once asked what good this PTRB value actually has and someone had a reply that made sense, but I've since forgot what that was...

  • Wuerfel_21Wuerfel_21 Posts: 5,053
    edited 2021-10-06 00:14

    @Rayman said:
    I once asked what good this PTRB value actually has and someone had a reply that made sense, but I've since forgot what that was...

    If you need to load something into LUT on startup, that PTRB thing makes it really easy

    DAT
          org $000
    entry
          add ptrb,#@lutcode-@entry
          setq2 #511
          rdlong 0,ptrb
    
          ' Imagine more code
          fit $1F0
    
          org $200
    lutcode
          ' Imagine code/data
          long $DEADBEEF[512]
          fit $400
    
  • evanhevanh Posts: 15,915

    @"Dave Hein" said:
    I posted a comment about PTRA yesterday, but it probably got lost due to the server issue.

    Still there - https://forums.parallax.com/discussion/comment/1529494/#Comment_1529494 Just question was asked twice.

  • @evanh , thanks. The previous forum software had a way to list previous posts. The current forum software doesn't have that, but I now see that there is a "Participated" link that list the threads that I posted in.

    I've thought about using the PTRB value as an easy way for relocatable code to know where it's loaded. The relative jumps makes it fairly easy to create relocatable code. I haven't tried relative addressing for variables, but I think using PTRB with an offset would work. That would produce position-independent-code that could be loaded anywhere in hub RAM.

  • @"Dave Hein" said:
    @evanh , thanks. The previous forum software had a way to list previous posts. The current forum software doesn't have that, but I now see that there is a "Participated" link that list the threads that I posted in.

    You can get to a list of all comments from your (or anyone else's) profile page.

  • @Wuerfel_21 , thanks.

  • RaymanRayman Posts: 14,641

    @Wuerfel_21 said:
    If you need to load something into LUT on startup, that PTRB thing makes it really easy

    >

    Right. I think that was it...

Sign In or Register to comment.