Shop OBEX P1 Docs P2 Docs Learn Events
Two SX questions. E2Flash and DS — Parallax Forums

Two SX questions. E2Flash and DS

PLJackPLJack Posts: 398
edited 2005-06-03 23:05 in General Discussion
I've read all three manuals, Honest. [noparse]:)[/noparse]
But I can not nail down these two questions.

1)
2k of E2Flash.
Since it has a Read/Write of 10,000 I assume this is regular flash ram.
In other words I can save data to this area and it will be retained during
power off. And can be accessed again when the SX is powered up.
Is this true?
If so could you please provide a short ASM snippet on how to write and read from this ram.

2)
DS and arrays.
To allocate a Byte for a var I can do:
AVar DS 1

Now, this will also compile:

AVar DS 8

I assume I just allocated 8 bytes of ram there.
What I need is a bank of bytes that I can access via an index.
Like so:

mov Avar(Idx), AValue

Now I know this syntax is wrong, but that is the jest of what I am trying to do.
Again, a small ASM snippet would be greatly appreciated.

thanks.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jack

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-06-02 18:58
    There is 2K of program memory in the SX28, this space can be used to store data known at the time you program the SX, this area cannot be written to while the SX is running, but it can be read from. I have some code that given a 12 bit address will fetch the 12 bits of data at that location, if you only need 8 bits of data you can place "retw Constant" in your code, call that address and the constant will be placed into W.

    Indexing in the SX is accomplished using the FSR and IND registers (FSR points to the memory location, IND used in an instruction tells the SX to use the address in FSR). I have code for stack operations that treats all the banks as one large bank using the indirection method. I can post it when I return home this evening.
  • PLJackPLJack Posts: 398
    edited 2005-06-02 19:08
    Paul Baker said...
    There is 2K of program memory in the SX28, this space can be used to store data known at the time you program the SX, this area cannot be written to while the SX is running, but it can be read from.
    Ahh, not what I thought it was then.
    Thanks for the info.


    Paul Baker said...

    Indexing in the SX is accomplished using the FSR and IND registers (FSR points to the memory location, IND used in an instruction tells the SX to use the address in FSR). I have code for stack operations that treats all the banks as one large bank using the indirection method. I can post it when I return home this evening.
    I would like to see that.

    thanks again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jack
  • BeanBean Posts: 8,129
    edited 2005-06-02 22:37
    Jack,
    You can write some simple SX/B code and see how it handles data and arrays.
    For data see the "DATA" and "READ" commands, for arrays just delare "MyArray VAR BYTE(8)"
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012


    Product web site: www.sxvm.com

    "It's not getting what you want, it's wanting what you've got."
    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-06-03 04:31
    Ok, here's the stack code I promised.
  • PLJackPLJack Posts: 398
    edited 2005-06-03 07:08
    Thank you very much!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jack
  • James NewtonJames Newton Posts: 329
    edited 2005-06-03 23:05
    I've taken the liberty of adding Paul's code to the others at:
    http://www.sxlist.com/lib/mem/sstack_sx.htm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    James Newton, Host of SXList.com
    james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
    SX FAQ / Code / Tutorials / Documentation:
    http://www.sxlist.com Pick faster!



Sign In or Register to comment.