Shop OBEX P1 Docs P2 Docs Learn Events
Octothorpe, in the Propeller assembly language — Parallax Forums

Octothorpe, in the Propeller assembly language

Carl HayesCarl Hayes Posts: 841
edited 2008-12-13 05:08 in Propeller 1
I've just received my first-ever Propeller stuff, and I'm reading the manual through.· I've written assembler on many machines in many decades, and I'm most interested in assembler 'cuz it's easy.· I started writing assembler on the IBM 709 (a vacuum-tube mainframe) in the early 1960s, and made a couple different careers as (among other things) an assembler programmer on everything from mainframes through minis to PCs.· PC assembler, incidentally, was the one I found most truly bizarre.

I observe that (in the Propeller manual) many instructions specify a syntax that includes an octothorpe [noparse][[/noparse]sometimes clumsily called a pound sign, or number sign].· For example, from page 416:

WRWORD Value, <#> Address

I know that showing the octothorpe inside the angle brackets means it's optional.

I haven't been able to find, either in the manual or in the supplement, any explanation of what the octothorpe does to the meaning, or effect, of the instruction.· I know it's got to be·in the book somewhere, but it conceals itself very skilfully.

What's it mean?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2008-12-13 04:06
    This is an immediate, (or direct) mode instruction.

    It works like this:

    mov destination, 5

    In this form, the contents of the cog_long at address 5 are moved to the cog_long indicated by the value of the label destination.

    mov destination, #5

    With immediate mode addressing, the value 5, is directly moved to the cog_long indicated by the value of the label destination.

    The S field is the only one that can have this method of addressing. It's 9 bits, just enough to either specify a source cog_long as an operand, or a value that's 9 bits in size, which ever makes the most sense for the programmer.

    In either case, the value 5 does exist in the instruction bits. The difference is whether or not it's an address or a value to be used directly, thus the "direct addressing" terminology associated with the octothorpe character. (My browser spell check does not grok this!)

    ---and I had no idea that was called the octothorpe!! Heck, most everybody I know says, "pound sign"! LOL!!! I can't wait to try that one out on somebody. It's better than tilde. "~"

    This addressing is worth some consideration when coding the jmp instruction. With the immediate form, you are using a value to indicate a jump to a specific cog_long, for continued program execution. With the non-immediate form, you are using a value to indicate which of the cog_longs contain the value that will be the target address! (indirect addressing) In most instances, you would code the # form of the instruction, unless specifically coding a jump pointer.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net

    Post Edited (potatohead) : 12/13/2008 4:44:03 AM GMT
  • potatoheadpotatohead Posts: 10,261
    edited 2008-12-13 04:11
    In the case of WRWORD specifically, the immediate form means direct addressing of the first 9 bit addressable hub memory. The target address for the word to be written to the hub resides as a 9 bit value in the instruction. (# = direct addressing)

    In the non-immediate mode, that same 9 bit value then indicates which cog_long contains the HUB memory address the word will be written to. (indirect addressing again, similar to jmp)

    WRWORD value, #5

    In this direct form, the address of the HUB memory to be written to is the value 5, used directly from the instruction itself. Value contains the address of the cog_long that contains the value to be transferred to the HUB. (direct)

    WRWORD value, 5

    Here, the only difference is the value 5 is the address of a cog_long that contains a value that is the HUB memory address to be written to. (indirect)

    Hope that helps!

    Have a great time on your Prop. It's as addictive as radio is!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net

    Post Edited (potatohead) : 12/13/2008 4:29:38 AM GMT
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-12-13 04:18
    Then indirect addressing is the norm, and literals, or I should say immediate values,·have to be indicated?· Also I'm unsure I understand your expression cog-word, but perhaps it means that the the location containing the [noparse][[/noparse]indirect] address is in the cog memory as opposed to main memory?

    So that, for example, #11 means the literal value 1011 binary, and 11 means the contents of the 11th byte in cog memory?

    Isn't octothorpe a wonderful word?· It is the only name for # that is unambiguous -- all the other names are used sometimes for other symbols.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
  • potatoheadpotatohead Posts: 10,261
    edited 2008-12-13 04:25
    Absolutely it is! Love it, and thanks for using it! (I'm a sucker for that kind of playful distraction.)

    You are correct. Indirect addressing is the norm. For my own personal sanity, I characterize the Propeller as a memory to memory design. There is no need to load, compute, store with an accumulator, like on many other CPUs. Because of that, indirect addressing sees far more frequent use than it would otherwise, thus the instruction layout. Makes sense to me!

    cog_word is just one of the addressable COG memory locations. Sometimes, these are confusing as they being data or program is really up to the programmer! I really meant to type cog_long, but I saw your post before editing mine fully, so I'll cop to it. Sorry!

    I'm gonna make those edits now for others to not be so confused.

    Edit: There! All done! I make that mistake from time to time, and I have no idea why...

    Another Edit: To clarify COG addressing is on a long basis only. They are just numbered from 0 to 511. The HUB is addressable on a byte, word or long basis. COGs operate only on their COG memory, often called registers when being used for data purposes, and addresses when being used as executables. (up to you about this) FYI, once a COG is started up, it's memory is copied from the HUB, at the address you specify in the COGNEW, and is not then associated to the HUB in any way. You then can overwrite the HUB memory, leaving the COG to do it's thing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net

    Post Edited (potatohead) : 12/13/2008 4:48:24 AM GMT
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-12-13 04:28
    Thanks much. I think your chosen moniker is nondescriptive.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
  • potatoheadpotatohead Posts: 10,261
    edited 2008-12-13 04:34
    It's actually a lark. Quite some time ago, I used that moniker on a then budding website called Slashdot. I ended up just using it in many places, as it's not often taken! Besides, exceeding low expectations is always a better scenario than having to meet overly high ones!

    PC assembler is just broken. I'm sorry you had to experience it! And I love "going for assembler because it's easier" too. Nice perspective. You are gonna have a great time on the Prop!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-12-13 05:00
    potatohead said...

    ---and I had no idea that was called the octothorpe!! Heck, most everybody I know says, "pound sign"! LOL!!! I can't wait to try that one out on somebody. It's better than tilde. "~"
    It's sometimes useful to know that although in English we generally use the Spanish word tilde·for ~, it is known in Portuguese as til.· In Portuguese its use differs from that in Spanish, of course.· In English it is quite as perfectly correct, but less common,·to call it til as to call it tilde.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
  • potatoheadpotatohead Posts: 10,261
    edited 2008-12-13 05:08
    [noparse];)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
Sign In or Register to comment.