Shop OBEX P1 Docs P2 Docs Learn Events
Spin math — Parallax Forums

Spin math

codekingcodeking Posts: 39
edited 2007-01-08 00:23 in Propeller 1
2^8

How would I do that in spin?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-07 17:27
    1 << 8
  • Luis DigitalLuis Digital Posts: 371
    edited 2007-01-07 20:00
    Mike Green said...
    1 << 8

    Good trick that functions if the base is 2. smile.gif
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2007-01-07 20:32
    There is also the bitwise decode operator,

    x := |< 8

    This one is often found standing solo in the context of forming 32 bit pin mask for instructions like WAITPEQ
    |< 8
    %0000000_00000000_00000001_00000000

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • codekingcodeking Posts: 39
    edited 2007-01-07 22:57
    Luis Digital said...

    Good trick that functions if the base is 2.

    Since it's a trick, if yoou do 2 ^ 0, will it give zero as an answer r the correct answer 1?
  • Luis DigitalLuis Digital Posts: 371
    edited 2007-01-07 23:58
    codeking said...
    Luis Digital said...

    Good trick that functions if the base is 2.

    Since it's a trick, if yoou do 2 ^ 0, will it give zero as an answer r the correct answer 1?

    1 << 0

    1 roll.giftongue.gif
  • Luis DigitalLuis Digital Posts: 371
    edited 2007-01-08 00:17
    A little explanation, because I see that some they are initiating in the digital world (binary).

    << (SHL in Pascal) is Bitwise Shift Left Operator.

    Why 1<< 0 is equal to 1?

    Because I do not move anything to the left.

    Wow, I have found a good tutor of assembler with drawings.
    http://chortle.ccsu.edu/AssemblyTutorial/Chapter-12/ass12_2.html

    Someone asked for one some day ago, I expect that serve of something.
  • Luis DigitalLuis Digital Posts: 371
    edited 2007-01-08 00:23
    Ok, more info also in the Propeller manual page 266.
Sign In or Register to comment.