Shop OBEX P1 Docs P2 Docs Learn Events
Re-using Hub space after a cog is loaded - example - Page 2 — Parallax Forums

Re-using Hub space after a cog is loaded - example

2»

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-05-08 08:28
    Something like that. Every label (i.e. symbol) exists in a dictionary or symbol table. At the beginning of an object's compilation, the only dictionary in existence would be the global dictionary. In Spin, as it exists now, whenever a method header is encountered a new, nested dictionary is created (or appended to the global dictionary) for its parameter names, for result, and for local variable names. At the end of compiling that method, the local disctionary is discarded (i.e. popped). The same holds for PASM :local labels: their dictionary exists only temporarily. With defined namespaces, the programmer can create and destroy dictionaries, define which dictionary a label lives in, and specify, at multiple points within the program, in which order dictionaries should be searched for a referenced label (sort of like PATH directives for files). That way names can be defined, used, and reused under complete control of the programmer.

    -Phil
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-05-08 12:51
    Forget what I said in my last post.· We don't need to put any code after the cog 0 stack.· We don't even need to change the prop tool.· All you need to do is group all of the initialization and cog-loading objects together.· This means that the cog loading needs to be done in a seperate object from the rest of the cog interface code.· I think the following·object solves the problem.· This start function is called once at the beginning of execution, and then all of the memory from startaddr to endaddr is available.

    Dave
    OBJ
      ser : "startserial"
      vid : "startvideo"
      sd : "startsd"
      init "initworld"
      dummy : "dummy"
    PUB start(pserialvars, pvideovars, psdvars, pworldvars) | startaddr, endaddr
      ser.start(pserialvars)
      vid.start(pvideovars)
      sd.start(psdvars)
      init.start(pworldvars)
      startaddr := @@0
      endaddr := dummy.getstartaddr
      return (startaddr << 16) | endaddr
    
Sign In or Register to comment.