PDA

View Full Version : ASM Webinar Follow-up Questions



CassLan
12-23-2009, 09:50 PM
Almost done watching the ASM Webinar...thanks so much for it Parallax!

I have a question at about 39 minutes in this code is up and being discussed:


CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

VAR
long Count

OBJ
pst : "Parallax Serial Terminal"

PUB Main
pst.start(115200)
cognew(@Asm, @Count)
repeat
pst.Dec(Count)
pst.NewLine
waitcnt(clkfreq / 100 + cnt)

DAT
Asm org
mov Addr, par 'Get Spin variable address
Loop add Value, #1 'Add 1 to Value
wrlong Value, Addr 'Write Value to Spin variable
jmp #Loop 'Loop

Addr long 0
Value long 0

It was brought up to illustrate passing information from Spin, to a new Asm cog being launched..and I guess vice/versa
So the par register of the new cog, now contains the·address of Count?
Then the first line of Asm code copies that address to the long known as Addr?
So Now..the long Addr which resides in cogram contains the address of the long Count which resides in main ram?
the long Value which resides in cogram gets incremented by 1
Then the contents of the long Value get written to the address Addr which is really the long Count in mainram?
Then it loops around.

Do I have this right? Why can't you leave the par register with the needed address first passed to it?

If I had a DAT Section which contained Longs BEFORE the org statement..is that kept in Main RAM?
If I have 2 Assembly routines each under 496 Longs each meant to run in seperate cogs, what stops the 2nd one from being copied into the 496 Long cog ram..the org statement?

Again...what a great Webinar!!!!!
Rick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


NYC Area Prop Club (http://www.gothampropclub.com)

Prop Forum Search (Via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)

·

Ale
12-24-2009, 12:46 AM
yes to all. And yes you can use PAR in the wrxxx/rdxxx instructions.
coginit copies 496 (maybe 512) starting at the address you give. It doesn'T care/know what it copies or if another portion is going to end in another COG. Each COG has its own COG RAM that is separated and not mapped to HUB RAM. You can have 3 COGs with the same code, just copies 3 times for each one of the COG RAMs.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH (http://propeller.wikispaces.com/MATH)
pPropQL: propeller.wikispaces.com/pPropQL (http://propeller.wikispaces.com/pPropQL)
pPropQL020: propeller.wikispaces.com/pPropQL020 (http://propeller.wikispaces.com/pPropQL020)
OMU for the pPropQL/020 propeller.wikispaces.com/OMU (http://propeller.wikispaces.com/OMU)

Post Edited (Ale) : 12/23/2009 4:56:10 PM GMT

Bean
12-24-2009, 02:19 AM
par is usually copied to another cogram variable because par is read-only. You can only RDxxx/WRxxx the 1st long by using par directly.

But you are correct, in this example you could have used par directly.

When code is loaded into a cog, it moves 496 longs always. So whatever is in hubram after the code gets copied too.

What the org command does it tell it what the COG address is for labels. Assume this code below is in HUB address $1000. See how ORG dictates the labels address.



HUB
Addr PASM
---------------------------------
ORG 0
$1000 start jmp #start ' jmp #0
$1004 start2 jmp #start2 ' jmp #1
ORG 0
$1008 start3 jmp #start3 ' jmp #0
$100C start4 jmp #start4 ' jmp #1

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropBASIC home page www.propbasic.com (http://www.propbasic.com)


Post Edited (Bean (Hitt Consulting)) : 12/23/2009 6:29:31 PM GMT

ericball
12-24-2009, 02:41 AM
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

VAR
long Count

OBJ
pst : "Parallax Serial Terminal"

PUB Main
pst.start(115200)
cognew(@Asm, @Count)
repeat
pst.Dec(Count)
pst.NewLine
waitcnt(clkfreq / 100 + cnt)

DAT
org 0
Asm mov Addr, par 'Get Spin variable address
Loop rdlong Value, Addr 'Read Value from Spin variable
add Value, #1 'Add 1 to Value
wrlong Value, Addr 'Write Value to Spin variable
jmp #Loop 'Loop
Value res 1
fit 496




I'm hoping the webinar code included the rdlong (which I've added) otherwise the code won't do much.

An additional important note about PAR is it's only 14 bits - long addresses only!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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)