EasyManua.ls Logo

Atari 800

Atari 800
122 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
RESTORE (RES.)
In
the
description
of
the
FOR/NEXT
statement,
the
stack
was
defined
as a
group
of
memory
addresses
reserved
for
return
addresses.
The
top
entry
in
the
stack
controls
the
number
of
loops
to
be
executed
and
the
RETURN
target
line
for
a
GOSUB.
If
a
subroutine
is
not
terminated
by
a RETURN
statement,
the
top
memory
location
of
the
stack
is still
loaded
with
some
numbers.
If
another
GOSUB
is
executed,
that
top
location
needs
to
be
cleared.
To
prepare
the
stack
for
a
new
GOSUB,
use
a POP
to
clear
the
data
from
the
top
location
in
the
stack.
The
POP
command
must
be
used
according
to
the
following
rules:
1.
It
must
be
in
the
execution
path
of
the
program.
2.
It
must
follow
the
execution
of
any
GOSUB
statement
that
is
not
brought
back
to
the
main
program
by
a RETURN
statement.
The
following
example
demonstirates
the
use
of
the
POP
command
with
a
GOSUB
when
the
RETURN is
not
executed:
10
Go~:;us
1000
15
F.:Et-1
LINE
20
WLL
t·mT
BE
E>=:ECUTED
:::1:.1
PF.:
I
t·n
II
t·~OPt·1AL
F.:ETuft:t·~
FR
I
t·ns
TH
I~=;
t·1Ef;~:;
AGE.
H
30
PF.:WT
11
ABt·iOlmAL
PETUF:t-l
PPrt-n::;
THI::;
r·1E
SSAGE.
11
40
POP
999
HiD
1
f1t-:::1~~1
F~~~
I
t·iT
II
t·~o~~J
E::<ECiJT
I
t·i~~
~:;uE:F.:CHJT
I
t·1E
.
!I
1010
GOTO
30
1020
~:ETUF:ti
Figure
4-11.
GOSUB
Statement
With
POP
Format:
Example:
RESTORE [aexp]
100 RESTORE
The
Atari
Personal
Computer
System
contains
an
internal
"pointer"
that
keeps
track
ofthe
DATA
statement
item
to
be
read
next.
Used
without
the
op-
tional
aexp,
the
RESTORE
statement
resets
that
pointer
to
the
first
DATA
item
in
the
program.
Used
with
the
optional
aexp,
the
RESTORE
statement
sets
the
pointer
to
the
first
DATA
item
on
the
line
specifed
by
the
value
ofthe
aexp.
This
statement
permits
repetitive
use
of
the
same
data.
10
FOR
N=1
TO
2
20
READ
A
30
RESTORE
40
READ
B
50
t·l=A+B
60
PRIHT
11
TOTAL
EQUALS
11
;M
70
NE:>\T
N
00
END
90
DATA
30,15
Figure
4-12.
Restore
Program
Listing
On
the
first
pass
through
the
loop, A
will
be
30
and
B
will
be
30 so
the
total
line
50
will
print
SUM
TOTAL
EQUALS
60,
but
on
the
second
pass, A
will
equal15
Program
Statements
21

Table of Contents

Other manuals for Atari 800

Related product manuals