Shop OBEX P1 Docs P2 Docs Learn Events
Launching an ASM routine from a different object — Parallax Forums

Launching an ASM routine from a different object

NefastorNefastor Posts: 14
edited 2007-01-07 11:14 in Propeller 1
Hi all,

I can't find information on the syntax of cognew / coginit for this particular case :

- I have an object "A.spin", which declares an instance of object "B.spin", like so :

OBJ
   BINST : "B"




Object B contains a DAT block with some assembler (let's say at label :start)

And then in object A I want to have a cog running that assembler.

The chip's manual only shows how to launch a cog to run assembler if the DAT block is in the same object as the cognew instruction :

    cognew (@start, parameter)




So what do I do ? I tried a few obvious things like cognew (BINST.start, parameter) but none of it compiles, it keeps saying it expects either a variable, or an expression, or something else...

Of course there's always the quick-and-dirty fix of copying all my code into a single object, but that's not the point of having objects now is it ? tongue.gif

I hope you guys can shed some light on this issue, thanks [noparse]:D[/noparse]

Jean

Comments

  • BTXBTX Posts: 674
    edited 2007-01-06 15:43
    Jean:

    To call from A.spin the B.asm running cog, you must have some like this:
    {{ B.spin}}
    

    PUB Start 
             cognew(@asmlabel, parameter) 
     
    DAT
    asmlabel      xxxxxx     ' asm command
                  xxxxxx     ' asm command
                  etc.       ' asm command 
    
    

    So from A.spin you call it: BINST.Start and that runs the asm code in the another cog.

    Regards.

    Alberto.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-06 16:24
    Another way to do this is to have a routine in B that returns the address of the assembly block and this is used in A to start the cog:
    {{ B.spin }}
    PUB getAddress
       return @asmlabel
    DAT
    asmlabel xxxxx
    
    {{ A.spin }}
    PUB start | startPoint
      startPoint := getAddress
      cognew(startPoint,parameter)
    
    
  • NefastorNefastor Posts: 14
    edited 2007-01-07 11:14
    Thanks guys, I think I've got it [noparse]:D[/noparse]

    Man I can't wait for my chips to arrive so I can start running this code [noparse]:)[/noparse]

    Jean
Sign In or Register to comment.