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-FileWhen changing integer variables, the GFA BASIC interpreter checks that the
value of the variable lies within the range for this variable type. The legal
ranges for the three types of integer variables are:
Type Postfix Minimum Maximum
Byte | 0 255
Word & -32768 32767
Long % -2147483648 2147483647
When the legal range is exceeded, error numbers (depending on the type of
variable affected) 2, 3 or 4 are triggered (Number not integer, byte, or word).
Such an error is known as integer overflow.
A program generated with the 3.0 compiler will not always be checked
for integer overflow. Such a check is superfluous in an error-free program and
only requires time and space. It is only sensible during program development
with the interpreter.
The program:
x&=10000
y&=4*x&
PRINT y&
generates the error message "Number not word" in the interpreter, whereas the
compiled program writes -25536 to the screen with no error message.
From the first two lines of the program, the compiler will generate the
following code (without the comments, of course):
move.w #$2710,-$8000(a5) ;$2710 is 10000 decimal
;$8000(a5) is the address of x&,
;the instruction therefore equals
;the line x&=10000.
move.w -$8000(a5),d0 ;x& is written into data
;register 0.
asl.w #$2,d0 ;The multiplication with a power
;of 2 (4 in this case) is
;executed with a fast bit shifting
;command.
move.w d0,-$7ffe(a5) ;-$7ffe(a5) is the address of
;y&. Thus result of the
;multiplication is assigned to
;y&.
The advantage of the non-existing integer overflow check results in the high
speed of the code. A program with a FOR loop and simple additions and
subtractions of integer variables is faster than in the interpreter by a factor
of 26.