Topic : The GFA-Basic Compendium
Author : GFA Systemtechnik GmbH
Version : GFABasic.HYP v2.98 (12/31/2023)
Subject : Documentation/Programming
Nodes : 899
Index Size : 28056
HCP-Version : 3
Compiled on : Atari
@charset : atarist
@lang :
@default : Document not found
@help : Help
@options : +g -i -s +z
@width : 75
@hostname : STRNGSRV
@hostname : CAB
@hostname : HIGHWIRE
@hostname : THING
View Ref-FileThe compiler option $Mx is used to generate a program which will simply reserve
x bytes for itself. Normally a program generated with the 3.0
compiler claims all available memory space (minus 16 kb) for itself.
The instruction RESERVE can be used to force a program to claim only part of
the free memory, but this has an effect different from the $mx option. A
program beginning with RESERVE 25600, for example, will first claim all free
memory when run. The GFA BASIC instruction RESERVE will only then be executed
and release some of the reserved space again.
By contrast, the compiler option $m25600 will ensure that not all free memory,
but only 25600 bytes (if available) will be used by the program. This compiler
option must be used in accessories which may only use part of the free memory.
You can find an example in the chapter on accessories.
Memo: The space between the option and the number is optional.
Example: $m 2048
The compiler does not actually accept values in the range of 0 to 999.
Any value in this range is automatically replaced with 1000.
Odd values are rounded down (made even): $M65535 -> allocates 65534 kb
Important: If the exact value cannot be allocated (ram too low) it
gives the application all the available ram minus 16384 bytes. This
could cause a program to behave strangely or crash, since the program
doesn't know it was given a smaller amount than requested.
This situation can be detected with the following code:
IF MALLOC(-1)<=16384
PRINT "$M failed, program terminated!"
EDIT
ENDIF
Under MiNT memory is rounded to an 8kb boundary, so you might as well
request a size pre-rounded up, this way your program can use the ram
that would normally be wasted.
What exactly is contained in this block of memory:
Dimensioned arrays (all types): DIM tmp$(10),buf|(32),ptr%(12)
This also includes all data stored in the array and its descriptor.
All assigned strings: t$="test"
This also includes the string descriptor.
This can be a very tricky value to compute! It may requires some trial
and error.
What is not in this block of memory?
All assigned numerical variables (all types): a#=3.16 or size%=2048
These are stored in the BSS section of the binary.