Shop OBEX P1 Docs P2 Docs Learn Events
spinix - Page 4 — Parallax Forums

spinix

124»

Comments

  • David BetzDavid Betz Posts: 14,511
    edited 2014-07-27 11:31
    Dave Hein wrote: »
    I forgot to mention that this release contains the original C source files for some of the utilities in the csrc directory. The C files are converted to Spin using cspin, and copied to the src directory. These utilities include bas, cal, diff, ed, lerner, sed, sobdump, sort, spasm, spinit, splink, tar, ted and vi.
    Your Basic interpreter is quite simple and elegant. Nice job!
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-07-27 18:40
    Thanks, it was interesting writing a Basic interpreter. I based it on Tiny Basic, but I added the dim command, and also support for using let and then. This makes it easier to port existing Basic programs. I also made most commands work in both the interpreter mode and run mode. I just need to speed it up a bit, and reduce the size of the executable so there is more program memory.
  • jazzedjazzed Posts: 11,803
    edited 2014-07-27 18:43
    Dave Hein wrote: »
    I forgot to mention that this release contains the original C source files for some of the utilities in the csrc directory. The C files are converted to Spin using cspin, and copied to the src directory. These utilities include bas, cal, diff, ed, lerner, sed, sobdump, sort, spasm, spinit, splink, tar, ted and vi.

    Thanks for the C source Dave. Looks like you're having fun there all around. Kudos for sed and diff too.
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-09-21 04:50
    Here is spinix 1.67. This version allows for stand-alone operation using a keyboard and VGA monitor. The boot program starts out in serial on pins 31 and 30 at 115200 baud as it did in previous releases. Once spinix boots up you can run the setup utility to configure it for VGA and keyboard. You then have to save the set up to EEPROM and reboot. Spinix will then come up using the keyboard and VGA display. I also added the loadkb, loadvga and loadser to load the keyboard, VGA and serial drivers manually. The script files "vga" and "serial" allow switching back and forth between VGA and serial modes. However, this only persist until the next reboot. setup must be used to make the configuration persist after reboots. Use the man command to get more information on these utilities.

    Other changes include adding a string engine to spinit, spasm and bas. The string engine improves the speed of these programs by a factor of 3.

    I also now include a compiled version of pfth that takes less memory than the uncompiled version, and takes less time to start up. The original uncompiled version was renamed to pfth.bin, and is still available in the /bin directory. The compiled version was obtained by running pfth.bin, and then executing the command "sdsave pfth".

    The /basic directory now contains trek.bas, which is the classic Star Trek game.
  • David BetzDavid Betz Posts: 14,511
    edited 2014-09-21 05:06
    Dave Hein wrote: »
    Here is spinix 1.67. This version allows for stand-alone operation using a keyboard and VGA monitor. The boot program starts out in serial on pins 31 and 30 at 115200 baud as it did in previous releases. Once spinix boots up you can run the setup utility to configure it for VGA and keyboard. You then have to save the set up to EEPROM and reboot. Spinix will then come up using the keyboard and VGA display. I also added the loadkb, loadvga and loadser to load the keyboard, VGA and serial drivers manually. The script files "vga" and "serial" allow switching back and forth between VGA and serial modes. However, this only persist until the next reboot. setup must be used to make the configuration persist after reboots. Use the man command to get more information on these utilities.

    Other changes include adding a string engine to spinit, spasm and bas. The string engine improves the speed of these programs by a factor of 3.

    I also now include a compiled version of pfth that takes less memory than the uncompiled version, and takes less time to start up. The original uncompiled version was renamed to pfth.bin, and is still available in the /bin directory. The compiled version was obtained by running pfth.bin, and then executing the command "sdsave pfth".

    The /basic directory now contains trek.bas, which is the classic Star Trek game.
    Sounds nice but what is a "string engine"?
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-09-21 05:34
    The string engine consists of basic string functions written in PASM. It's a technique that the Sphinx compiler used to get better performance. When spasm, spinit or bas start up it starts up a cog running the string engine. The string engine contains methods called SearchList, FindChar, SkipChar FindChars, SearchTable, SearchOpList and SearchListN.

    It's in the file src/streng.spin.
  • David BetzDavid Betz Posts: 14,511
    edited 2014-09-21 06:09
    Dave Hein wrote: »
    The string engine consists of basic string functions written in PASM. It's a technique that the Sphinx compiler used to get better performance. When spasm, spinit or bas start up it starts up a cog running the string engine. The string engine contains methods called SearchList, FindChar, SkipChar FindChars, SearchTable, SearchOpList and SearchListN.

    It's in the file src/streng.spin.
    Thanks for the explanation. What are the requirements for a program to run under Spinix? Can a PropGCC program compiled with CMM run? How does it take advantage of the serial and/or VGA/KB I/O?
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-09-21 08:07
    A CMM program can run as a stand-alone program, but there are issues with integrating it as a spinix app. LMM provides a way to set the stack starting point to prevent high-end memory from getting overwritten. LMM also has a hook for passing argc and argv. CMM doesn't have that.

    If you look in the cdemos directory you'll see directories for the programs dry, fibo and hello. They are LMM programs that use a spinix serial driver. The C spinix console driver is located in spinixcon.c.

    The filetest app also integrates to the spinix SD SPI driver. The file driver code is hacked up right now, and I'll clean it up eventually. I basically provide sector read and write routines instead of using PropGCC's library routines.

    Getting CMM to work with spinix is on my todo list. I think it will require modifying the startup assembly code to work like LMM.
  • David BetzDavid Betz Posts: 14,511
    edited 2014-09-21 09:00
    Dave Hein wrote: »
    A CMM program can run as a stand-alone program, but there are issues with integrating it as a spinix app. LMM provides a way to set the stack starting point to prevent high-end memory from getting overwritten. LMM also has a hook for passing argc and argv. CMM doesn't have that.

    If you look in the cdemos directory you'll see directories for the programs dry, fibo and hello. They are LMM programs that use a spinix serial driver. The C spinix console driver is located in spinixcon.c.

    The filetest app also integrates to the spinix SD SPI driver. The file driver code is hacked up right now, and I'll clean it up eventually. I basically provide sector read and write routines instead of using PropGCC's library routines.

    Getting CMM to work with spinix is on my todo list. I think it will require modifying the startup assembly code to work LMM.
    It's odd that LMM has this support and CMM doesn't. Eric usually provides consistent behavior across all memory models. I'll take a look at what would be required to support CMM. I'm interested in the possiblity of running an interpreter for a C-like language I've been working on but it won't fit in the LMM memory model. I suppose any XMM modes are completely out of the question?
  • David BetzDavid Betz Posts: 14,511
    edited 2014-09-21 14:05
    Have you been using the release_1_0 branch of propgcc with Spinix or the default branch? The release_1_0 branch is the one that comes with SimpleIDE.
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-09-21 14:15
    I use the PropGCC that comes with SimpleIDE. Concerning XMM, I would like to get that working with spinix also. Since spinix requires having an SD card XMMC programs could execute from SD. Systems that have flash or external RAM could use that instead for better performance. I just need to figure out how to write a loader. I guess I would just need to see how the loader works that runs from EEPROM. Maybe you would have some suggestions on how to do that.
  • David BetzDavid Betz Posts: 14,511
    edited 2014-09-21 14:23
    Dave Hein wrote: »
    I use the PropGCC that comes with SimpleIDE. Concerning XMM, I would like to get that working with spinix also. Since spinix requires having an SD card XMMC programs could execute from SD. Systems that have flash or external RAM could use that instead for better performance. I just need to figure out how to write a loader. I guess I would just need to see how the loader works that runs from EEPROM. Maybe you would have some suggestions on how to do that.
    I would tell you how the loaders work but I'll have to first remember myself! :-)
  • Dave HeinDave Hein Posts: 6,347
    edited 2015-01-13 12:13
    I've been playing around with running XMMC programs under spinix, and I have a kludge that sort of works. Using SimpleIDE I built an XMMC program and burned the loader into EEPROM. I then wrote a program to read back the EEPROM and store it in a binary file. I then wrote a shell script called runpex that copies the PEX file to /autorun.pex and runs the binary file that contains the EEPROM image to run the XMMC program. That all works, but it only ran on the target board that I built the program for, which was a C3 board. So then I wrote a program call patchcfg the replaces the C3's SD configuration with the current board's configuration. This allows me to run the binaries on any board.

    The files are located in the attached ZIP file that contains a TAR file. It contains a floating point version of spinix's Basic interpreter called fbas.pex. To load the files, download the ZIP file and unzip it. Copy the TAR file to a spinix SD card. Under spinix run "tar -xf xmmc.tar" and then run "install". You can then run the fbas.pex program by typing "runpex fbas.pex". The following shows an example of an install and execution.
    /> tar -xf xmmc.tar
    filename = fbas.pex, filesize = 69464, attributes = 666, checksum = 0
    filename = install, filesize = 51, attributes = 666, checksum = 0
    filename = sd_cache.c3, filesize = 14232, attributes = 666, checksum = 0
    filename = fbas.c, filesize = 20181, attributes = 666, checksum = 0
    filename = fbas.sid, filesize = 154, attributes = 666, checksum = 0
    filename = sine.bas, filesize = 67, attributes = 666, checksum = 0
    filename = runpex, filesize = 163, attributes = 666, checksum = 0
    filename = patchcfg, filesize = 19432, attributes = 666, checksum = 0
    /> install
    Patching 2689 and 2690
    Patching __cfg_sdspi_config1 with 02000101
    Patching __cfg_sdspi_config2 with 03000000
    /> runpex fbas.pex
    Patching 15262 and 15263
    Patching __cfg_sdspi_config1 with 02000101
    Patching __cfg_sdspi_config2 with 03000000
    Patching 17342 and 17343
    Patching __cfg_sdspi_config2 with 03000000
    Patching __cfg_sdspi_config1 with 02000101
    Loading cache driver
    Initializing SD card
    Mounting SD filesystem
    Opening AUTORUN.PEX
    Loading kernel
    Loading cluster map
    Initializing cache
    Starting program
    Ok
    
    Ok
    old sine.bas
    Ok
    list
    10 p = 3.1415926
    20 for i = 0 to 20
    30 print sin(i*p/10)
    40 next i
    Ok
    run
    0.000000
    0.309017
    0.587785
    0.809017
    0.951057
    1.000000
    0.951057
    0.809017
    0.587785
    0.309017
    0.000000
    -0.309017
    -0.587785
    -0.809017
    -0.951057
    -1.000000
    -0.951057
    -0.809017
    -0.587786
    -0.309017
    -0.000000
    Ok
    bye
    />
    
    Hopefully, I can figure out how to build the SD cache load, and I'll be able to clean this up a bit.

    BTW, the fbas program is just an example of a large program with full stdio file support and floating point that would not fit as an LMM or CMM program. It's just a quick and dirty modification of the bas program, but using floating point instead of ints. I added the sin, cos, tan, asin, acos and atan functions to it. fbas works, but it runs slowly. XMMC is good for programs that contain a lot of code, and don't require high speed execution.
Sign In or Register to comment.