Shop OBEX P1 Docs P2 Docs Learn Events
Driving me crazy: wrlong, wrbyte — Parallax Forums

Driving me crazy: wrlong, wrbyte

Christof Eb.Christof Eb. Posts: 1,109
edited 2007-03-17 19:54 in Propeller 1
Hello, please rescue me!

I do not understand this:

..
wrlong bp,bp ' is working
wrbyte bp,bp ' is not working
...

If I omit the wrlong, the wrbyte works.
Is there a restriction using wrX ? Does the IDE something (optimizing?) with the code??

Christof

Comments

  • Jasper_MJasper_M Posts: 222
    edited 2007-03-17 17:22
    Umm, the compiler/assembler does no optimizing.

    The second wrbyte in that code writes the same thing in the same address, so it does not modify anything. Remember that propeller is little endian, ie. $22 looks in memory as a long like 22 00 00 00. So you're overwriting the LEAST significant byte with the wrbyte (At least assuming that the address is divisible by 4).

    Post Edited (Jasper_M) : 3/17/2007 5:27:09 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-17 17:37
    Christof,
    I don't know what you're trying to do with this code sequence. It doesn't make sense.
    Mike
  • Christof Eb.Christof Eb. Posts: 1,109
    edited 2007-03-17 17:49
    Thank you,

    that was not the problem. I was already crazy posting this.

    The real problem was, that I used
    Dat
    P long '/* Primary Register */
    S long '/* Second Register */
    ...
    instead of
    Dat
    P long 1 '/* Primary Register */
    S long 1 '/* Second Register */
    ..

    the assembler did not use different locations. You seem to have to use init values.

    This lead the code to write somewhere into memory....
    Thank you Jasper, I realized, that I had to have a different problem...
    Christof
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-17 17:51
    Yes, because LONG/WORD/BYTE allow multiple locations to be specified, they use the number of expressions given to control the number of storage locations. Not giving any results in nothing being allocated.
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-17 17:55
    No problem : P ...

    I was just looking at your code and looking at those empty "long"s and thinking "oh, you can do that..."... And good luck with retargeting the small C!
  • Jeff MartinJeff Martin Posts: 751
    edited 2007-03-17 19:54
    Christof,

    You're right about the "longs" without data... they end up not emitting any data (by design)... but simply specifying a data value may not be the best solution either (it's okay, but may be wasteful, is all).

    Another way is to do:

    P  res  1
    S  res  1
    

    The "1" means "1 long of space".· The difference is that the res (reserve) directive increments the cog address of the next item, but doesn't emit any data (whereas P long <nothing> also doesn't emit data, but doesn't increment the assembler's cog address either).

    A note of caution about res... since it doesn't emit data, make sure you have all your res's as the LAST code in your assembly... or you'll end up with P and S pointing to a location used by a "long" definition, or an instruction, that you specified after it.

    SUMMARY:

    · defining longs, with data, increases the size of your object

    · defining res's does not increase the size of your object, but still gives you a symbolic register to work with once the code is loaded into the cog.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Jeff Martin

    · Sr. Software Engineer
    · Parallax, Inc.
Sign In or Register to comment.