Shop OBEX P1 Docs P2 Docs Learn Events
assembly for two cogs — Parallax Forums

assembly for two cogs

electric550electric550 Posts: 122
edited 2009-07-20 13:09 in Propeller 1
I was wondering if anyone had a recommendation on formatting assembly code for two cogs in on document. Does it require two org statements and two fit statements. Or should I split the two programs into two different files and call them as objects? If there is an example that someone could point me to, or a suggestion would be good.

For example
CON
...........

OBJ
..........

Var
long var1
long var2

Pub Start
cognew(@Assembly1,@var1)
cognew(@Assembly2,@var2)

DAT
'--------------------------------------------------------------
       org 0 
Assembly1
                        MOV   V1, PAR
                      
                        V1   res     1
       FIT 496
'--------------------------------------------------------------
       org 0 
Assembly2
                        MOV   V2, PAR
                      
                        V2   res     1
       FIT 496



I am just trying to make sure that assembly gets loaded into its own cog. I assume that when cog new gets called it loads the assembly from the specified identifier until it reaches the fit statement?

                

Comments

  • Nick MuellerNick Mueller Posts: 815
    edited 2009-07-19 19:37
    Doesn't it require a second DAT right before the second org? At least, it doesn't hurt.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-07-19 19:39
    Yep ... two org and two fit is correct!

    The ORG is a compiler statement which tells the compiler how to translate the HUB adresses (that's where the PASM code lives during program-load) to the COG adresses (that's where the program shall run). It's an offset that has to be used in all the labels you use inside of that DAT section. The FIT is a compiler statement which tells you if a PASM program is to big to fit into the COG-RAM. If you are sure that your PASM is smaller you don't really need it.

    So, if you have 2 PASM parts in your program, you need 2 ORG 0 statements if these PASM programs are started in a COG. Only in case you work with overlays, then it makes sense to have an ORG statement which is different from 0.

    PS: My guess is you don't need 2 DAT sections, but because of the different colors it makes sense as you can distinguish the different PASM programs.
  • electric550electric550 Posts: 122
    edited 2009-07-19 19:45
    Thanks!
  • ericballericball Posts: 774
    edited 2009-07-20 13:09
    Also - don't have any register usage over an ORG boundary. Put any RES for the first PASM routine just before the FIT/ORG.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
Sign In or Register to comment.