Announcement
Collapse
No announcement yet.
DOS / PB3.5 Memory Basics?
Collapse
X
-
There are also CODESEG / CODEPTR statements which will return the location of a specific piece of the executable code in memory.
-
. After dimensioning a bunch of 4k-10k byte arrays how do I locate them correctly so I can BLOAD the graphics into them? Do I need to take any precautions so they don't cross 64k segment boundaries?
BLOAD must be executed with DEF SEG set to the VARSEG of the first element of the target array. (As stated and shown in the help file under BLOAD).
2. How can I tell (within the PB program) where the PowerBasic executable ends up in DOS memory? how much memory is left for additional data arrays and can I have the program allocate the remaining memory to a large array.
3. There are two $segment directives spaced in the source code, how do I know that they are at the 'right' places? For a 200k program, shouldn't there be three $segment directives for a total of four 64k blocks?
4 The program has DIM statements scattered throughout it, many after varying amounts of executable code. Is this a problem, shouldn't most/all? DIM's be in the beginning of the program? How big a problem is this
I think you should make sure you are using dynamic arrays, which can be done by using either the $DYNAMIC directive, REDIM instead of DIM, the DYNAMIC option in the DIM statement or by using a variable for the max subscript in the DIM statement. I'm guessing you probably are using dynamic arrays (or program would not load at all if insufficient memory were available), but I'd check anyway.
5. Is there a way to 'see' the memory layout of the executable and all of the arrays to know where things are going into memory?
I need to learn how to properly use DEF SEG and all the related commands to properly handle the memory needed for this program
MCM
Leave a comment:
-
DOS / PB3.5 Memory Basics?
Hi all,
I'm looking for a place to learn the correct way to manage DOS memory from within PowerBasic for things like graphic arrays, were/how to BLOAD graphic files, how much 'extra' memory is available to allocate to a large numeric array, etc.
I'm new to PowerBasic and this forum, but have been programming in basic (BBX) for many many years. In a previous life I wrote small DOS .com utilities in assembly. I understand most of the general layout of DOS memory but not completely how PowerBasic interacts with it.
I've recently inherited a moderate sized (200k) PowerBasic program that reads files into large arrays and does vga screen graphics, the program also loads graphic images via BLOAD.
I made some simple changes to the program which changed the executable size by about 16k (smaller)... The program would not run without crashing (CNTRL-ALT-DEL style) and/or some graphic images BLOADed wouldn't display.
My hunch is that some Arrays are declared in the wrong places in the basic program, or there are files being BLOADED into the executable in memory or over some DOS memory, and that by changing the size of the executable, I've caused the program to somehow improperly cross a segment boundary or load graphics into program areas.
I need to learn how to properly use DEF SEG and all the related commands to properly handle the memory needed for this program.
Specifically, I'm looking to learn:
1. After dimensioning a bunch of 4k-10k byte arrays how do I locate them correctly so I can BLOAD the graphics into them? Do I need to take any precautions so they don't cross 64k segment boundaries?
2. How can I tell (within the PB program) where the PowerBasic executable ends up in DOS memory? how much memory is left for additional data arrays and can I have the program allocate the remaining memory to a large array.
3. There are two $segment directives spaced in the source code, how do I know that they are at the 'right' places? For a 200k program, shouldn't there be three $segment directives for a total of four 64k blocks?
4. The program has DIM statements scattered throughout it, many after varying amounts of executable code. Is this a problem, shouldn't most/all? DIM's be in the beginning of the program? How big a problem is this?
5. Is there a way to 'see' the memory layout of the executable and all of the arrays to know where things are going into memory?
Any suggestions on where I can learn more about these issues would greatly appreciated. I've been through my PB-DOS 3.5 manuals but don't feel that I've absorbed all I need to know.
TIA,
JohnLast edited by John R. Seitz; 28 Nov 2007, 02:47 AM.Tags: None
Leave a comment: