Shop OBEX P1 Docs P2 Docs Learn Events
ASM Webinar Follow-up Questions — Parallax Forums

ASM Webinar Follow-up Questions

CassLanCassLan Posts: 586
edited 2009-12-23 18:41 in Propeller 1
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

Prop Forum Search (Via Google)

·

Comments

  • AleAle Posts: 2,363
    edited 2009-12-23 16:46
    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
    pPropQL: propeller.wikispaces.com/pPropQL
    pPropQL020: propeller.wikispaces.com/pPropQL020
    OMU for the pPropQL/020 propeller.wikispaces.com/OMU

    Post Edited (Ale) : 12/23/2009 4:56:10 PM GMT
  • BeanBean Posts: 8,129
    edited 2009-12-23 18:19
    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


    Post Edited (Bean (Hitt Consulting)) : 12/23/2009 6:29:31 PM GMT
  • ericballericball Posts: 774
    edited 2009-12-23 18:41
    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
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
Sign In or Register to comment.