Shop OBEX P1 Docs P2 Docs Learn Events
rdlong command??? — Parallax Forums

rdlong command???

krazyideaskrazyideas Posts: 119
edited 2008-11-20 02:56 in Propeller 1
Hello

I want to read a varuble that I have in spin code and use it in a assembly program.

say I have the fallowing

Var
··· long pluse

Pub
·(((pluse + 10) / 5)*15)

Dat

#1························ rdlong UP,·· pluse



UP long

The problem is whit the rdlong UP, pluse but I don't know what to do.
any help would be great
Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-18 02:29
    Please explain what you're trying to do. The little program fragment that you've posted doesn't make any sense and it's not at all clear that you understand how assembly language and Spin work together. You can't just mix assembly and Spin code. A Spin routine can start up an idle cog (processor) with an assembly program and wait for that cog to execute the program (or interact with it) and they can share variables. Have a look at some of the examples in the "sticky thread"s (like Propeller Programming Tutorials) at the top of the thread list in this forum.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-11-19 16:59
    Try this:

    VAR
      long pluse
    
    PUB
      pluse := (pluse+10)*15/5   '  <- using integer math always divide after multiply
      pluse_ptr := @pluse ' <- set pointer in DAT section to point to variable in VAR section
      cognew(@pasmstart, 0) ' <- launch a cog running PASM code starting at @pasmstart
      etc...      ' <- original cog running SPIN continues here while PASM code continues running in new cog
    
    DAT
                             org
      pasmstart         rdlong UP, pluse_ptr
                             etc...
                             etc...
    
      pluse_ptr         long  0
      UP                  long 0
    
    
    



    Make sure your pointer variables are within 497 longs after the start of your PASM code so they will be copied into the cog with the code. Always initialize your pointers BEFORE doing cognew() because they get copied into the cog. When you call cognew() on PASM code, it begins with the address at the beginning of your PASM code (@pasmstart) and copies the subsequent 497 longs from HUB to the cog memory, bringing your pointer (pluse_ptr) along for the ride! I find this is easier than dealing with PAR.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup

    Post Edited (Ken Peterson) : 11/19/2008 5:17:25 PM GMT
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-11-20 02:56
    I think this would be a good place to reiterate my recommendation for DeSilva's Machine Language Tutorial

    http://forums.parallax.com/forums/default.aspx?f=25&m=209237

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
Sign In or Register to comment.