Jump to content
IGNORED

STACK, DATA, and strings


Opry99er

Recommended Posts

Bear with me... I'm going to work through an issue in my head here and I hope someone might have some additional opinions that might give me a little better understanding. Thanks in advance.

 

I'm working on a project right now that requires a significant amount of text to be available to the program for display. I have chosen to put all the text into DATA statements, and then use a small subroutine to load all the text into a string array.

 

It works beautifully, but I am noticing that it is chewing through my stack space. So far I have 33% of all the required text in DATA statements, but my stack space has been cut in half with just the 1/3 of text I need. I still have enough PROGRAM space, I think, to finish the project.

 

Two things:

 

1) I don't mind hitting a disk for the data, but I only want to do it once. This means that the stack space will still have to absorb all this text into the string arrays, and we will probably run out of stack space.

 

 

Example of #1: (text on disk pulled into a string array)

Initialize
Open disk file
Read all text from disk and feed it into a text array
Close disk file
 
Begin Program
Display Text from string arrays
End Program
 

In this scenario we save PROGAM space, but not STACK space.

 

 

2) I COULD read the text directly from the DATA statements and bypass the use of string arrays. This, however, would require that all the DATA is in my program at all times, and would significantly cut down on my PROGRAM space.

 

Example of #2: (text read from DATA statements and displayed as needed)

Initialize
 
Begin Program
Display text from DATA statements as needed using RESTORE
End Program
 

In this scenario, we save STACK space, but not program space

 

 

Perhaps there is something I missed here... Any thoughts?

Edited by Opry99er
Link to comment
Share on other sites

You're actually doubling your usage with that approach.

 

If you want to be as efficient as possible, you either:

  1. Store your text in DATA statements and READ them into a single static string only as needed. This requires copious use of RESTORE commands to point to the right location to read text from
  2. Store all your text on disk and read them into string arrays at the start of the program

If you are already seeing half the stack burned with only 1/3 of your actual data complete, that means you may not have enough space for it using a single method. You could use both methods though to share the load between the two memory types.

Link to comment
Share on other sites

You're actually doubling your usage with that approach.

 

If you want to be as efficient as possible, you either:

  1. Store your text in DATA statements and READ them into a single static string only as needed. This requires copious use of RESTORE commands to point to the right location to read text from
  2. Store all your text on disk and read them into string arrays at the start of the program

If you are already seeing half the stack burned with only 1/3 of your actual data complete, that means you may not have enough space for it using a single method. You could use both methods though to share the load between the two memory types.

 

 

I think I can absorb more of a hit to my PROGRAM space at this point than STACK. I may need to re-think the extent of detail in the text.

Link to comment
Share on other sites

One nice feature of my DATA is the padding. Each segment of data takes up 9 DATA statements. I need only offset the RESTORE by that many statements in order to retrieve the correct information.

 

The question is, can I GOTO A... where A is a variable containing a line number. I havent tested it yet, but Im sure we could find a way to skin that cat. :)

Link to comment
Share on other sites

You don't need to place your strings in arrays, they're already in memory as data statements. Why have them in memory twice? ;-)

 

Yes sir... I have two options... put them in arrays (drawn from disk) or use DATA statements to house the data. Im trying to find the best way to accomplish the goal.

Link to comment
Share on other sites

Thats what I am hoping to do... but I dont think the stack will be able to withstand the onslaught of data.

 

Im going to try though. Adams suggestion will likely be my only option, but Im going to try to load the text data in one big WHAM from disk and cross my fingers.

Edited by Opry99er
Link to comment
Share on other sites

Thats what I am hoping to do... but I dont think the stack will be able to withstand the onslaught of data.

 

Im going to try though. Adams suggestion will likely be my only option, but Im going to try to load the text data in one big WHAM from disk and cross my fingers.

 

 

It's been 30 something years but I know I built a pretty big application on TI-BASIC that used a database of information and I could read the records from disk with just an record number.

(it even used a binary search for find key strings in the records. :-) You should have heard the old disk drives chunking!)

Couldn't you make a separate program that creates all your text on a file and then the final program can pull them in by record number, like you would in an array, and print them to the screen?

That way you only have the strings in memory that you need to display at the time.

Am I missing something else important?

  • Like 1
Link to comment
Share on other sites

No... only that if I pull data from an external source, I can only do it once.

 

This program is being designed to run from tape, so record access is tough and limited. I want to load the program into memory, then hit a big record pull from cassette all at once to populate the arrays...

 

Or, as has been suggested, keep all records in DATA statements and access them as needed using RESTORE.

Link to comment
Share on other sites

Had some success! I was able to put all the data into a data file and pull it all in one clean shot. It leaves me with only 2K of stack space left, but I think that is okay.

 

I need to learn the size limits of data files that can be pulled from CS1, because my current data file is a hair over 9K. The main program is now less than 2K, but that will grow significantly now that I have some headroom.

 

Thanks for the suggestions, folks. :)

Link to comment
Share on other sites

No... only that if I pull data from an external source, I can only do it once.

 

This program is being designed to run from tape, so record access is tough and limited. I want to load the program into memory, then hit a big record pull from cassette all at once to populate the arrays...

 

Or, as has been suggested, keep all records in DATA statements and access them as needed using RESTORE.

 

 

AH... I missed the Cassette component. Serial access only.

Link to comment
Share on other sites

Lol!!! Weve got PEBs... This is primarily a Because its There deal. There will be no official or unofficial release for diskette. If this thing comes together as planned, youll either need a modem or a cassette player to play it. :D

Edited by Opry99er
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...