Using Memory Lo Catio N; Using Peek And Poke For Ram A C Ce Ss - Commodore 128 System Manual

Hide thumbs Also See for 128:
Table of Contents

Advertisement

The ON statement is used with either the GOTO or GOSUB-
RETURN commands, depending on what you need the program
to do. A variable or calculation should be after the ON command.
After the GOTO or GOSUB command, there should be a list of
line numbers. Type in the program below to see how the ON
command works.
10 ?"ENTER A NUMBER BETWEEN ONE AND FIVE"
20 INPUT X
30 ON X GOSUB 100,200,300,400,500
40 END
100 ? "YOUR NUMBER WAS ONE":RETURN
200 ? "YOUR NUMBER WAS TWO":RETURN
300 ? "YOUR NUMBER WAS THREE":RETURN
400 ? "YOUR NUMBER WAS FOUR" :RETURN
500 ? "YOUR NUMBER WAS FIVE" :RETURN
When the value of X is 1, the computer branches to the first line
number in the list (100). When X is 2, the computer branches to
the second number in the list (200), and so on.
USING MEMORY LOCATIONS
Using PEEK and POKE for RAM/ROM access
Each area of the computer's memory has a special function. For
instance, there is a very large area to store your programs and
the variables associated with them. This part of memory, called
RAM, is cleared when you use the NEW command. Other areas
are not as large, but they have very specialized functions. For
instance, there is an area of memory locations that controls the
music features of the computer.
There are two BASIC commands—PEEK and POKE—that you
can use to access and manipulate the computer's memory. Use
of PEEK and POKE commands can be a powerful programming
device because the contents of the computer's memory locations
determine exactly what the computer should be doing at a
specific time.
4-18

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

128d

Table of Contents