c64-programmers_reference_guide-01-basic_programming_rules.pdf
(
2228 KB
)
Pobierz
INTRODUCTION
about
This chapter
talks
how
BASIC stores and
manipulates
data.
The
topics
include:
1) A brief
mention
of the operating
system components
and
functions
as well
as the
character
set used
in the
Commodore
64.
2)
The formation
of constants
and
variables.
What
types
of variables
there
are.
And
how constants
and variables
are stored
in memory.
3)
The rules for
arithmetic
calculations,
relationship
tests,
string
han-
dling,
and
logical
operations.
Also included
are the rules for
form-
ing
expressions,
and
the
data
conversions
necessary
when
you're
using
BASIC with
mixed
data
types.
SCREEN DISPLAY CODES
(BASIC
CHARACTER SET)
THE OPERATING
SYSTEM
(OS)
is
contained
The Operating
System
in the
Read
Only
Memory
(ROM)
chips
and
is a combination
of three
separate,
but interrelated,
program
modules.
1) The
BASIC Interpreter
2)
The
KERNAL
3)
The Screen
Editor
1)
The
BASIC
Interpreter
is responsible
for
analyzing
BASIC state-
ment
syntax
and
for
performing
the
required
calculations
and/or
data
manipulation.
The BASIC Interpreter
has a vocabulary
of 65
"keywords"
which
have
special
meanings.
The
upper
and
lower
case alphabet
and the digits
0-9
are used to make
both
keywords
and
variable
names.
Certain
punctuation
characters
and
special
1-1
lists tl1e
symbols
also have
meanings
for
the Interpreter.
Table
special
characters
and
their
uses.
2)
The KERNA
handles
most
of the
interrupt
level
processing
in the
system
(for
details
on
interrupt
level
processing,
see Chapter
5).
The
KERNAL also
does
the
actual
input
and
output
of data.
3)
The
Screen
Editor
controls
the output
to the video
screen (television
set) and the editing
of BASIC program
text.
In addition,
the Screen
Editor
intercepts
keyboard
input
so that
it can
decide
whether
the
2
BASIC PROGRAMMING RULES
Table 1-1. CBM BASICCharacter Set
NAMEand DESCRIPTION
CHARACTER
BLANK-separates
keywords
and
variable
names
SEMI-COLON-used
in variable
lists to format
output
;
=
EQUAL SIGN-value
assignment
and
relationship
testing
PLUSSIGN-arithmetic
+
*
/
t
(
addition
or string concatenation
(concatenation:
linking together
in a chain)
MINUS SIGN-arithmetic
subtraction,
unar{. minus (-1)
ASTERISK-arithmetic multiplication
SLASH-arithmetic division
UP ARROW-arithmetic exponentiation
LEFTPARENTHESIS-expression
evaluatiorl
and
functions
RIGHT PARENTHESIS-expression
)
evaluatibn
and
functions
%
#
PERCENT-declares
variable
name
as
ani integer
NUMBER-comes
before
logical file num~er
in input/
output statements
DOLLARSIGN-declares
$
variable
name
s a string
COMMA-used
in variable
lists to forma
output;
also
separates
command
para
eters
PERIOD-decimal
point
in floating
point
onstants
If
QUOTATION MARK-encloses
string
cons ants
COLON-separates
multiple BASIC statem
nts in a line
?
<
>
7T
QUESTION MARK-abbreviation
for the ke
ord PRINT
LESSTHAN-used
in relationship
tests
GREATERTHAN-used
in relationship
test
PI-the
numeric
constant
3.141592654
characters
put in should
be acted
upon immediatelyl
or passed
on
to the
BASIC Interpreter.
The Operating
System
gives
you two
modes
of
BASIC loperation:
1)
DIRECTMode
2)
PROGRAM
Mode
1) When you're
using the
DIRECTmode,
BASIC statem~nts
don't
have
line
numbers
in
front
of
the
statement.
They
are
executed
whenever
the
.:~IIIIII:~/. key is pressed.
2) The
PROGRAM mode
is the
one
you
use
for
running
programs.
BASIC PROGRAMMING RULES
3
using
all
of
your
When
the
PROGRAM
mode,
BASIC
statements
in front
of them.
You can
have
more
than
must have
line numbers
BASIC
statement
in a line of your program,
but the number
of
one
statements
is
limited
by
the
fact
that
you
can
only
put
80
char-
acters
on
a
logical
screen
line.
This means
that
if you
are
going
to
go
over
the
80 character
limit you
have
to
put
the
entire
BASIC
statement
that
doesn't
fit
on
a
new
line
with
a
new
line
number.
hit
DI!IiIII
before
NOTE: Always
type
NEW and
starting
a
new
program.
The Commodore
64 has two complete
character
sets that you can
use
either from the keyboard or in your programs.
In SET 1, the upper case alphabet and the numbers 0-9 are available
without pressing the IDIIiI key. If you hold down the IDIIiI key
while typing, the graphics characters on the
RIGHT
side of the front of
the keys are used. If you hold down the
[i
key while typing, the
graphics characters on the
LEFT
side of the front of the key are used.
Holding down the IDIIiI key while typing any character that doesn't
have
graphic symbols on the front of the key gives you the symbol on the
top most part of the key.
In SET2, the lower case
alphabet
and
the numbers
0-9
are available
without
pressing
the
IDIIiI
key. The upper
case
alphabet
is available
when
you hold down
the
IDIIiI
key while typing.
Again,
the graphic
symbols
on the LEFTside of the front of the keys are
displayed
by press-
[i
ing the
key, while the
symbols
on the
top
most
part
of any
key
without
graphics
characters
are
selected
when
you
hold
down
the
IDIIiI
key while
typing.
[i
To switch
from
one
character
set
to the
other
press
the
and
the
IDIIiI
keys together.
PROGRAMMING
NUMBERS
AND VARIABLES
INTEGER, FLOATING.POINT AND
STRING CONSTANTS
Constants
are
the data
values
that
you put in your
BASIC
statements.
BASIC
uses
these
values
to
represent
data
during
statement
execution.
CBM
BASIC
can
recognize
and
manipulate
three
types
of
constants:
1)
INTEGER NUMBERS
2)
FLOATING-POINT
NUMBERS
3)
STRINGS
4
BASIC PROGRAMMING RULES
constants
Integer
are
whole
numbers
(numbers
without
decimal
-32768
points).
Integer
constants
must
be
between
and
+32767.
In-
teger
constants
do not have
decimal
points
or commas
between
digits.
If the
plus (+)
sign
is left
out,
the constant
is assumed
to be a positive
number.
Zeros
coming
before
a constant
are
ignored
and
shouldn't
be
used since they waste
memory
and
slow down
your
program.
However,
they
won't
cause
an
error.
Integers
are
stored
in memory
as two-byte
binary
numbers.
Some
examples
of integer
constants
are:
-12
8765
-32768
+44
o
-32767
NOTE:
Do NOT put commas
inside
any
number.
For example,
always
type
32,000
as
32000.
If you
put
a comma
in the
middle
of a
number
you will get
the
BASIC error
message
?SYNTAX ERROR.
Floating-point
constants
are
positive
or
negative
numbers
and
can
contain
fractions.
Fractional
ports
of
a number
may
be
shown
using
a
decimal
point.
Once
again
remember
that
commas
are
NOT used
be-
tween
numbers.
If the plus sign (+)
is left off
the front
of a number,
the
64
assumes
Commodore
that
the number
is positive.
If you leave
off
the
decimal
point
the
computer
will
assume
that
it follows
the
last
digit
of
the
number.
And
as with
integers,
zeros
that
come
before
a constant
are
ignored.
Floating-point
constants
can
be
used
in two
ways:
1) SIMPLE NUMBER
2)
SCIENTIFIC NOTATION
Floating-point
constants
will
show you up to nine digits
on your
screen.
These
digits
can
represent
values
between
-999999999.
and
+999999999.
If
you
enter
more
than
nine
digits
the
number
will
be
rounded
based
on the
tenth
digit.
If the
tenth
digit
is greater
than
or
equal
to 5 the number
will
be rounded
upward.
Less than
5 the number
will
be rounded
downward.
This could
be important
to the final
totals
of
some
numbers
you
may
want
to work
with.
Floating-point
numbers
are
stored
(using
five
bytes
of
memory)
and
are
manipulated
in calculations
with
ten
places
of accuracy.
However,
BASIC PROGRAMMING RULES
5
Plik z chomika:
matizo80
Inne pliki z tego folderu:
c64-dreams-v0.45.zip
(26456068 KB)
GameBase64_V18_Full_Version.zip
(14639109 KB)
jak_zostac_niesmiertelnym_www_retroreaders_pl.djvu
(192 KB)
615-encyklopedia-commodore-64.pdf
(259 KB)
Black%20box%208.pdf
(588 KB)
Inne foldery tego chomika:
Pliki dostępne do 01.06.2025
Pliki dostępne do 19.01.2025
!Muzyka
!Seriale
BlackBerry
Zgłoś jeśli
naruszono regulamin