Launching Cogs in Assembly Trouble
pjv
Posts: 1,903
Hi All;
I'm trying to learn Propeller assembler, and am having difficulty in understanding what is going wrong when I launch a cog from an assembler routine.
A simple program to launch 3 "toggling" assembler cogs from spin works exactly as expected, but when I modify it (delete launching the second from spin) to launch one of them from one of the spin-launched assembler routines, the direction register seems to get messed up. Through current meassurement observations, I believe that·the·affected·cog IS actually being launched.
When spin launches cogs1, 2 and 3, I get toggling on all 3 cog lines, but when I comment-out the spin-launch of cog2, and enable the cog1 launch of cog2, I get no output on cog2's· "4"pin.... as if the cog2 direction register gets cleared. Replacing the three direction setting instructions "mov· dira,#num" with "or· dira,#num" does not fix the problem.
What am I doing wrong??
Cheers,
Peter (pjv)
I'm trying to learn Propeller assembler, and am having difficulty in understanding what is going wrong when I launch a cog from an assembler routine.
A simple program to launch 3 "toggling" assembler cogs from spin works exactly as expected, but when I modify it (delete launching the second from spin) to launch one of them from one of the spin-launched assembler routines, the direction register seems to get messed up. Through current meassurement observations, I believe that·the·affected·cog IS actually being launched.
_clkmode = xtal1 _clkfreq = 5_000_000 PUB Launch 'this should be cog0 dira :=1 outa := 1 outa := 0 coginit(1, @One,0) outa := 1 coginit(2, @Two,0) 'disable this line when enabling the launch from cog2 outa := 0 coginit(3, @Three,0) outa := 1 DAT org 'this should be cog1 One mov dira,#2 xor outa,#2 xor outa,#2 ' coginit AssyLaunch 'assembly launch of cog2 disabled for now, enable when disabling spin launch of cog2 Loop1 xor outa,#2 jmp #Loop1 AssyLaunch long @Two <<4 | %0_010 'particulars for launching cog2 DAT org 'this should be cog2 Two mov dira,#4 xor outa,#4 Loop2 xor outa,#4 jmp #Loop2 DAT org 'this should be cog3 Three mov dira,#8 xor outa,#8 Loop3 xor outa,#8 jmp #Loop3
When spin launches cogs1, 2 and 3, I get toggling on all 3 cog lines, but when I comment-out the spin-launch of cog2, and enable the cog1 launch of cog2, I get no output on cog2's· "4"pin.... as if the cog2 direction register gets cleared. Replacing the three direction setting instructions "mov· dira,#num" with "or· dira,#num" does not fix the problem.
What am I doing wrong??
Cheers,
Peter (pjv)
Comments
I thought I had pre-loaded AssyLaunch with the correct hub address..... at least according to the HEX window of the listing, as well as hand-decoding the instructions. So I modified my code to read identical to Mike's suggestion (plus of course deleting the spin launch of cog2 and enabling the cog1 launch of cog2), and it still yields the same results; no toggling on cog2.
@Tim: I'm still trying to wrap my head around this symbol's differing actions...... I spent a lot of time today counting and decoding instructions from the HEX listing window.
What else might be wrong..... could there be a timing issue because spin is still getting cog3 loaded while cog1 is trying to load cog2?
Cheers,
Peter (pjv)
Do you realise the address you need to put in [noparse][[/noparse] 17..4 ] is the top 14 bits of the address?
Try
This will work as PAR automatically zeros the bottom 2 bits anyway. Ordinarily it's a good idea to mask it first. I use something like this in spin.
This way you use the spin interpreter to fix the object offset for you and remove any guesswork. If you don't want to do that, and you are *sure* you are always going to be the top object then you could do :
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lt's not particularly silly, is it?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lt's not particularly silly, is it?
You're the man!
I now see in my code I shifted 4 left when it should have been 2, because the address for the Parameter register is 14 bits long. Shifting in zeros then of course permits the new/old·cog·bit and chosen cog number just to be merged into the long. And of course the $10 starting offset has to be added..... I had earlier included that, but with the incorrect shifts the result was wrong.
It·can really as simple as the following code:
Anyhow, up and running, so THANKS!
Cheers,
Peter (pjv)