Shop OBEX P1 Docs P2 Docs Learn Events
How to make multiple entry points into a single assembler code? — Parallax Forums

How to make multiple entry points into a single assembler code?

AlarusAlarus Posts: 48
edited 2013-06-19 06:35 in Propeller 1
How to make multiple entry points into a single assembler code?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-17 05:57
    It's easy as long as you remember that each entry has to have an exit even if all the exits are the same location:
    entry1      nop   ' 1st entry
    entry2      nop   ' 2nd entry
    entry3      nop   ' 3rd entry
    '
    entry3_ret        ' these labels can be in any order
    entry2_ret
    entry1_ret  ret   ' single exit
    
    Note that a CALL instruction is actually a macro that generates a JMPRET instruction, so that "CALL <entry>" generates "JMPRET <entry>_RET,#<entry>". Look in the Propeller manual for a description. The RET is just a JMP instruction with the destination address not filled in. The CALL will do that when it's executed.
  • AlarusAlarus Posts: 48
    edited 2013-06-17 08:20
    Thank you, Mike Green! By using multiple entry points I can run a few cog?

    In the object some procedures are written in the PASM (Init, StartMaster, StartSlave).
    I need to run a procedure StartMaster or StartSlave depending on the procedure Init.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-17 08:32
    "I can run a few cog?" ... I'm not sure what you mean. There are no "procedures" in PASM. Usually there's a Spin interface with some methods that are called by your main program and there's a PASM program that's started in a cog by the object's initialization routine. The PASM program and the interface methods communicate via a shared area of memory. You'll need to tell us more about what you're trying to do and you'll need to post your source code. If you're using an existing object, provide a link to it at least. Use the Attachment Manager to attach the source files to a reply (use the Go Advanced button when making your reply).
  • JonnyMacJonnyMac Posts: 9,107
    edited 2013-06-17 09:19
    I've attached my 1-Wire object which demonstrates how to call discrete PASM routines from Spin. The setup and implementation is fairly common and easy to use. This demonstrates what Mike was talking about in post #4.
    Usually there's a Spin interface with some methods that are called by your main program and there's a PASM program that's started in a cog by the object's initialization routine. The PASM program and the interface methods communicate via a shared area of memory.
  • kuronekokuroneko Posts: 3,623
    edited 2013-06-19 06:35
    To add some variety have a look at [post=1136990]this driver[/post]. It avoids jump tables altogether.
Sign In or Register to comment.