Shop OBEX P1 Docs P2 Docs Learn Events
Calling a 2nd object's ASM Code directly — Parallax Forums

Calling a 2nd object's ASM Code directly

SteelSteel Posts: 313
edited 2007-08-09 00:06 in Propeller 1
Is there a way to directly call ASM code in a different object?

I know you can use object1 to call a sub-routine in object2·that then calls·the ASM in Object2...But I would like to call the ASM in Object2 directly from Object1.

The reason is that Object1 is the location for my global variables.· I need the ASM in object2 to talk to these variables·while the code is running.

If I just call a sub-routine to start the ASM, I just pass the variables along...but then that is it.· The ASM in object2 doesn't actually see the·global variables...only what you passed it at passing time.

I would like the ASM in Object2 to be able to directly talk to the Global Variables in Object1.

Has anybody done this?

Thanks
Shaun

Post Edited (Steel) : 8/7/2007 11:42:30 PM GMT

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-08-07 23:52
    No, you can't, instead pass the variable pointer from Object 1 to Object 2's start method. A pointer is an address and therefore both objects are capable of communicating with each other because the have a common space they both know the location to.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • SteelSteel Posts: 313
    edited 2007-08-08 23:52
    Hmmm...·· I am trying to 'pass the pointer' down to the ASM in a second object...but it doesn't seem to be working.· Anybody see anything wrong with this code?

    ___________________________________
    OBJECT1 SPIN CODE:

    CON
    · {required constants}

    OBJ

    ··OBJ2· : "OBJECT_2"

    VAR
    ····· LONG VARTOPASS
    PUB
    ····· OBJ2.START(@VARTOPASS)
    ····· ....other code here....

    DATA
    ····· .........
    _________________________________________

    ________________________________________
    OBJECT_2 SPIN CODE:
    CON
    ····· {REQUIRED CON HERE}
    VAR

    PUB START(POINTER)
    ····· COGINIT(1,@ASM_CODE_START, POINTER)

    DAT
    ······· ORG ·0
    ·· ASM_CODE_START
    ······· MOV· ····· PTR,·············· PAR
    ······· RDLONG··· PASSED_DATA, PTR

    ·PTR··············· long· $0
    ·PASSED_DATA· long ·$0
    _________________________________________
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-09 00:06
    What you've shown looks ok. If it's not working, it's something you're not showing that's responsible.

    For example, why are you using COGINIT rather than COGNEW? How do you know what cogs are available?
Sign In or Register to comment.