Shop OBEX P1 Docs P2 Docs Learn Events
Does anyone have a spin absolutes document? — Parallax Forums

Does anyone have a spin absolutes document?

turbosupraturbosupra Posts: 1,088
edited 2011-10-15 19:43 in Propeller 1
I'm looking to compile a document with absolutes about spin, for example, methods only return longs.

Does anyone have a list of absolutes like that for spin?

Comments

  • RinksCustomsRinksCustoms Posts: 531
    edited 2011-10-14 17:24
    Not a list, but the specs and absolutes are all in the manual.
  • Mike GMike G Posts: 2,702
    edited 2011-10-14 17:33
    Parallax Propeller Manual?
  • bsnutbsnut Posts: 521
    edited 2011-10-14 19:24
    Your qestion, Does anyone have a spin absolutes document? I think the info you are looking for would be in the Parallax Propeller Manual.
  • turbosupraturbosupra Posts: 1,088
    edited 2011-10-14 21:33
    I've read the manual, does it say in the manual that methods always return longs? I do not remember reading that and was hoping to compile a cliff notes version of the absolutes.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-14 21:44
    I suppose you could say the return type is defined by default. IOW, there simply isn't a mechanism in the language to return anything but a long.

    -Phil
  • AribaAriba Posts: 2,690
    edited 2011-10-14 22:19
    turbosupra wrote: »
    I've read the manual, does it say in the manual that methods always return longs? ...
    Depends on what you mean with longs. A methode returns a 32bit value, because the Propeller is a 32bit processor. This value is typeless, so how this 32 bits are interpreted depends on the function of the methode and the destinaton variable. This can be a byte, a word, a long, a pointer to a string, a float value or something else.
    I.E: mybyte := serial.rx
    returns the serially received byte. The byte is passed in the the lower 8 bits of a 32bit return value, but only this 8 lower bits gets written to the mybyte variable, so it does not really matter that there is a 32bit value in between.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-14 22:43
    Ariba stated it well. In addition, all expressions and operations are computed with signed 32-bit math. A method call is just a special instance of an expression element. It's only when the result of an expression gets assigned to a shorter variable that a conversion is made to a different type. And that's done by chopping off the top 16 bits (for words) or 24 bits (for bytes).

    -Phil
  • turbosupraturbosupra Posts: 1,088
    edited 2011-10-15 19:29
    Thanks everyone, that was a good explanation and makes sense now that it has been phrased that way.

    Are there other things similar to that, that would be helpful in committing to memory?
  • potatoheadpotatohead Posts: 10,261
    edited 2011-10-15 19:43
    True = -1

    (it appears that message was too short)
Sign In or Register to comment.