Shop OBEX P1 Docs P2 Docs Learn Events
Here? ($ operator) — Parallax Forums

Here? ($ operator)

CardboardGuruCardboardGuru Posts: 443
edited 2007-10-29 23:36 in Propeller 1
I've just updated to prop-tool 1.05.8 and I noticed in the release notes for 1.05.6

"Updated compiler to support $ as a "here" operator"

I'd be interested to know what that means, and how is it used?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
Prop Room Robotics - my web store for Roomba spare parts in the UK

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-10-28 13:24
    JMP #$
    


    MOVS  $+2,  computedAddress
    NOP
    MOV  x, 0-0
    


    StartOfBlock  LONG $+1
    



    If you should ask me in private, this is a questionable gift....
  • hippyhippy Posts: 1,981
    edited 2007-10-28 13:43
    deSilva said...
    If you should ask me in private, this is a questionable gift....

    Go on; tell us all, in public smile.gif

    I'm interested in hearing your views and I'm sure others are. I see it as a useful addition but you have a lot more Propeller Assembler experience than I have.

    I'll admit it can be prone to error when code is added or removed between its use and intended destination and reaching over macro commands can cause problems but that's no different to its use in any other Assembler, and, finally, people are not forced to use it.
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-28 14:07
    Oh, dear...
    (a) I think it is not strictly needed... Something like
    X++
    in C... I should expect any decent compiler to generate efficient code out of
    X += 1

    $ - indeed present in any (macro!) assembler has it's main duty inside macros, as it would need tricky modifications otherwise when expanding macros...
    Another useful application in other machines is aligning code or data
    ORG  (($+15)/16)*16
    



    Used with discretion there is no more danger in it than in the next best JMP-instruction.
    However, now - having this NEW feature - people will start looking through their code where this can be applied for better or for worse; imagine: tight loop could be re-written DJNZ X, #$-1 - Yes, I know you all: DeSilva.. and the rest...
  • potatoheadpotatohead Posts: 10,260
    edited 2007-10-28 17:17
    I like it's use for the self-modify code loops! One does not need to manage a label now, and instructions are just nice easy integer addresses, making the target easy to spot. Cake, if you ask me. For longer distance targets, say more than 10 instructions, I'll still use the label as counting can then be an annoyance.

    I'm highly likely to pick that up and go with it. Other uses will really depend on how it adds clarity, of if it makes something more possible, sans a kludge.

    Sorry to go somewhat OT, but it's kind of relevant. What's the easiest way to make damn sure an instruction exists at a specific COG address? eg: $ = $100

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-10-28 17:34
    I think as a means (per deSilva's example) to align blocks of memory it would be useful. For all the other examples in this thread, I think it hurts readability, and does not result in more efficient code. So at least I don't see myself going back into old code and adding it.

    Is this a new features they snuck into Propeller Tool? What, if any, are the other new features? I haven't had a chance to install the new one yet. Does it replace the old one automatically?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-28 17:35
    potatohead,
    I don't think that "$" is implemented as a variable. It's a predefined label whose value happens to change from place to place, so "$ = $100" would not be allowed. You'd use "ORG $100" for that purpose. "$" is useful in macro definitions as others have noted (which we don't have) and it's useful in creating tables with relative addresses. As noted, it's useful in 2-3 instruction loops. It's a dangerous construct in most other contexts. The fact that something useful can be abused is not a reason by itself to prohibit its introduction. There are certainly contexts where "$" can be clearly and cleanly used to implement something where the other alternative (local labels) is awkward and potentially confusing and error prone.
  • CJCJ Posts: 470
    edited 2007-10-28 17:38
    perhaps a padding array using the taget fill-to address minus $here

    pad: long 0[noparse][[/noparse]$100 - $]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Parallax Forums - If you're ready to learn, we're ready to help.

    Post Edited (CJ) : 10/28/2007 5:46:10 PM GMT
  • potatoheadpotatohead Posts: 10,260
    edited 2007-10-28 17:46
    I figured it was not a variable. That was just wistful shorthand.

    I'm somewhat outta the loop on org. I thought there were problems with it's direct use, as in ORG $100. Can't seem to find the thread. Was a while back though.

    If ORG = address is ok, that totally answers the question. I might have just been limited from bad, or old info!

    Ken, the Parallax practice, seen so far, is to just install the newer version alongside the older one. That way you can move projects over, see what, if anything, has to be changed, than carry on with the newer tool as it makes sense.

    When you run any given version, it looks to see if it is associated with the relevant files, asks if you want to deal with that, then goes and does it's thing. All in all, pretty painless.

    I'm not gonna go edit any older code either. Will probably just use it, where it makes sense, in newer code. After thinking about it, I'll probably limit using it in the self-modify way, only for very small and tight situations.

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

    Post Edited (potatohead) : 10/28/2007 5:53:30 PM GMT
  • hippyhippy Posts: 1,981
    edited 2007-10-28 18:05
    I've never thought something not being strictly needed a good reason not to have it. It's up to the coder ( and coding standards they work to ) to decide if they want to use x++, X+=1, X:=X+1, or even inc(@x). Ideally the first three should compile to the most optimal code regardless of which is used.

    Using $+n is potentially dangerous, but that comes with the territory ( is there anything to stop people using label+n ? I'm in the wrong OS so cannot check ). Misuse is usually in writing code where it's not clear where $+n area boundaries are leading to accidental editing.

    One argument against code using $+n is that it will not work for those who have not upgraded to a compiler version which supports it. Generally not a problem but there are people around the world who do have problems downloading 10MB files.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-10-28 18:15
    The problem with something like ORG $100 is that the code following it is assembled as if it began at that address. But that doesn't mean that the code will be physcially located there. When the cog starts up, 512 longs are loaded in sequence from hub RAM, irrespective of any directives that might suggest otherwise.

    That doesn't mean that ORG is useless, though. For example, you might want to designate an area of cog RAM that's shared by multiple snippets of code (i.e. overlays). In such a case, each snippet would begin with an ORG bearing the cog address of the overlay area.

    -Phil
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-28 18:42
    CJ said...
    perhaps a padding array using the taget fill-to address minus $here
    pad: long 0[noparse][[/noparse]$100 - $]
    Good point: this is something I used some times to work around a missing ORG $100
    pad: long 0[noparse][[/noparse]$100-pad]
    


    had always been possible; there is not much improvement in
    long 0[noparse][[/noparse]$100-$]
    
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-10-28 23:04
    potatohead said...
    Sorry to go somewhat OT, but it's kind of relevant. What's the easiest way to make damn sure an instruction exists at a specific COG address? eg: $ = $100

    a text macro for 495 nop's
  • potatoheadpotatohead Posts: 10,260
    edited 2007-10-29 06:32
    That's pretty funny.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-10-29 22:55
    Another question about the new Prop Tool. When I installed the previous version, I was able to install everything except the USB driver , which I had to have one of our sysadmins do (permissions). If I install the new one, I assume I can do it without having to install USB drivers again and therefore install without bothering our IT services dept.(?)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-29 23:11
    They do have a bad image, those IT guys, haven't they smile.gif

    To your question: I think it will not enforce the installation of a driver when there is already one present.
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-10-29 23:36
    deSilva: I guess I'll know for sure when I go to do the upgrade. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
Sign In or Register to comment.