Shop OBEX P1 Docs P2 Docs Learn Events
BS2 remote code compiling (external memory) — Parallax Forums

BS2 remote code compiling (external memory)

ToneTone Posts: 3
edited 2006-03-06 20:15 in BASIC Stamp
Would it be possible to make a program stored in the BS2 eeprom compile "code lines" stored in a remote memory (ex: sdcard through uMMC device) ?
·
Thanks for any help on that matter,
·
·
·
Antoine Levesque


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1000010 1010011 110010BS2

1010010 1001111 1000011 1001011 1010011· 100001ROCKS !
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-03-06 03:52
    No. The BS2 is not capable of compiling its own interpretive code. You need a Windows, Linux, or Macintosh computer to do so. That said, you could create your own simple interpreter that runs in the BS2 and executes information stored as data in the BS2 memory, in some kind of external memory device (like a serial EEPROM or uMMC). This would be slow, but maybe fast enough for your needs.

    Mike Green
  • ToneTone Posts: 3
    edited 2006-03-06 16:29
    //·you could create your own simple interpreter that runs in the BS2 and executes information stored as data
    //·in the BS2 memory, in some kind of external memory device (like a serial EEPROM or uMMC). This would be
    //·slow, but maybe fast enough for your needs.


    As for speed needs, i'm patient and it's not a real issue. So to rephrase the question, let's say i wrote code like this one (it's not actual code, just an algorithm)

    for dataADR =·1024 to·2047····················· 'external memory adresses
    ·· read storedDATA, inVariable·················· 'read the external memory, dump in variable
    ·· execute inVariable······························· 'execute code·from variable ???
    next

    'data stored exemple
    '

    DATA···· ( codeStr_01,·· codeStr_02,·· codeStr_03 )


    and codeStr_01 could resemble something like a for next or a do loop statement.



    Thanks again for any input on this!



    Antoine Levesque

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1000010 1010011 110010BS2

    1010010 1001111 1000011 1001011 1010011· 100001ROCKS !
    ·
  • DiablodeMorteDiablodeMorte Posts: 238
    edited 2006-03-06 19:05
    Um.. What you want could be a slight bit difficult. I'm sure it can be DONE but the time taken would not be fun. I havn't played with string recognition in but lets say..

    DATA ("FOR", "<", 30)
    DATA ("Other instrucitons")
    DATA ("NEXT")
    You could do a MASSIVE branch statment like:
    (not real code)
    If(No idea on addressing data so here's a sudo way)
    if data.1 = "for" goto for_loop

    for_loop:
    if data.2 = "<"
    for i < data.3
    (handel the middle data)
    if data.x = "Next"
    Next

    Yea.. it could be done
  • Mike GreenMike Green Posts: 23,101
    edited 2006-03-06 20:15
    I really don't recommend trying to make a general purpose program interpreter using Stamp Basic. Look at Forth or Jovial for examples. Decide on the absolute minimal functionality. Pick a simple microprocessor for an example like the SX series and even trim that down. Maybe you could use single character operators and digits for constants. A stack machine would be even simpler in some ways and could eliminate the need for addresses. A digit or series of digits would imply a push with a comma as a simple delimiter so: "1,2+" would push a one and a two and add them to get three. If you had 5 variables, you could use letters for them and their use by themselves would imply a load. A "." could mean to pop the top of the stack into the following variable so "A,1+.A" means "push A, push 1, add, pop into A". For bits, you could allow a digit after a letter like "A2" for bit 2 of A. For decision making, you could use "=" for test equal, "<" for test less, ">" for test greater with paired brackets providing the markers like "{} [noparse]/noparse ()" and ";" signifying an else. So, "IF A < 1 THEN xx ELSE yy" would be written as: "[noparse][[/noparse]A,1<xx;yy]". You could pick some other single character like "^" as a "repeat to the previous innermost bracket" to get loops. Anyway, there are lots of choices, but the basic idea is to simplify the operations and the syntax as much as possible. Look at introductory computer science books for examples of simple interpreters.

    Mike Green
Sign In or Register to comment.