Shop OBEX P1 Docs P2 Docs Learn Events
Reusing DAT block hub RAM after PASM loaded into cog — Parallax Forums

Reusing DAT block hub RAM after PASM loaded into cog

I'm running out of memory and it just occurred to me that once I've launched PASM code into a cog to run, I can reclaim and reuse the DAT block from hub RAM for other purposes. Before I spend too much time on this, I'm hoping I can validate this as a reasonable approach.

1) Is there any reason this is a bad idea? (I realized that if I want to launch the code into another cog (or reboot/restart in the same cog) that will require "finding" the original DAT block contents (from EEPROM).
2) To determine where the hub memory for the DAT block begins and ends, I plan to simply add a label (symbol) to the first and last (non-RES) locations. So I'd typically label the line after the ORG 0 directive ("beginDatMem"), and the last location preceding the first RES "allocation" ("endDatMem"). I'd use the address "beginDatMem" as my first available hub memory location, and (address of "endDatMem" - address of "beginDatMem") to calculate the number of bytes now available to me.
3) Should I need to retrieve the original DAT contents (to relaunch a cog, for instance) is there a direct, simple mapping from hub address to where it is stored/loaded from EEPROM? I wrote a loader to copy any arbitrary contiguous memory from EEPROM and load it into hub RAM and could reuse this if I can figure out where the DAT block is in EEPROM.

Thanks in advance for any info on this.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2016-11-28 17:20
    1. It's not a bad idea at all, and you seem well aware of the caveats.

    2. That should work fine.

    3. The address mapping couldn't be easier: the byte addresses in hub RAM and EEPROM are the same.

    -Phil
  • Thanks for the confirmation Phil. This seemed so easy, straightforward and obvious that I figured it was too good to be true.
Sign In or Register to comment.