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

Spin Semantics

g3cwig3cwi Posts: 262
edited 2012-02-25 13:57 in Propeller 1
The Spin language provides several ways of doing some things:

A := A + 1
A += 1
A ++

To my tiny mind, the first is the most readable. Is there any runtime penalty for writing the more intuitive form here or elsewhere?

Cheers

Richard

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-02-25 00:41
    First there is space (top expression uses most memory). Then speed (top expression is slowest). That said small size doesn't always equal higher speed.

    Check out this thread as well: [post=1063920]Spin speed up[/post].
  • g3cwig3cwi Posts: 262
    edited 2012-02-25 01:15
    Interesting. Is Spin compiled or interpreted?
  • kuronekokuroneko Posts: 3,623
    edited 2012-02-25 01:30
    Compiled to byte code which in turn is interpreted by the ROM based SPIN interpreter.
  • Heater.Heater. Posts: 21,230
    edited 2012-02-25 01:36
    Spin is compiled into byte codes which are then run by the byte code interpretter built into the Prop. Works rather like the old Pascal p-code system or Java.
    It awful slow 50 to 100 times slower than executing native PASM instructions. But has the benifit of making smaller code which is important on the memory constrained Prop with its 32 bit instructions. Also gets around the Problem that the Prop can only execute native code from within its COGs which are only holding 496 instructions max.
  • JonnyMacJonnyMac Posts: 9,197
    edited 2012-02-25 09:19
    Is there any runtime penalty for writing the more intuitive form here or elsewhere?

    It turns out, yes. The examples you cite consume 656, 576, and 336 cycles, respectively. One of the [many] neat things about the Propeller is that it can time itself using the CNT register. See the attached program.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-02-25 11:48
    This makes me wonder if there could be such a thing as an optimizing Spin compiler; What would it take to make a Spin frontend for LLVM, and add a spin bytecode backend? Could have some interesting results...
  • turbosupraturbosupra Posts: 1,088
    edited 2012-02-25 13:57
    Very nice!
    JonnyMac wrote: »
    It turns out, yes. The examples you cite consume 656, 576, and 336 cycles, respectively. One of the [many] neat things about the Propeller is that it can time itself using the CNT register. See the attached program.
Sign In or Register to comment.