Shop OBEX P1 Docs P2 Docs Learn Events
Array Example Please — Parallax Forums

Array Example Please

Brian CarpenterBrian Carpenter Posts: 728
edited 2006-10-23 15:19 in General Discussion
Does anyone have an example of writing to an array in SX/B

I have an array called KeyVal··· VAR···· BYTE (16)

Now how do i write and read to it?

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


It's Only A Stupid Question If You Have Not Googled It First!!

Comments

  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2006-10-22 11:32
    Altitudeap,

    Jon Williams wrote this sometime back to show me how to have arrays larger than 16 bytes (in this case 64 bytes) in SX/B. Maybe this will help although I never exactly understood it.
  • metron9metron9 Posts: 1,100
    edited 2006-10-22 22:10
    I was going to try and help you out so I did some poking around with the SX28 chip. File attached.


    If any of the statements are incorrect below please correct me, it is what I understand it now and may not be correct.

    The SXB Basic compiler uses memory variables $00 thru $0C for its own internal use.

    When you define your firat variable it uses the next available memory locations, $0D $0E, $0F ... up to $1F

    When you use the BANK command to switch between the 8 banks of memory you can use only memory locations $10 thru $1F in each of the banks bank1 thru Bank7

    So those 3 bytes $0D, $0E, $0F in bank 0 throw you off when bank switching. The file attached I define v1, v2, and v3 as the first 3 byte variable names and then x1 .. x16 as 16 more variables.

    Then I can switch banks from 0 to 7 to get 64 bytes of variable space.

    One problem though, The compiler on pass 2 seems to have a problem aND GIVES A WARNING, the code runs in the debugger though so perhaps someone can tell us why it is giving a warning. Funny thing the x1=255 thru x4=255 code gives the warnings about current bank, if i comment out x1 thru x4 then it gives warnings on the next 4 code lines x5=255 thru x8=255 maby someone knows why.


    So warnings aside you could set up banks of 8 LED variables, use groups of 2 for your number of key hits to compare too and the other one for number of key hits current. Then switch banks and compare the next set of 8.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • BeanBean Posts: 8,129
    edited 2006-10-23 15:19
    That assembler warning is correct. The assembler has no way of knowing what you are doing.
    Just ignore the warning.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
Sign In or Register to comment.