<s>
Commodore	B-Language
BASIC	I-Language
,	O
also	O
known	O
as	O
PET	B-Language
BASIC	I-Language
or	O
CBM-BASIC	O
,	O
is	O
the	O
dialect	O
of	O
the	O
BASIC	O
programming	O
language	O
used	O
in	O
Commodore	O
International	O
's	O
8-bit	O
home	O
computer	O
line	O
,	O
stretching	O
from	O
the	O
PET	B-Device
(	O
1977	O
)	O
to	O
the	O
Commodore	B-Device
128	I-Device
(	O
1985	O
)	O
.	O
</s>
<s>
The	O
core	O
is	O
based	O
on	O
6502	B-General_Concept
Microsoft	B-Language
BASIC	I-Language
,	O
and	O
as	O
such	O
it	O
shares	O
many	O
characteristics	O
with	O
other	O
6502	B-General_Concept
BASICs	O
of	O
the	O
time	O
,	O
such	O
as	O
Applesoft	B-Language
BASIC	I-Language
.	O
</s>
<s>
The	O
original	O
PET	B-Device
version	O
was	O
very	O
similar	O
to	O
the	O
original	O
Microsoft	O
implementation	O
with	O
few	O
modifications	O
.	O
</s>
<s>
BASIC	B-Language
2.0	I-Language
on	O
the	O
C64	O
was	O
also	O
similar	O
,	O
and	O
was	O
also	O
seen	O
on	O
C128s	O
(	O
in	O
C64	O
mode	O
)	O
and	O
other	O
models	O
.	O
</s>
<s>
Later	O
PETs	O
featured	O
BASIC	O
4.0	O
,	O
similar	O
to	O
the	O
original	O
but	O
adding	O
a	O
number	O
of	O
commands	O
for	O
working	O
with	O
floppy	B-Device
disks	I-Device
.	O
</s>
<s>
BASIC	O
3.5	O
was	O
the	O
first	O
to	O
really	O
deviate	O
,	O
adding	O
a	O
number	O
of	O
commands	O
for	O
graphics	O
and	O
sound	O
support	O
on	O
the	O
C16	O
and	O
Plus/4	B-Operating_System
.	O
</s>
<s>
BASIC	B-Language
7.0	I-Language
was	O
included	O
with	O
the	O
Commodore	B-Device
128	I-Device
,	O
and	O
included	O
structured	O
programming	O
commands	O
from	O
the	O
Plus/4	B-Operating_System
'	O
s	O
BASIC	O
3.5	O
,	O
as	O
well	O
as	O
keywords	O
designed	O
specifically	O
to	O
take	O
advantage	O
of	O
the	O
machine	O
's	O
new	O
capabilities	O
.	O
</s>
<s>
A	O
sprite	O
editor	O
and	O
machine	B-General_Concept
language	I-General_Concept
monitor	I-General_Concept
were	O
added	O
.	O
</s>
<s>
The	O
last	O
,	O
BASIC	O
10.0	O
,	O
was	O
part	O
of	O
the	O
unreleased	O
Commodore	B-Device
65	I-Device
.	O
</s>
<s>
It	O
was	O
not	O
until	O
the	O
Commodore	B-Device
128	I-Device
(	O
with	O
V7.0	O
)	O
that	O
a	O
Microsoft	O
copyright	O
notice	O
was	O
displayed	O
.	O
</s>
<s>
However	O
,	O
Microsoft	O
had	O
built	O
an	O
easter	O
egg	O
into	O
the	O
version	O
2	O
or	O
"	O
upgrade	O
"	O
Commodore	B-Language
Basic	I-Language
that	O
proved	O
its	O
provenance	O
:	O
typing	O
the	O
(	O
obscure	O
)	O
command	O
WAIT	O
6502	B-General_Concept
,	O
1	O
would	O
result	O
in	O
Microsoft	O
!	O
</s>
<s>
(	O
The	O
easter	O
egg	O
was	O
well-obfuscated	O
—	O
the	O
message	O
did	O
not	O
show	O
up	O
in	O
any	O
disassembly	O
of	O
the	O
interpreter	B-Application
.	O
)	O
</s>
<s>
The	O
popular	O
Commodore	O
64	O
came	O
with	O
BASIC	O
v2.0	O
in	O
ROM	B-Device
even	O
though	O
the	O
computer	O
was	O
released	O
after	O
the	O
PET/CBM	O
series	O
that	O
had	O
version	O
4.0	O
because	O
the	O
64	O
was	O
intended	O
as	O
a	O
home	O
computer	O
,	O
while	O
the	O
PET/CBM	O
series	O
were	O
targeted	O
at	O
business	O
and	O
educational	O
use	O
where	O
their	O
built-in	O
programming	O
language	O
was	O
presumed	O
to	O
be	O
more	O
heavily	O
used	O
.	O
</s>
<s>
A	O
convenient	O
feature	O
of	O
Commodore	O
's	O
ROM-resident	O
BASIC	B-Language
interpreter	I-Language
and	O
KERNAL	B-Operating_System
was	O
the	O
full-screen	B-Application
editor	I-Application
.	O
</s>
<s>
Although	O
Commodore	O
keyboards	O
only	O
have	O
two	O
cursor	B-Device
keys	I-Device
which	O
alternated	O
direction	O
when	O
the	O
shift	O
key	O
was	O
held	O
,	O
the	O
screen	O
editor	O
allowed	O
users	O
to	O
enter	O
direct	B-Application
commands	I-Application
or	O
to	O
input	O
and	O
edit	O
program	O
lines	O
from	O
anywhere	O
on	O
the	O
screen	O
.	O
</s>
<s>
If	O
a	O
line	O
was	O
prefixed	O
with	O
a	O
line	B-Application
number	I-Application
,	O
it	O
was	O
tokenized	O
and	O
stored	O
in	O
program	B-Device
memory	I-Device
.	O
</s>
<s>
Lines	O
not	O
beginning	O
with	O
a	O
number	O
were	O
executed	O
by	O
pressing	O
the	O
key	O
whenever	O
the	O
cursor	B-Application
happened	O
to	O
be	O
on	O
the	O
line	O
.	O
</s>
<s>
This	O
marked	O
a	O
significant	O
upgrade	O
in	O
program	O
entry	O
interfaces	O
compared	O
to	O
other	O
common	O
home	O
computer	O
BASICs	O
at	O
the	O
time	O
,	O
which	O
typically	O
used	O
line	B-Application
editors	I-Application
,	O
invoked	O
by	O
a	O
separate	O
EDIT	O
command	O
,	O
or	O
a	O
"	O
copy	O
cursor	B-Application
"	O
that	O
truncated	O
the	O
line	O
at	O
the	O
cursor	B-Application
's	O
position	O
.	O
</s>
<s>
It	O
also	O
had	O
the	O
capability	O
of	O
saving	O
named	O
files	O
to	O
any	O
device	O
,	O
including	O
the	O
cassette	B-Device
–	O
a	O
popular	O
storage	O
device	O
in	O
the	O
days	O
of	O
the	O
PET	B-Device
,	O
and	O
one	O
that	O
remained	O
in	O
use	O
throughout	O
the	O
lifespan	O
of	O
the	O
8-bit	O
Commodores	O
as	O
an	O
inexpensive	O
form	O
of	O
mass	O
storage	O
.	O
</s>
<s>
Most	O
systems	O
only	O
supported	O
filenames	O
on	O
diskette	B-Device
,	O
which	O
made	O
saving	O
multiple	O
files	O
on	O
other	O
devices	O
more	O
difficult	O
.	O
</s>
<s>
With	O
the	O
PET	B-Device
(	O
and	O
BASIC	B-Language
2.0	I-Language
)	O
,	O
files	O
from	O
cassettes	O
could	O
be	O
requested	O
by	O
name	O
.	O
</s>
<s>
The	O
file	O
system	O
was	O
also	O
supported	O
by	O
a	O
powerful	O
record	B-General_Concept
structure	I-General_Concept
that	O
could	O
be	O
loaded	O
or	O
saved	O
to	O
files	O
.	O
</s>
<s>
Commodore	O
cassette	B-Device
data	O
was	O
recorded	O
digitally	O
,	O
rather	O
than	O
less	O
expensive	O
(	O
and	O
less	O
reliable	O
)	O
analog	O
methods	O
used	O
by	O
other	O
manufacturers	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
specialized	O
Datasette	B-Device
was	O
required	O
rather	O
than	O
a	O
standard	O
tape	O
recorder	O
.	O
</s>
<s>
Adapters	O
were	O
available	O
that	O
used	O
an	O
analog-to-digital	O
converter	O
to	O
allow	O
use	O
of	O
a	O
standard	O
recorder	O
,	O
but	O
these	O
cost	O
only	O
a	O
little	O
less	O
than	O
the	O
Datasette	B-Device
.	O
</s>
<s>
Some	O
Commodore	B-Language
BASIC	I-Language
variants	O
supplied	O
BLOAD	B-Protocol
and	O
BSAVE	B-Protocol
commands	O
that	O
worked	O
like	O
their	O
counterparts	O
in	O
Applesoft	B-Language
BASIC	I-Language
,	O
loading	O
or	O
saving	O
bitmaps	O
from	O
specified	O
memory	O
locations	O
.	O
</s>
<s>
The	O
PET	B-Device
does	O
not	O
support	O
relocatable	O
programs	O
and	O
the	O
command	O
will	O
always	O
load	O
at	O
the	O
first	O
two	O
bytes	O
contained	O
in	O
the	O
program	O
file	O
.	O
</s>
<s>
This	O
created	O
a	O
problem	O
when	O
trying	O
to	O
load	O
BASIC	O
programs	O
saved	O
on	O
other	O
Commodore	O
machines	O
as	O
they	O
would	O
load	O
at	O
a	O
higher	O
address	O
than	O
where	O
the	O
PET	B-Device
's	O
BASIC	O
expected	O
the	O
program	O
to	O
be	O
,	O
there	O
were	O
workarounds	O
to	O
"	O
move	O
"	O
programs	O
to	O
the	O
proper	O
location	O
.	O
</s>
<s>
If	O
a	O
program	O
was	O
saved	O
on	O
a	O
CBM-II	B-Device
machine	O
,	O
the	O
only	O
way	O
to	O
load	O
it	O
on	O
a	O
PET	B-Device
was	O
by	O
modifying	O
the	O
first	O
two	O
bytes	O
with	O
a	O
disk	O
sector	O
editor	O
as	O
the	O
CBM-II	B-Device
series	O
had	O
their	O
BASIC	O
program	O
area	O
at	O
$0	O
,	O
which	O
would	O
result	O
in	O
a	O
PET	B-Device
attempting	O
to	O
load	O
into	O
the	O
zero	O
page	O
and	O
locking	O
up	O
.	O
</s>
<s>
Commodore	B-Language
BASIC	I-Language
keywords	O
could	O
be	O
abbreviated	O
by	O
entering	O
first	O
an	O
unshifted	O
keypress	O
,	O
and	O
then	O
a	O
shifted	O
keypress	O
of	O
the	O
next	O
letter	O
.	O
</s>
<s>
This	O
set	O
the	O
high	O
bit	O
,	O
causing	O
the	O
interpreter	B-Application
to	O
stop	O
reading	O
and	O
parse	O
the	O
statement	O
according	O
to	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
.	O
</s>
<s>
the	O
command	O
,	O
GOTO	B-Application
,	O
could	O
be	O
abbreviated	O
G{Shift-O}	O
(	O
which	O
resembled	O
GΓ	O
onscreen	O
)	O
.	O
</s>
<s>
In	O
cases	O
like	O
this	O
,	O
there	O
was	O
an	O
ambiguity	O
,	O
so	O
more	O
unshifted	O
letters	O
of	O
the	O
command	O
were	O
needed	O
,	O
such	O
as	O
GO{Shift-S}	O
(	O
GO	O
♥	O
)	O
being	O
required	O
for	O
GOSUB	B-Device
.	O
</s>
<s>
For	O
example	O
,	O
the	O
command	O
,	O
INPUT	O
had	O
no	O
abbreviation	O
because	O
its	O
spelling	O
collided	O
with	O
the	O
separate	O
INPUT#	O
keyword	O
,	O
which	O
was	O
located	O
nearer	O
to	O
the	O
beginning	O
of	O
the	O
keyword	O
lookup	B-Data_Structure
table	I-Data_Structure
.	O
</s>
<s>
shortcut	O
,	O
as	O
was	O
common	O
in	O
most	O
Microsoft	B-Language
BASIC	I-Language
dialects	O
.	O
</s>
<s>
Abbreviating	O
commands	O
with	O
shifted	O
letters	O
is	O
unique	O
to	O
Commodore	B-Language
BASIC	I-Language
.	O
</s>
<s>
This	O
tokenizing	O
method	O
had	O
a	O
glitch	O
such	O
that	O
if	O
one	O
included	O
a	O
REM	O
(	O
BASIC	O
statement	O
to	O
add	O
a	O
comment	O
to	O
the	O
code	O
)	O
followed	O
by	O
a	O
{Shift-L},	O
when	O
trying	O
to	O
view	O
the	O
program	O
listing	O
,	O
the	O
BASIC	B-Language
interpreter	I-Language
would	O
immediately	O
abort	O
the	O
listing	O
,	O
display	O
a	O
?	O
SYNTAX	O
ERROR	O
and	O
return	O
to	O
the	O
READY	O
.	O
</s>
<s>
By	O
abbreviating	O
keywords	O
,	O
it	O
was	O
possible	O
to	O
fit	O
more	O
code	O
on	O
a	O
single	O
program	O
line	O
(	O
which	O
could	O
take	O
up	O
two	O
screen	O
lines	O
on	O
40-column	O
displays	O
-	O
i.e.	O
,	O
C64	O
or	O
PET	B-Device
,	O
or	O
four	O
lines	O
on	O
the	O
VIC-20	B-Device
'	O
s	O
22-column	O
display	O
)	O
.	O
</s>
<s>
The	O
LIST	O
command	O
displayed	O
the	O
entire	O
command	O
keyword	O
-	O
extending	O
the	O
program	O
line	O
beyond	O
the	O
2	O
or	O
4	O
screen	O
lines	O
which	O
could	O
be	O
entered	O
into	O
program	B-Device
memory	I-Device
.	O
</s>
<s>
Like	O
the	O
original	O
Microsoft	B-Language
BASIC	I-Language
interpreter	B-Application
,	O
Commodore	B-Language
BASIC	I-Language
is	O
slower	O
than	O
native	O
machine	B-Language
code	I-Language
.	O
</s>
<s>
Test	O
results	O
have	O
shown	O
that	O
copying	O
16	O
kilobytes	O
from	O
ROM	B-Device
to	O
RAM	B-Architecture
takes	O
less	O
than	O
a	O
second	O
in	O
machine	B-Language
code	I-Language
,	O
compared	O
to	O
over	O
a	O
minute	O
in	O
BASIC	O
.	O
</s>
<s>
To	O
execute	O
faster	O
than	O
the	O
interpreter	B-Application
,	O
programmers	O
started	O
using	O
various	O
techniques	O
to	O
speed	O
up	O
execution	O
.	O
</s>
<s>
One	O
was	O
to	O
store	O
often-used	O
floating	B-Algorithm
point	I-Algorithm
values	I-Algorithm
in	O
variables	O
rather	O
than	O
using	O
literal	O
values	O
,	O
as	O
interpreting	O
a	O
variable	O
name	O
was	O
faster	O
than	O
interpreting	O
a	O
literal	O
number	O
.	O
</s>
<s>
Since	O
floating	B-Algorithm
point	I-Algorithm
is	O
default	O
type	O
for	O
all	O
commands	O
,	O
it	O
's	O
faster	O
to	O
use	O
floating	B-Algorithm
point	I-Algorithm
numbers	I-Algorithm
as	O
arguments	O
,	O
rather	O
than	O
integers	O
.	O
</s>
<s>
When	O
speed	O
was	O
important	O
,	O
some	O
programmers	O
converted	O
sections	O
of	O
BASIC	O
programs	O
to	O
6502	B-General_Concept
or	O
6510	B-General_Concept
assembly	O
language	O
that	O
was	O
loaded	O
separately	O
from	O
a	O
file	O
or	O
POKEd	O
into	O
memory	O
from	O
DATA	O
statements	O
at	O
the	O
end	O
of	O
the	O
BASIC	O
program	O
,	O
and	O
executed	O
from	O
BASIC	O
using	O
the	O
SYS	O
command	O
,	O
either	O
from	O
direct	B-Application
mode	I-Application
or	O
from	O
the	O
program	O
itself	O
.	O
</s>
<s>
When	O
the	O
execution	O
speed	O
of	O
machine	B-Language
language	I-Language
was	O
too	O
great	O
,	O
such	O
as	O
for	O
a	O
game	O
or	O
when	O
waiting	O
for	O
user	O
input	O
,	O
programmers	O
could	O
poll	B-General_Concept
by	O
reading	O
selected	O
memory	O
locations	O
(	O
such	O
as	O
for	O
the	O
64	O
,	O
or	O
for	O
the	O
128	O
,	O
denoting	O
size	O
of	O
the	O
keyboard	O
queue	O
)	O
to	O
delay	O
or	O
halt	O
execution	O
.	O
</s>
<s>
A	O
unique	O
feature	O
of	O
Commodore	B-Language
BASIC	I-Language
is	O
the	O
use	O
of	O
control	O
codes	O
to	O
perform	O
tasks	O
such	O
as	O
clearing	O
the	O
screen	O
or	O
positioning	O
the	O
cursor	B-Application
within	O
a	O
program	O
;	O
these	O
can	O
be	O
invoked	O
either	O
by	O
issuing	O
a	O
command	O
where	O
X	O
corresponds	O
to	O
the	O
control	O
code	O
to	O
be	O
issued	O
(	O
for	O
example	O
,	O
is	O
the	O
control	O
code	O
to	O
clear	O
the	O
screen	O
)	O
or	O
by	O
pressing	O
the	O
key	O
in	O
question	O
between	O
quote	O
marks	O
,	O
thus	O
pressing	O
following	O
a	O
quote	O
mark	O
will	O
cause	O
BASIC	O
to	O
display	O
the	O
visual	O
representation	O
of	O
the	O
control	O
code	O
(	O
in	O
this	O
case	O
,	O
a	O
reversed	O
heart	O
)	O
which	O
is	O
then	O
acted	O
upon	O
at	O
program	O
execution	O
(	O
directly	O
printing	O
out	O
the	O
control	O
codes	O
uses	O
less	O
memory	O
and	O
executes	O
faster	O
than	O
invoking	O
a	O
function	O
)	O
.	O
</s>
<s>
This	O
is	O
in	O
comparison	O
to	O
other	O
implementations	O
of	O
BASIC	O
which	O
typically	O
have	O
dedicated	O
commands	O
to	O
clear	O
the	O
screen	O
or	O
move	O
the	O
cursor	B-Application
.	O
</s>
<s>
BASIC	O
3.5	O
and	O
up	O
have	O
proper	O
commands	O
for	O
clearing	O
the	O
screen	O
and	O
moving	O
the	O
cursor	B-Application
.	O
</s>
<s>
Program	O
lines	O
in	O
Commodore	B-Language
BASIC	I-Language
do	O
not	O
require	O
spaces	O
anywhere	O
(	O
but	O
the	O
command	O
will	O
always	O
display	O
one	O
between	O
the	O
line	B-Application
number	I-Application
and	O
the	O
statement	O
)	O
,	O
e.g.	O
,	O
,	O
and	O
it	O
was	O
common	O
to	O
write	O
programs	O
with	O
no	O
spacing	O
.	O
</s>
<s>
Spaces	O
between	O
the	O
line	B-Application
number	I-Application
and	O
program	O
statement	O
are	O
removed	O
by	O
the	O
tokenizer	O
.	O
</s>
<s>
Program	O
lines	O
can	O
be	O
80	O
characters	O
total	O
on	O
most	O
machines	O
,	O
but	O
machines	O
with	O
40	O
column	O
text	O
would	O
cause	O
the	O
line	O
to	O
wrap	O
around	O
to	O
the	O
next	O
line	O
on	O
the	O
screen	O
,	O
and	O
on	O
the	O
VIC-20	B-Device
,	O
which	O
had	O
a	O
22	O
column	O
display	O
,	O
program	O
lines	O
could	O
occupy	O
as	O
many	O
as	O
four	O
.	O
</s>
<s>
BASIC	B-Language
7.0	I-Language
on	O
the	O
Commodore	B-Device
128	I-Device
increased	O
the	O
limit	O
of	O
a	O
program	O
line	O
to	O
160	O
characters	O
(	O
four	O
40-column	O
lines	O
or	O
two	O
80-column	O
lines	O
)	O
.	O
</s>
<s>
BASIC	B-Language
7.0	I-Language
displays	O
a	O
error	O
if	O
the	O
user	O
enters	O
a	O
program	O
line	O
over	O
160	O
characters	O
in	O
length	O
.	O
</s>
<s>
The	O
line	B-Application
number	I-Application
is	O
counted	O
in	O
the	O
number	O
of	O
characters	O
in	O
the	O
program	O
line	O
,	O
so	O
a	O
five	O
digit	O
line	B-Application
number	I-Application
will	O
result	O
in	O
four	O
fewer	O
characters	O
allowed	O
than	O
a	O
one	O
digit	O
number	O
.	O
</s>
<s>
The	O
order	O
of	O
execution	O
of	O
Commodore	B-Language
BASIC	I-Language
lines	O
was	O
not	O
determined	O
by	O
line	B-Application
numbering	I-Application
;	O
instead	O
,	O
it	O
followed	O
the	O
order	O
in	O
which	O
the	O
lines	O
were	O
linked	O
in	O
memory	O
.	O
</s>
<s>
Program	O
lines	O
were	O
stored	O
in	O
memory	O
as	O
a	O
singly	O
linked	O
list	O
with	O
a	O
pointer	O
(	O
containing	O
the	O
address	O
of	O
the	O
beginning	O
of	O
the	O
next	O
program	O
line	O
)	O
,	O
a	O
line	B-Application
number	I-Application
,	O
and	O
then	O
the	O
tokenized	O
code	O
for	O
the	O
line	O
.	O
</s>
<s>
While	O
a	O
program	O
was	O
being	O
entered	O
,	O
BASIC	O
would	O
constantly	O
reorder	O
program	O
lines	O
in	O
memory	O
so	O
that	O
the	O
line	B-Application
numbers	I-Application
and	O
pointers	O
were	O
all	O
in	O
ascending	O
order	O
.	O
</s>
<s>
However	O
,	O
after	O
a	O
program	O
was	O
entered	O
,	O
manually	O
altering	O
the	O
line	B-Application
numbers	I-Application
and	O
pointers	O
with	O
the	O
POKE	B-Language
commands	O
could	O
allow	O
for	O
out-of-order	O
execution	O
or	O
even	O
give	O
each	O
line	O
the	O
same	O
line	B-Application
number	I-Application
.	O
</s>
<s>
In	O
the	O
early	O
days	O
,	O
when	O
BASIC	O
was	O
used	O
commercially	O
,	O
this	O
was	O
a	O
software	B-Application
protection	I-Application
technique	O
to	O
discourage	O
casual	O
modification	O
of	O
the	O
program	O
.	O
</s>
<s>
Line	B-Application
numbers	I-Application
can	O
range	O
from	O
0	O
to	O
65520	O
and	O
take	O
five	O
bytes	O
to	O
store	O
regardless	O
of	O
how	O
many	O
digits	O
are	O
in	O
the	O
line	B-Application
number	I-Application
,	O
although	O
execution	O
is	O
faster	O
the	O
fewer	O
digits	O
there	O
are	O
.	O
</s>
<s>
and	O
statements	O
will	O
search	O
downward	O
from	O
the	O
current	O
line	O
to	O
find	O
a	O
line	B-Application
number	I-Application
if	O
a	O
forward	O
jump	O
is	O
performed	O
,	O
in	O
case	O
of	O
a	O
backwards	O
jump	O
,	O
they	O
will	O
return	O
to	O
the	O
start	O
of	O
the	O
program	O
to	O
begin	O
searching	O
.	O
</s>
<s>
Commodore	B-Language
BASIC	I-Language
also	O
supports	O
bitwise	O
operators	O
,	O
and	O
,	O
although	O
this	O
feature	O
was	O
part	O
of	O
the	O
core	O
Microsoft	O
6502	B-General_Concept
BASIC	O
code	O
,	O
it	O
was	O
usually	O
omitted	O
in	O
other	O
implementations	O
such	O
as	O
Applesoft	B-Language
BASIC	I-Language
.	O
</s>
<s>
The	O
native	O
number	O
format	O
of	O
Commodore	B-Language
BASIC	I-Language
,	O
like	O
that	O
of	O
its	O
parent	O
MS	B-Language
BASIC	I-Language
,	O
was	O
floating	B-Algorithm
point	I-Algorithm
.	O
</s>
<s>
Most	O
contemporary	O
BASIC	O
implementations	O
used	O
one	O
byte	O
for	O
the	O
characteristic	O
(	O
exponent	O
)	O
and	O
three	O
bytes	O
for	O
the	O
mantissa	B-Algorithm
.	O
</s>
<s>
The	O
accuracy	O
of	O
a	O
floating	B-Algorithm
point	I-Algorithm
number	I-Algorithm
using	O
a	O
three-byte	O
mantissa	B-Algorithm
is	O
only	O
about	O
6.5	O
decimal	B-Application
digits	O
,	O
and	O
round-off	B-Algorithm
error	I-Algorithm
is	O
common	O
.	O
</s>
<s>
6502	B-General_Concept
implementations	O
of	O
Microsoft	B-Language
BASIC	I-Language
utilized	O
40-bit	O
floating	B-Algorithm
point	I-Algorithm
arithmetic	I-Algorithm
,	O
meaning	O
that	O
variables	O
took	O
five	O
bytes	O
to	O
store	O
(	O
four	O
byte	O
mantissa	B-Algorithm
and	O
one	O
byte	O
for	O
the	O
exponent	O
)	O
unlike	O
the	O
32-bit	O
floating	B-Algorithm
point	I-Algorithm
found	O
in	O
BASIC-80	B-Language
.	O
</s>
<s>
While	O
8080/Z80	O
implementations	O
of	O
Microsoft	B-Language
BASIC	I-Language
supported	O
integer	O
and	O
double	O
precision	O
variables	O
,	O
6502	B-General_Concept
implementations	O
were	O
floating	B-Algorithm
point	I-Algorithm
only	O
.	O
</s>
<s>
Although	O
Commodore	B-Language
BASIC	I-Language
supports	O
signed	B-Algorithm
integer	I-Algorithm
variables	O
(	O
denoted	O
with	O
a	O
percent	O
sign	O
)	O
in	O
the	O
range	O
-32768	O
to	O
32767	O
,	O
in	O
practice	O
they	O
are	O
only	O
used	O
for	O
array	O
variables	O
and	O
serve	O
the	O
function	O
of	O
conserving	O
memory	O
by	O
limiting	O
array	O
elements	O
to	O
two	O
bytes	O
each	O
(	O
an	O
array	O
of	O
2000	O
elements	O
will	O
occupy	O
10,000	O
bytes	O
if	O
declared	O
as	O
a	O
floating	B-Algorithm
point	I-Algorithm
array	O
,	O
but	O
only	O
4000	O
if	O
declared	O
as	O
an	O
integer	O
array	O
)	O
.	O
</s>
<s>
Denoting	O
any	O
variable	O
as	O
integer	O
simply	O
causes	O
BASIC	O
to	O
convert	O
it	O
back	O
to	O
floating	B-Algorithm
point	I-Algorithm
,	O
slowing	O
down	O
program	O
execution	O
and	O
wasting	O
memory	O
as	O
each	O
percent	O
sign	O
takes	O
one	O
additional	O
byte	O
to	O
store	O
(	O
since	O
this	O
also	O
applies	O
to	O
integer	O
arrays	O
,	O
the	O
programmer	O
should	O
avoid	O
using	O
them	O
unless	O
very	O
large	O
arrays	O
are	O
used	O
that	O
would	O
exceed	O
available	O
memory	O
if	O
stored	O
as	O
floating	B-Algorithm
point	I-Algorithm
)	O
.	O
</s>
<s>
Also	O
,	O
it	O
is	O
not	O
possible	O
to	O
or	O
memory	O
locations	O
above	O
32767	O
with	O
address	O
defined	O
as	O
a	O
signed	B-Algorithm
integer	I-Algorithm
.	O
</s>
<s>
The	O
statement	O
,	O
used	O
to	O
start	O
machine	B-Language
language	I-Language
programs	O
,	O
was	O
added	O
by	O
Commodore	O
and	O
was	O
not	O
in	O
the	O
original	O
Microsoft	B-Language
BASIC	I-Language
code	O
,	O
which	O
featured	O
only	O
the	O
USR	O
function	O
for	O
invoking	O
machine	B-Language
language	I-Language
routines	O
.	O
</s>
<s>
It	O
automatically	O
loads	O
the	O
CPU	O
's	O
registers	O
with	O
the	O
values	O
in	O
(	O
C64	O
,	O
varies	O
on	O
other	O
machines	O
)	O
--this	O
can	O
be	O
used	O
to	O
pass	O
data	O
to	O
machine	B-Language
language	I-Language
routines	O
or	O
as	O
a	O
means	O
of	O
calling	O
kernal	B-Operating_System
functions	O
from	O
BASIC	O
(	O
as	O
an	O
example	O
,	O
clears	O
the	O
screen	O
)	O
.	O
</s>
<s>
Since	O
Commodore	O
8-bit	O
machines	O
other	O
than	O
the	O
C128	B-Device
cannot	O
automatically	O
boot	O
disk	O
software	O
,	O
the	O
usual	O
technique	O
is	O
to	O
include	O
a	O
BASIC	O
stub	O
like	O
to	O
begin	O
program	O
execution	O
.	O
</s>
<s>
As	O
with	O
most	O
other	O
versions	O
of	O
Microsoft	B-Language
BASIC	I-Language
,	O
if	O
an	O
array	O
is	O
not	O
declared	O
with	O
a	O
statement	O
,	O
it	O
is	O
automatically	O
set	O
to	O
ten	O
elements	O
(	O
in	O
practice	O
11	O
since	O
array	O
elements	O
are	O
counted	O
from	O
0	O
)	O
.	O
</s>
<s>
Numeric	B-Algorithm
arrays	O
are	O
automatically	O
filled	O
with	O
zeros	O
when	O
they	O
are	O
created	O
,	O
there	O
may	O
be	O
a	O
momentary	O
delay	O
in	O
program	O
execution	O
if	O
a	O
large	O
array	O
is	O
dimensioned	O
.	O
</s>
<s>
Unlike	O
some	O
other	O
implementations	O
of	O
Microsoft	B-Language
BASIC	I-Language
,	O
Commodore	B-Language
BASIC	I-Language
does	O
not	O
require	O
string	O
space	O
to	O
be	O
reserved	O
at	O
the	O
start	O
of	O
a	O
program	O
.	O
</s>
<s>
The	O
clock	O
is	O
not	O
a	O
very	O
reliable	O
method	O
of	O
timekeeping	O
since	O
it	O
stops	O
whenever	O
interrupts	O
are	O
turned	O
off	O
(	O
done	O
by	O
some	O
kernal	B-Operating_System
routines	O
)	O
and	O
accessing	O
the	O
IEC	O
(	O
or	O
IEEE	O
port	O
on	O
the	O
PET	B-Device
)	O
port	O
will	O
slow	O
the	O
clock	O
update	O
by	O
a	O
few	O
ticks	O
.	O
</s>
<s>
The	O
function	O
in	O
Commodore	B-Language
BASIC	I-Language
can	O
use	O
the	O
clock	O
to	O
generate	O
random	O
numbers	O
;	O
this	O
is	O
accomplished	O
by	O
,	O
however	O
it	O
is	O
of	O
relatively	O
limited	O
use	O
as	O
only	O
numbers	O
between	O
0	O
and	O
255	O
are	O
returned	O
.	O
</s>
<s>
Otherwise	O
,	O
works	O
the	O
same	O
as	O
other	O
implementations	O
of	O
Microsoft	B-Language
BASIC	I-Language
in	O
that	O
a	O
pseudo-random	O
sequence	O
is	O
used	O
via	O
a	O
fixed	O
5-byte	O
seed	O
value	O
stored	O
at	O
power	O
on	O
in	O
memory	O
locations	O
on	O
the	O
C64	O
(	O
the	O
location	O
differs	O
on	O
other	O
machines	O
)	O
.	O
</s>
<s>
Since	O
true	O
random	O
number	O
generation	O
is	O
impossible	O
with	O
the	O
statement	O
,	O
it	O
is	O
more	O
typical	O
on	O
the	O
C64	O
and	O
C128	B-Device
to	O
utilize	O
the	O
SID	O
chip	O
's	O
white	O
noise	O
channel	O
for	O
random	O
numbers	O
.	O
</s>
<s>
BASIC	B-Language
2.0	I-Language
notoriously	O
suffered	O
from	O
extremely	O
slow	O
garbage	O
collection	O
of	O
strings	O
.	O
</s>
<s>
BASIC	O
4.0	O
introduced	O
an	O
improved	O
garbage	O
collection	O
system	O
with	O
back	O
pointers	O
and	O
all	O
later	O
implementations	O
of	O
Commodore	B-Language
BASIC	I-Language
also	O
have	O
it	O
.	O
</s>
<s>
The	O
function	O
in	O
BASIC	B-Language
2.0	I-Language
suffered	O
from	O
another	O
technical	O
flaw	O
in	O
that	O
it	O
cannot	O
handle	O
signed	O
numbers	O
over	O
32768	O
,	O
thus	O
if	O
the	O
function	O
is	O
invoked	O
on	O
a	O
C64	O
(	O
38k	O
BASIC	O
memory	O
)	O
,	O
a	O
negative	O
amount	O
of	O
free	O
BASIC	O
memory	O
will	O
be	O
displayed	O
(	O
adding	O
65535	O
to	O
the	O
reported	O
number	O
will	O
obtain	O
the	O
correct	O
amount	O
of	O
free	O
memory	O
)	O
.	O
</s>
<s>
The	O
PET	B-Device
and	O
VIC-20	B-Device
never	O
had	O
more	O
than	O
32k	O
of	O
total	O
memory	O
available	O
to	O
BASIC	O
,	O
so	O
this	O
limitation	O
did	O
not	O
become	O
apparent	O
until	O
the	O
C64	O
was	O
developed	O
.	O
</s>
<s>
The	O
function	O
on	O
BASIC	O
3.5	O
and	O
7.0	O
corrected	O
this	O
problem	O
and	O
on	O
BASIC	B-Language
7.0	I-Language
was	O
also	O
"	O
split	O
"	O
into	O
two	O
functions	O
,	O
one	O
to	O
display	O
free	O
BASIC	O
program	O
text	O
memory	O
and	O
the	O
other	O
to	O
display	O
free	O
variable	O
memory	O
.	O
</s>
<s>
Many	O
BASIC	O
extensions	O
were	O
released	O
for	O
the	O
Commodore	O
64	O
,	O
due	O
to	O
the	O
relatively	O
limited	O
capabilities	O
of	O
its	O
native	O
BASIC	B-Language
2.0	I-Language
.	O
</s>
<s>
One	O
of	O
the	O
most	O
popular	O
extensions	O
was	O
the	O
DOS	B-Operating_System
Wedge	I-Operating_System
,	O
which	O
was	O
included	O
on	O
the	O
Commodore	O
1541	O
Test/Demo	O
Disk	O
.	O
</s>
<s>
Its	O
features	O
were	O
subsequently	O
incorporated	O
in	O
various	O
third-party	O
extensions	O
,	O
such	O
as	O
the	O
popular	O
Epyx	B-Application
FastLoad	I-Application
cartridge	B-Protocol
.	O
</s>
<s>
Other	O
BASIC	O
extensions	O
added	O
additional	O
keywords	O
to	O
make	O
it	O
easier	O
to	O
code	O
sprites	O
,	O
sound	O
,	O
and	O
high-resolution	O
graphics	O
like	O
Simons	B-Language
 '	I-Language
BASIC	I-Language
(	O
1983	O
)	O
and	O
Vision	O
BASIC	O
(	O
2022	O
)	O
.	O
</s>
<s>
Although	O
BASIC	B-Language
2.0	I-Language
'	O
s	O
lack	O
of	O
sound	O
or	O
graphics	O
features	O
was	O
frustrating	O
to	O
many	O
users	O
,	O
some	O
critics	O
argued	O
that	O
it	O
was	O
ultimately	O
beneficial	O
since	O
it	O
forced	O
the	O
user	O
to	O
learn	O
machine	B-Language
language	I-Language
.	O
</s>
<s>
The	O
limitations	O
of	O
BASIC	B-Language
2.0	I-Language
on	O
the	O
C64	O
led	O
to	O
use	O
of	O
built-in	O
ROM	B-Device
machine	B-Language
language	I-Language
from	O
BASIC	O
.	O
</s>
<s>
From	O
a	O
modern	O
programming	O
point	O
of	O
view	O
,	O
the	O
earlier	O
versions	O
of	O
Commodore	B-Language
BASIC	I-Language
presented	O
a	O
host	O
of	O
bad	O
programming	O
traps	O
for	O
the	O
programmer	O
.	O
</s>
<s>
As	O
most	O
of	O
these	O
issues	O
derived	O
from	O
Microsoft	B-Language
BASIC	I-Language
,	O
virtually	O
every	O
home	O
computer	O
BASIC	O
of	O
the	O
era	O
suffered	O
from	O
similar	O
deficiencies	O
.	O
</s>
<s>
Every	O
line	O
of	O
a	O
Microsoft	B-Language
BASIC	I-Language
program	O
was	O
assigned	O
a	O
line	B-Application
number	I-Application
by	O
the	O
programmer	O
.	O
</s>
<s>
A	O
common	O
technique	O
was	O
to	O
start	O
a	O
program	O
at	O
some	O
low	O
line	B-Application
number	I-Application
with	O
an	O
jump	O
table	O
,	O
with	O
the	O
body	O
of	O
the	O
program	O
structured	O
into	O
sections	O
starting	O
at	O
a	O
designated	O
line	B-Application
number	I-Application
like	O
1000	O
,	O
2000	O
,	O
and	O
so	O
on	O
.	O
</s>
<s>
If	O
a	O
large	O
section	O
needed	O
to	O
be	O
added	O
,	O
it	O
could	O
just	O
be	O
assigned	O
the	O
next	O
available	O
major	O
line	B-Application
number	I-Application
and	O
inserted	O
to	O
the	O
jump	O
table	O
.	O
</s>
<s>
Later	O
BASIC	O
versions	O
on	O
Commodore	O
and	O
other	O
platforms	O
included	O
a	O
and	O
command	O
,	O
as	O
well	O
as	O
an	O
AUTO	O
line	B-Application
numbering	I-Application
command	O
that	O
would	O
automatically	O
select	O
and	O
insert	O
line	B-Application
numbers	I-Application
according	O
to	O
a	O
selected	O
increment	O
.	O
</s>
<s>
Earlier	O
BASICs	O
from	O
Commodore	O
also	O
lack	O
debugging	O
commands	O
,	O
meaning	O
that	O
bugs	B-Application
and	O
unused	O
variables	O
are	O
hard	O
to	O
trap	O
.	O
</s>
<s>
structures	O
,	O
a	O
standard	O
part	O
of	O
Z80	O
Microsoft	B-Language
BASICs	I-Language
,	O
were	O
added	O
to	O
BASIC	O
3.5	O
after	O
being	O
unavailable	O
in	O
earlier	O
versions	O
of	O
Commodore	B-Language
BASIC	I-Language
.	O
</s>
<s>
In	O
common	O
with	O
other	O
home	O
computers	O
,	O
Commodore	O
's	O
machines	O
booted	O
directly	O
into	O
the	O
BASIC	B-Language
interpreter	I-Language
.	O
</s>
<s>
BASIC	O
's	O
file	O
and	O
programming	O
commands	O
could	O
be	O
entered	O
in	O
direct	B-Application
mode	I-Application
to	O
load	O
and	O
execute	O
software	O
.	O
</s>
<s>
If	O
program	O
execution	O
was	O
halted	O
using	O
the	O
RUN/STOP	O
key	O
,	O
variable	O
values	O
would	O
be	O
preserved	O
in	O
RAM	B-Architecture
and	O
could	O
be	O
PRINTed	O
for	O
debugging	O
.	O
</s>
<s>
This	O
,	O
along	O
with	O
the	O
advanced	O
screen	O
editor	O
included	O
with	O
Commodore	B-Language
BASIC	I-Language
gave	O
the	O
programming	O
environment	O
a	O
REPL-like	O
feel	O
;	O
programmers	O
could	O
insert	O
and	O
edit	O
program	O
lines	O
at	O
any	O
screen	O
location	O
,	O
interactively	O
building	O
the	O
program	O
.	O
</s>
<s>
This	O
is	O
in	O
contrast	O
to	O
business-oriented	O
operating	O
systems	O
of	O
the	O
time	O
like	O
CP/M	B-Application
or	O
MS-DOS	B-Application
,	O
which	O
typically	O
booted	O
into	O
a	O
command	B-Application
line	I-Application
interface	I-Application
.	O
</s>
<s>
While	O
some	O
versions	O
of	O
Commodore	B-Language
BASIC	I-Language
included	O
disk-specific	O
DLOAD	O
and	O
DSAVE	O
commands	O
,	O
the	O
version	O
built	O
into	O
the	O
Commodore	O
64	O
lacked	O
these	O
,	O
requiring	O
the	O
user	O
to	O
specify	O
the	O
disk	O
drive	O
's	O
device	O
number	O
(	O
typically	O
8	O
or	O
9	O
)	O
to	O
the	O
standard	O
LOAD	O
command	O
,	O
which	O
otherwise	O
defaulted	O
to	O
tape	O
.	O
</s>
<s>
Another	O
omission	O
from	O
the	O
Commodore	O
64s	O
BASIC	B-Language
2.0	I-Language
was	O
a	O
DIRECTORY	O
command	O
to	O
display	O
a	O
disk	O
's	O
contents	O
without	O
clearing	O
main	O
memory	O
.	O
</s>
<s>
On	O
the	O
64	O
,	O
viewing	O
files	O
on	O
a	O
disk	O
was	O
implemented	O
as	O
loading	O
a	O
"	O
program	O
"	O
which	O
when	O
listed	O
showed	O
the	O
directory	O
as	O
a	O
pseudo	O
BASIC	O
program	O
,	O
with	O
the	O
file	O
's	O
block	O
size	O
as	O
the	O
line	B-Application
number	I-Application
.	O
</s>
<s>
Addons	O
like	O
the	O
DOS	B-Operating_System
Wedge	I-Operating_System
overcame	O
this	O
by	O
rendering	O
the	O
directory	O
listing	O
direct	O
to	O
screen	O
memory	O
.	O
</s>
<s>
A	O
list	O
of	O
CBM	B-Language
BASIC	I-Language
versions	O
in	O
chronological	O
order	O
,	O
with	O
successively	O
added	O
features	O
:	O
</s>
<s>
disk	B-Device
operations	I-Device
:	O
DLOAD	O
,	O
DSAVE	O
,	O
COPY	O
,	O
SCRATCH	O
,	O
etc	O
.	O
</s>
<s>
used	O
the	O
128	O
's	O
bank	B-General_Concept
switching	I-General_Concept
to	O
store	O
program	O
code	O
separately	O
from	O
variables	O
.	O
</s>
<s>
Variable	O
values	O
would	O
be	O
preserved	O
across	O
program	O
executions	O
if	O
the	O
program	O
was	O
started	O
with	O
the	O
GOTO	B-Application
command	O
.	O
</s>
<s>
V3.6	O
:	O
Commodore	B-Device
LCD	I-Device
(	O
unreleased	O
prototype	O
)	O
.	O
</s>
