Shop OBEX P1 Docs P2 Docs Learn Events
assembly language question in "machinelanguage.pdf" tutorial — Parallax Forums

assembly language question in "machinelanguage.pdf" tutorial

jbw2jbw2 Posts: 1
edited 2015-03-29 14:15 in Learn with BlocklyProp
I am trying to learn assembly language programming. I do understand the basics of Spin and C and the parallax hardware. I have gone thru the “assembly_09” tutorial and have started the “machinelanguage.pdf” tutorial. I am not able to understand the programming example 2 on pg 10. it is my understanding that the instruction:
patternaddr := @aCounter places the address of “acounter” into “patternaddr”, so then why is the, value of, rather than the, address of, “acounter” placed into “outa” by the instruction: RDLONG OUTA, patternAddr?

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2015-03-29 13:46
    rdlong and friends get values from specific hub addresses so that hub data can be used by the cog.

    Your answer is in how rdlong works. It needs a hub address to know what long to get and another cog address to know where to put it.

    It can be used to fetch an address, and whether or not that happens depends on the purpose of the target hub long.

    To the cog, it is always the same. Get data from a source hub long, and put it into a destination cog long. Both arguments are addresses.

    Say you store an address in the hub. You fetch it with rdlong, and then use it as an address for say a wrlong. There is no meaningful difference between doing that and say storing a data value in the hub. you still fetch it with rdlong, and you still use it in say an add operation.

    Up to you.

    In pasm, you determine what is an address or value. In SPIN, you need to ask for addresses at times because SPIN knows them, but you or your program might not.
  • edited 2015-03-29 14:15
    jbw2 wrote: »
    I am trying to learn assembly language programming. I do understand the basics of Spin and C and the parallax hardware. I have gone thru the “assembly_09” tutorial and have started the “machinelanguage.pdf” tutorial. I am not able to understand the programming example 2 on pg 10. it is my understanding that the instruction:
    patternaddr := @aCounter places the address of “acounter” into “patternaddr”, so then why is the, value of, rather than the, address of, “acounter” placed into “outa” by the instruction: RDLONG OUTA, patternAddr?

    patternaddr := @aCounter places the address of aCounter into the variable patternaddr.

    RDLONG OUTA, patternAddr reads the value at patternAddr and copies it to OUTA.

    Sandy
Sign In or Register to comment.