Shop OBEX P1 Docs P2 Docs Learn Events
How to find an objects address in hub — Parallax Forums

How to find an objects address in hub

PropHeadPropHead Posts: 2
edited 2013-04-25 08:24 in Propeller 1
I realized that once a cog is loaded, and as long as I never stop and start the cog, I should be able to reclaim the space in hub ram where the code resides that was copied into the cog when it was started.
Is there a way to calculate the absolute location where an object resides in hub ram?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-25 08:10
    You can't calculate the absolute location where an object resides in hub ram. You can get the address of the space used by assembly code in the object though. You need to add a method (PUB routine) to the object that returns the hub address of the code. If the first location in the DAT section for the code is called "code", then the method returns "@code". You might have another method that returns the length of the DAT section. To get that, you'd add a label to the assembly code after the last instruction or data long, but before any RES directives, say "lastLoc", and return "@lastLoc - @code".
  • PropHeadPropHead Posts: 2
    edited 2013-04-25 08:24
    Thank you. I already use the method you describe but I Need the address in an asm routine in another cog and I am currently fetching the value in spin from the cog, passing it as a param to the other cog that runs the asm code. I was hoping for a more direct route. Thank you for responding!
Sign In or Register to comment.