Shop OBEX P1 Docs P2 Docs Learn Events
CASE Statement Limit — Parallax Forums

CASE Statement Limit

GoogGoog Posts: 65
edited 2006-06-16 21:19 in Propeller 1
I'm writing a pretty complicated SPIN program which requires WAAAY more than 64 Cases for a Case statement, but the compiler doesn't want to do more than that.· Any suggestions? Will If...ElseIf... work or is there a limit for that, too?

Thanks,
Goog

Comments

  • cgraceycgracey Posts: 14,133
    edited 2006-06-14 05:23
    You can nest CASE statements. This should make things execute faster, too, since groups of cases can be evaluated at the top level and then inner levels can separate the finer cases.

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


    Chip Gracey
    Parallax, Inc.
  • GoogGoog Posts: 65
    edited 2006-06-14 05:32
    Oooh - good suggestion, although I'm not sure I can do that in my application, based on the possible values.· But I just tried two CASE statements in a row.· Obviously the comparison won't evaluate to any of the first 64, so it will just flow right to the second CASE statement, which will pick it up.· That seems to work.· Thanks for the reply, Chip - you are working way too late! [noparse]:)[/noparse]

    Goog
  • cgraceycgracey Posts: 14,133
    edited 2006-06-14 05:42
    Remember also that you can specify ranges, not just values in a case statement:

    CASE x

    · 0..99: dothis

    · 100..199: dothisinstead

    I love playing with the Propeller, too. I'm having so much fun writing objects for it, that it's hard to work on the next-generation chip.


    Goog said...

    Oooh - good suggestion, although I'm not sure I can do that in my application, based on the possible values.· But I just tried two CASE statements in a row.· Obviously the comparison won't evaluate to any of the first 64, so it will just flow right to the second CASE statement, which will pick it up.· That seems to work.· Thanks for the reply, Chip - you are working way too late! [noparse]:)[/noparse]

    Goog

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


    Chip Gracey
    Parallax, Inc.
  • IbsenIbsen Posts: 68
    edited 2006-06-14 14:43
    So how about a hint ???

    What is the next generation chip going to be ???·· roll.gif

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


    *.*

    Ibsen

    " It's nice to be important, but
    ·· more important to be nice... "
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-06-14 14:49
    If you sift through the forum you'll find alot of details about the next chip.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.
  • cgraceycgracey Posts: 14,133
    edited 2006-06-14 17:15
    I don't want to over-commit, but it's going to be a lot faster and have more RAM.
    Ibsen said...



    So how about a hint ???

    What is the next generation chip going to be ???·· roll.gif

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


    Chip Gracey
    Parallax, Inc.
  • GoogGoog Posts: 65
    edited 2006-06-14 17:45
    <drool> I'd like to be at the top of the backorder list, please [noparse];)[/noparse] Is there a timeline? I already found I need more RAM for my C64 emulator! I was thinking attaching an EEPROM, but maybe I'll hold out for the new prop!

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

    Doing my part to keep the Commodore 64 alive!

    http://www.commodorestuff.com
    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-06-16 15:52
    Don't hold your breath, otherwise they'll be a bunch of passed out Propheads. It will be quite some time before the new version will availible for purchase.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.
  • Cliff L. BiffleCliff L. Biffle Posts: 206
    edited 2006-06-16 15:57
    Goog--

    Are you, by any chance, writing an interpreter?
  • GoogGoog Posts: 65
    edited 2006-06-16 16:27
    What exactly do you mean by 'Interpreter'? I am not writing anything that compiles·a language into a stream of byte code, which is then interpreted, if that's what you mean... if you're referring to my C64 emulator, you can see that in the "Commodore 64 Emulator" thread... it is going to be a fully emulated (software code that acts like the chips in the C64) Commodore 64 - all done in SPIN (or maybe some Assembly, if it turns out to be too slow, but I'm betting it will work well).

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

    Doing my part to keep the Commodore 64 alive!

    http://www.commodorestuff.com
    ·
  • Cliff L. BiffleCliff L. Biffle Posts: 206
    edited 2006-06-16 21:19
    Yes, that's what I meant -- you're writing code to interpret the C64's machine instructions. (Bytecodes do not an interpreter make.)

    A switched interpreter may not work as well as you want it to. SPIN gets about 20KIPS@80MHz; figuring 100:1 interpretation penalty for a switched interpreter (particularly considering the RAM access speed), I don't think you're going to keep up with a C64.

    You might look into Forth-style threaded interpreters. Googling that phrase will yield results. If SPIN allows indirect function calls (calls through function pointers), you could implement it entirely in SPIN...though I think you'll be happer in assembly in this case, performance-wise. smile.gif

    Neat project; I look forward to seeing what you do.
Sign In or Register to comment.