Shop OBEX P1 Docs P2 Docs Learn Events
Variables in DAT block not getting updated in Parallax serial terminal — Parallax Forums

Variables in DAT block not getting updated in Parallax serial terminal

Red_DogRed_Dog Posts: 7
edited 2011-09-05 06:07 in Propeller 1
Hello,

I'm experimenting with propeller assembly language and trying to view variables using the dec function in the parallax serial terminal object. I can't seem to get a very basic code block to work. For some reason the variable being monitored in PST isn't getting updated, but just shows the value the variable is initialized with. What am doing wrong?



countertest.spin

Thanks in advance

Comments

  • Clive WakehamClive Wakeham Posts: 152
    edited 2011-09-05 02:43
    Shouldn't the line view.dec(time)
    be instead;
    view.dec(long[@time]) ???
  • Red_DogRed_Dog Posts: 7
    edited 2011-09-05 04:56
    Thanks for the quick reply Clive,

    I tried that and it didn't work either, I get the same results either way. I think I might be trying to use the wrong tool (PST) for the job. It will read whatever I initialize the variable to with either syntax, however it doesn't update. I'll download the lite debug tool and see if that works better.

    Cheers,
    Brent
  • nutsonnutson Posts: 242
    edited 2011-09-05 05:32
    The most important character in PASM is #. Adding one to a register: add reg, #1, jumping to an address: jmp #address-label
  • kuronekokuroneko Posts: 3,623
    edited 2011-09-05 05:52
    time and long[@time] are the same in this context. Your problem is elsewhere (apart from the # and carry flag issue). The time (DAT) variable - as far as SPIN is concerned - only lives in hub RAM. Once the cog is started its code section is copied from hub to cog RAM. Then you keep changing the cog instance of time but never update the original in hub RAM.
  • AribaAriba Posts: 2,690
    edited 2011-09-05 06:07
    Red_Dog

    The time variable (register) is only changed inside the cog ram of the new started assembly cog. You can't access this variable from a Spin code running in another cog.
    The compiler builds an image of the assembly code in the hub ram, which is then loaded to the cog ram at cognew. Now the assembly code runs independant inside the cog and the hub ram image stays always at its initial state. If you access the time variable from Spin you read the hub ram version.
    To see the time value you need to write it to the hub ram inside the assembly cog. For that you need the hubram address of time, the simplest is you pass that in the par register:
    cognew(@compaddress, @time)
    then you write the current value inside the :loop, i.e.right after the waitcnt instruction:
    wrlong time,par
    Now you should see a change of the value.

    Andy
Sign In or Register to comment.