Shop OBEX P1 Docs P2 Docs Learn Events
out of memory on prop question? — Parallax Forums

out of memory on prop question?

vettezr1vettezr1 Posts: 77
edited 2010-09-22 18:06 in Propeller 1
Hi guys I have a problem I need to understand .. First I should state I have a few prop boards ,, Dr-Acula's, and other boards that have quite a bit of sram on them my problem is I wrote a program in spin for the prop but on a standard prop board like the proto board or demo board or Hydra I only have the ram/rom that comes with them my question is on the other boards I think I can only use the extra ram when running CPM is there anyway to just add a simple sram to a very basic prop board where my large program can just use the extra ram running spin?
I just need an extra 16K is this something that can be done???
Thanks guys

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-21 17:14
    The simple answer is no, you can't. There are ways around this sort of limitation, but they're not simple and don't really allow you to expand the amount of RAM available.

    There are all sorts of ways to attach external RAM to a Prop, but they all use lots of I/O pins (parallel SRAM) or are very slow (serial SRAM) and, in any event, these solutions provide memory that's not the same as that on the Prop chip. Several people have written programs like CP/M emulators or other CPM emulators that can use this external RAM with a speed penalty. There are also compilers like Catalina (C) that can use this external RAM, but as a separate memory. It's possible to attach serial SRAM to a Demo Board or a Hydra with the limited I/O pin availability and Bill Henning has been working on a virtual memory system that copies in code and data from the serial SRAM as needed and runs nearly as fast as something that uses just the internal Prop RAM, but it's not ready for casual use. Read some of the thread on the ZOG interpreter and Bill Henning's virtual memory code for ideas.

    There are all sorts of ways to save on memory. Often recoding part of your program and changing how the logic works can save a lot. Other times, people put a lot of strings in a program and each copy of the same string takes a separate piece of memory.
  • pjvpjv Posts: 1,903
    edited 2010-09-21 19:30
    Hi Vettezr1;

    I might have an answer sometime in the near future, but it depends a lot on your progtam and language.... that is if you are able to run in assembler.

    I am working on a system (mostly running... some tweaks still required) whereby cogs can load and swap any number of sections of program (to the cog size limit at any one time) at runtime from hub, and execute them at full speed. It would be a minor extension to permit that load too happen from an external SD card, albeit loading from hub would be quite a bit faster.

    In essence the program sections are re-locatable when pulled into the cog ram. If you are operating in Spin, then my approach would not work for you. And also if for some reason all your program needed to be resident inside the processer all of the time it also would not be suitable.

    So my approach is very dependent on you program's needs, but it just might work.

    Cheers,

    Peter (pjv)
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-09-21 19:34
    ...my question is on the other boards I think I can only use the extra ram when running CPM is there anyway to just add a simple sram to a very basic prop board where my large program can just use the extra ram running spin?

    That is why I am using CP/M. Not because I like old operating systems, but rather, because when I start writing a program and it very quickly grows to 1000 lines, I don't want to have to worry about running out of memory. Indeed, I don't even want to think about memory when I am coding.

    No one has written "big spin". Yet.

    But there are other options. Use C and I think you can use the extra sram with Catalina. I believe one of the Basic programs might be able to as well.

    CP/M can do a lot of things - on-board text editing, xmodem for wired (and wireless) file transfers. Multiple languages, including Pascal (which looks very similar to Spin).

    As an aside, someone over on the N8VEM forum has just posted some code for Space Invaders that is written in C with inline Z80 assembly. I'm waiting on more details, but with MPM you could have 8 programs running in parallel with 48k of memory for each program. Code fragment below.
    void Init9918Mode(ushort GMode,	ushort SpSize, ushort SpMag, ushort NTBase, ushort CTBase, ushort PTBase, ushort SABase, ushort SPBase, ushort Color)
    {
    	int temp;
    	#asm
    	LD A,255
    	OUT (84),A
    	#endasm
    	if((GMode & 4)>0)
    	{	
    		Set9918Register(2,128);
    	}
    	else
    	{
    		Set9918Register(0,128);
    	}
    }
    
  • jazzedjazzed Posts: 11,803
    edited 2010-09-21 21:18
    Dr_Acula wrote: »
    That is why I am using CP/M. Not because I like old operating systems, but rather, because when I start writing a program and it very quickly grows ....
    Really? LOL :) So if you have plenty of RAM you won't use CPM? :)

    Big Spin is possible, but without compiler support, it's unbearable - been there, done that.
  • AleAle Posts: 2,363
    edited 2010-09-22 07:23
    jazzed:

    we may have to convince Brad or mpark to "enhance" their compilers to support some external RAM and then rewrite the interpreter to use it. Maybe a LMM interpreter could be faster than the built-in (avoiding all the this-code-is-not-executed)
  • jazzedjazzed Posts: 11,803
    edited 2010-09-22 08:21
    While it may be possible to get BradC or mpark to support a Big Spin, I think existing alternatives make that less practical.

    Spin is a good native language for Propeller. Huge 32MB+ programs can be run on Propeller with C and external memory. I have 32MB SDRAM working with ZOG and will finish porting Catalina and continue other projects when I'm finished with the I2C keyboard/mouse interface.
  • vettezr1vettezr1 Posts: 77
    edited 2010-09-22 15:57
    Thanks guys DR_A I use your board a lot with CPM I love it. Yes I could run ASM but I do not know how to code with it yet.. Thanks
    Mike I should have mentioned I do need most of my I/O guys I have no doubt my code is bloated I am very in-experienced at programing so I wrote the whole thing in Spin I am not even calling OBJ's with the exception of PST most of my code is all dira outa and freq stuff I was quite suprised by the out of memory error but my code is over 20 pages I am not sure I would have to worry about speed Mike (serial Ram) but I am not sure how to use them
    my program is just one big giant I/O I also read input switches then based on that output to a servo or transistor


    Thanks guy if anyone can show me how to use a serial ram I would be very thankfull
  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-22 16:01
    There's a Flash Memory driver in the Object Exchange that also support serial SRAM (here).

    I suspect that it'll be a better use of your time and effort to trim down your program. You probably have a lot of duplicate code where most of a routine is identical to other routines ... a great candidate for subroutines.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-09-22 16:04
    To save memory you might look for blocks of code that are repeated an make them methods. Also look at program structure. You may be able to turn a linear block of code into a repeat loop. For example aaaaa could become repeat 5 a.

    John Abshier
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-09-22 18:06
    There are many ways to solve this problem - learn C, learn Z80 assembly, learn PASM, but I wonder if the first one to try might be to post your code as an attachment (warts and all) and we can have a look at it and maybe there are some really simple things that could be changed as John suggests.
Sign In or Register to comment.