EasyManua.ls Logo

Commodore VIC-20 - Page 124

Commodore VIC-20
404 pages
Print Icon
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...
110
The
VIC
20
User
Guide
PEEK
and
POKE
Statements
PEEK and POKE are two VIC BASIC statements that you will
encounter in later chapters. VIC computers can have up to 65,536 individual
memory locations, each of which can store a number ranging between 0 and
255.
(This strange upper bound
is
in fact 2
8
-1.)
All programs and data are
converted into sequences of numbers which are stored in this fashion.
The PEEK statement lets you read the number stored in any VIC
computer memory location. Consider the following PEEK statement:
This statement assigns the contents of memory location 200 to variable A
%.
The PEEK argument may be a number, as shown, an integer variable name,
or
an integer expression, but it must evaluate to the address
of
a memory
location.
The POKE statement writes data into a memory location.
For
exam-
ple, the statement
20
POKE
Se00/A"
stores the contents of variable
A%
in memory location 8000. Each POKE
argument may
be
a number, a variable,
or
an expression with a value
between 0 and 255. A floating point value
is
automatically converted to an
integer.
You can PEEK into read / write memory
or
read -only memory, but you
can POKE only into read/write memory. Read-only memory, as its name
implies, can have its contents read, but cannot
be
written into.
END
and
STOP
Statements
The END and STOP statements halt program execution. You can
continue execution by typing CONT. You do not have to include END
or
STOP statements in your program, but these statements do make programs
easier to use.
In
many of the programming examples given in this chapter
we
have
used a GO TO statement that branches to itself in order to stop program
execution.
For
example, the statement
50
OOTO
50

Other manuals for Commodore VIC-20

Related product manuals