Shop OBEX P1 Docs P2 Docs Learn Events
SX/B 2.0 - what is going to be new? — Parallax Forums

SX/B 2.0 - what is going to be new?

Timothy D. SwieterTimothy D. Swieter Posts: 1,613
edited 2007-06-30 01:58 in General Discussion
I have heard murmurs of SX/B 2.0 being released this fall, I am about to be a user, so I was curious if there is any information on what features, commands, language elements, etc are being added to the new version.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter
tdswieter.com
One little spark is all it takes for an idea to explode

Comments

  • BeanBean Posts: 8,129
    edited 2007-06-29 14:14
    The biggest enhancement is local variables. These are variables that exist only inside the subroutine (or function) that declares them. The local variables can only be array elements, but almost all commands now can use an array element where a byte variable is used (one exception is array indexing, an array index cannot be another array element).

    Also a form of task scheduling will be built in. Where you can declare tasks (subroutines) to be performed at certain time intervals.

    GETBIT & PUTBIT allows you to set or retreive the status of a single bit where the bit position CAN be a variable.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2007-06-29 22:30
    Great, thanks Bean!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter
    tdswieter.com
    One little spark is all it takes for an idea to explode
  • sstickelersstickeler Posts: 8
    edited 2007-06-29 22:45
    Will these local variables be like static 'c' variables ( i.e. they are really global but can only be accessed inside the function ) or will there be some sort of stack support?

    Thanks,
    Scott
  • BeanBean Posts: 8,129
    edited 2007-06-29 23:46
    Scott,
    They are created on a stack. The "stack" is an array hence the reason only array elements can be local variables.
    Different subroutines can use the same variable name and can use the same name as a global variable (rendering the global inaccessable in the subroutine).

    The SX28 family is limited to a 16 byte stack, the SX48 is only limited by total array space.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-06-30 00:49
    Can I define a local word without hassle? Many of my subroutines and functions use words.
  • sstickelersstickeler Posts: 8
    edited 2007-06-30 00:49
    Thanks Bean.

    That will be a nice improvement. It will certainly make memory management much easier. When is the new version slated for release?

    -Scott
  • BeanBean Posts: 8,129
    edited 2007-06-30 01:08
    Jon,
    No you cannot define word variables. Only arrays.
    The way around this is to define some global WORD variables, then save their value at the beginning of the subroutine and restore the value at the end of the subroutine.
    You need to do the same thing to get a "normal" byte variable to use as an array index.


    tempW VAR WORD ' Global variable

    SUB MySub
    · saveTempW VAR BYTE (2)

    · 'Save value of tempW
    · saveTempW(0) = tempW_LSB
    · saveTempW(1) = tempW_MSB

    · FOR tempW = 0 TO 1000
    · NEXT

    · ' Restore value of tempW
    · tempW_LSB = saveTempW(0)
    · tempW_MSB =saveTempW(1)
    · ENDSUB

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-06-30 01:35
    I don't get it.... why bother with local variables if they have to defined as an array, anyway? I can create an array now and more easily keep track of things. Am I missing something?
  • BeanBean Posts: 8,129
    edited 2007-06-30 01:53
    Jon,
    It prevents subroutines from trying to use the same global variable.
    From having to declare uumpteen temp global variables.
    It makes subroutine more modular. They can stand alone without depending on certain variable names to be declared.
    Subroutines can use the same variable names without any problem. If sub1 has a local var named "temp" and it calls sub2 that has a local var named "temp" it will still work just fine.
    It saves RAM because all the variables for all the subroutines are not declared at the same time. In essence they are created "on-the-fly" at runtime.

    If SX/B had not been geared towards learning assembly, I would made ALL variable work like array elements (through FSR). Then every variable type would work the same way. But the code would be alot larger and not nearly as easy to understand.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-06-30 01:58
    Since SX/B defines SUBs and FUNCs with SUB and FUNC, can't that be handled internally? And allow for Words?
Sign In or Register to comment.