PDA

View Full Version : assembly for two cogs



electric550
07-20-2009, 03:29 AM
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?

Nick Mueller
07-20-2009, 03:37 AM
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 (http://www.yadro.de)

MagIO2
07-20-2009, 03:39 AM
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.

electric550
07-20-2009, 03:45 AM
Thanks!

ericball
07-20-2009, 09:09 PM
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 (http://forums.parallax.com/showthread.php?p=800114)
NTSC & PAL driver templates: ObEx (http://obex.parallax.com/objects/483/) Forum (http://forums.parallax.com/showthread.php?p=803904)
OnePinTVText driver: ObEx (http://obex.parallax.com/objects/480/) Forum (http://forums.parallax.com/showthread.php?p=822453)