Shop OBEX P1 Docs P2 Docs Learn Events
reading variables from assembly HELP! — Parallax Forums

reading variables from assembly HELP!

yellowcouchyellowcouch Posts: 3
edited 2008-12-01 21:14 in Propeller 1
I am trying to read a variable from assembly usiing full duplex serial plus

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-01 20:21
    Try asking your question again, include your source code as attachments to your message, describe what happens, what works, what doesn't work, what you're trying to do (in detail). Your statement (as given) doesn't make any sense since the Extended FullDuplexSerial object is intended for use by a Spin program, not assembly.
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2008-12-01 20:38
    To extend Mikes question, were is the variable and where do you want it?
    i.e. Are you trying to read a variable that is inside of FullDuplexSerial from Spin or take a variable from Spin and use it from within FullDuplexSerial.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Signature space for rent, only $1.
    Send cash and signature to CannibalRobotics.
  • yellowcouchyellowcouch Posts: 3
    edited 2008-12-01 20:43
    Basically we are trying read an assembly variable called 'count' and display it on the PST (Parallax serial Terminal). Using straight SPIN was to slow. Currently the asm code turns on an LED at Pin 16 based on the input of Pin 2. We are goint to have PIN 2 reset the counter once we have read its value. However, using WRLONG count, # seems to send the processor into never never land. (We have tried both real numbers #0, #1, and variables for the #) And so far nothing has worked

    I think the last non working version used
    Mov mem, par
    and then
    Wrlong count, mem after the 'add count, #1' line

    CON
    _clkmode = xtal1 +pll16x
    _xinfreq = 5_000_000
    var
    long stack [noparse][[/noparse]30]
    obj
    Debug: "fullduplexserialplus"
    PUB Main
    debug.start (31,30,0,115200)
    {launch cog to blink pin 16 endlessly}
    cognew(@follow,0) 'Launch new cog
    repeat
    Debug.str(string("count"))
    Debug.Dec (Count)
    waitcnt(clkfreq+cnt)
    DAT
    {follow P16}
    ORG 0 'Begin at Cog RAM addr 0
    follow mov dira, Opin 'Set pin to output
    :loop mov P2, ina 'Sets pin to input
    shl P2, #14
    mov outa,Opin 'set minimun delay here
    mov outa, P2
    add Count,#1
    jmp #: loop 'loop endlessly
    OPin long |< 16 'pin number
    IPIN long 2 ' clock cycles to delay
    Time res 1 'system counter workspace
    P2 long
    Count long
  • yellowcouchyellowcouch Posts: 3
    edited 2008-12-01 20:53
    Okay, here it is ...........

    "
    CON
    _clkmode = xtal1 +pll16x
    _xinfreq = 5_000_000
    var
    long stack [noparse][[/noparse]30]
    obj
    Debug: "fullduplexserialplus"
    PUB Main
    debug.start (31,30,0,115200)
    {launch cog to blink pin 16 endlessly}
    cognew(@follow,0) 'Launch new cog
    repeat
    Debug.str(string("count"))
    Debug.Dec (Count)
    waitcnt(clkfreq+cnt)
    DAT
    {follow P16}
    ORG 0 'Begin at Cog RAM addr 0
    follow mov dira, Opin 'Set pin to output
    :loop mov P2, ina 'Sets pin to input
    shl P2, #14
    mov outa,Opin 'set minimun delay here
    mov outa, P2
    add Count,#1
    jmp #: loop 'loop endlessly
    OPin long |< 16 'pin number
    IPIN long 2 ' clock cycles to delay
    Time res 1 'system counter workspace
    P2 long
    Count long
    "
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-01 21:14
    There are many things wrong with your program not the least of which is that it's unformatted. If you included it as an attachment, the formatting, which is important, would be maintained. You can use the [noparse][[/noparse] code ] and [noparse][[/noparse] /code ] tags around your code and these will maintain the spacing at least (leave out the extra spaces in the square brackets).

    There are some assembly language tutorials in the permanent messages threads at the top of the thread list in this forum. I suggest looking at the Assembly Code Examples for the Beginner and deSilva's Machine Language Tutorial.

    Two things:
    1) "P2 long" and "Count long" have to come before the RES directive and they need values ("P2 long 0" and "Count long 0"). The way you've written them, they don't occupy any space.
    2) The whole DAT block gets copied to a cog by the COGNEW to execute it. When executing, the labels stand for locations in the cog's memory, not the shared hub memory. When you reference Count in the Debug.dec statement, you're referring to a location in or (in this case) just following the DAT block. What you have to do is declare a long variable in the VAR section which you use in the Debug.dec statement, then pass the address of this variable to your assembly routine like "cognew(@follow,@variable)". Then you'll be able to refer to this in a WRLONG instruction like "WRLONG Count,PAR". I believe there are some examples of this in the tutorials I mentioned.
Sign In or Register to comment.