Jump to content
IGNORED

So what exactly is the Stack for in Extended BASIC programming?


Airshack

Recommended Posts

I have a few questions about the Extended BASIC manual p169, SIZE command:

 

"...the stack is the amount of space left after the space taken up by string variables, information about variables, and the like is subtracted. The program space is the space left after the space taken up by the program and the values of numeric variables is subtracted."

 

Questions:

 

1. Why does usage of string variables in fact remove space from the "BYTES OF PROGRAM" and not from "BYTES OF STACK FREE?"

 

2. What does, "information about variables, and the like" ​mean specifically? Any good known references?

 

3. Is there and way to exploit STACK space while saving PROGRAM space in Extended BASIC?

 

Link to comment
Share on other sites

I have a few questions about the Extended BASIC manual p169, SIZE command:

 

"...the stack is the amount of space left after the space taken up by string variables, information about variables, and the like is subtracted. The program space is the space left after the space taken up by the program and the values of numeric variables is subtracted."

 

Questions:

 

1. Why does usage of string variables in fact remove space from the "BYTES OF PROGRAM" and not from "BYTES OF STACK FREE?"

 

2. What does, "information about variables, and the like" ​mean specifically? Any good known references?

 

3. Is there and way to exploit STACK space while saving PROGRAM space in Extended BASIC?

 

One good source is the page on Thierry Nouspikel's site for VDP RAM use for the Extended Basis cartridge.

 

Regarding (1) and (2), setting a string variable to a string, say

 

A$ = "abcdefghijklmnopqrstuvwxyz"

 

will only use stack space, i.e., VRAM, your results to the contrary notwithstanding. Whereas, reserving variable space by DIM or setting variables to values will use expansion RAM for the numbers themselves, but will use VRAM for information about the numbers, such as their names and locations in RAM.

 

Regarding (3), the only way I know to use stack space (VRAM) directly is via an ALC routine. You obviously need to be very careful you do not step on XB functionality in the process. As long as you work down from the highest available VRAM location pointed to by >8370. There may also be a way to monitor the bottom location of VRAM free space (>831A?), but I am not sure what that might be. It is not clear from Thierry's site.

 

There are other references available. One that is useful is the Dow TI Home Computer Assembly Language Primer, which should be on WHTech. Useful issues of The Smart Programmer and Micropendium are also on WHTech under “magazines”, I believe. There are surely other resources folks will add to this list.

 

...lee

  • Like 1
Link to comment
Share on other sites

If you type SIZE before running a program, the string variable information typed as part of the program consumes program space. That is, the typed text consumes program space just like the statements, commands, subprograms, variables, and other entities. You can test this yourself by entering a line or two with the PRINT statement (i.e., 10 PRINT "HELLO").

 

When you RUN a program, string spaced is consumed as you assign/manipulate the strings.

10 A$="HELLO"

In the case above, the string "HELLO" consumes program space before and during execution; it also consumes stack space during execution.

 

If you press FCTN-4 (BREAK) to halt the program execution, then type SIZE: the stack space will be reduced based on your string assignments. Available program space will be further diminished by the numeric variables that are declared and/or used in the program.

  • Like 1
Link to comment
Share on other sites

 

One good source is the page on Thierry Nouspikel's site for VDP RAM use for the Extended Basis cartridge.

 

Regarding (1) and (2), setting a string variable to a string, say

 

A$ = "abcdefghijklmnopqrstuvwxyz"

 

will only use stack space, i.e., VRAM, your results to the contrary notwithstanding. Whereas, reserving variable space by DIM or setting variables to values will use expansion RAM for the numbers themselves, but will use VRAM for information about the numbers, such as their names and locations in RAM.

 

Regarding (3), the only way I know to use stack space (VRAM) directly is via an ALC routine. You obviously need to be very careful you do not step on XB functionality in the process. As long as you work down from the highest available VRAM location pointed to by >8370. There may also be a way to monitor the bottom location of VRAM free space (>831A?), but I am not sure what that might be. It is not clear from Thierry's site.

 

There are other references available. One that is useful is the Dow TI Home Computer Assembly Language Primer, which should be on WHTech. Useful issues of The Smart Programmer and Micropendium are also on WHTech under “magazines”, I believe. There are surely other resources folks will add to this list.

 

...lee

 

That DOW Primer is exactly what I've been needing to check out. Thanks Lee.

Link to comment
Share on other sites

If you type SIZE before running a program, the string variable information typed as part of the program consumes program space. That is, the typed text consumes program space just like the statements, commands, subprograms, variables, and other entities. You can test this yourself by entering a line or two with the PRINT statement (i.e., 10 PRINT "HELLO").

 

When you RUN a program, string spaced is consumed as you assign/manipulate the strings.

10 A$="HELLO"

In the case above, the string "HELLO" consumes program space before and during execution; it also consumes stack space during execution.

 

If you press FCTN-4 (BREAK) to halt the program execution, then type SIZE: the stack space will be reduced based on your string assignments. Available program space will be further diminished by the numeric variables that are declared and/or used in the program.

So there's no XB way to say... assign all my strings to variables early on to offload the memory space to the stack instead of the program space?

Link to comment
Share on other sites

So there's no XB way to say... assign all my strings to variables early on to offload the memory space to the stack instead of the program space?

 

pre-scan it does something like that, allocates all the memory right at the beginning and "prescans" your program to make it start faster..

  • Like 1
Link to comment
Share on other sites

So there's no XB way to say... assign all my strings to variables early on to offload the memory space to the stack instead of the program space?

Let's say you have a really simple program:

10 READ A$

15 GOTO 15

20 DATA "HELLO WORLD"

When line 10 reads line 20 the string "HELLO WORLD" is copied into VDP ram, but line 20 is still taking up space as part of the program in CPU memory. There is not really any practical way to get rid of line 20, even though you no longer have a use for it. You could put the strings in a disk file and read them off the disk and into the string space in VDP ram. Without them taking up space in the actual program you would then have more room for program statements. Most people like to have a program as a self contained unit, but sometimes you need to do things another way.

  • Like 3
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...