<s>
The	O
COSMAC	O
(	O
Complementary	O
Symmetry	O
Monolithic	O
Array	O
Computer	O
)	O
is	O
an	O
8-bit	O
microprocessor	B-Architecture
family	O
introduced	O
by	O
RCA	O
.	O
</s>
<s>
It	O
is	O
historically	O
notable	O
as	O
the	O
first	O
CMOS	B-Device
microprocessor	B-Architecture
.	O
</s>
<s>
The	O
first	O
production	O
model	O
was	O
the	O
two-chip	O
CDP1801R	O
and	O
CDP1801U	O
,	O
which	O
were	O
later	O
combined	O
into	O
the	O
single-chip	O
CDP1802	B-General_Concept
.	O
</s>
<s>
The	O
1802	O
represented	O
the	O
majority	O
of	O
COSMAC	O
production	O
,	O
and	O
today	O
the	O
entire	O
line	O
is	O
known	O
simply	O
as	O
the	O
RCA	B-General_Concept
1802	I-General_Concept
.	O
</s>
<s>
The	O
processor	O
design	O
traces	O
its	O
history	O
to	O
an	O
experimental	O
home	O
computer	O
designed	O
by	O
Joseph	O
Weisbecker	O
in	O
the	O
early	O
1970s	O
,	O
built	O
at	O
his	O
home	O
using	O
TTL	B-General_Concept
components	O
.	O
</s>
<s>
RCA	O
began	O
development	O
of	O
the	O
CMOS	B-Device
version	O
of	O
the	O
processor	O
design	O
in	O
1973	O
,	O
sampling	O
it	O
in	O
1974	O
with	O
plans	O
to	O
move	O
to	O
a	O
single-chip	O
implementation	O
immediately	O
.	O
</s>
<s>
In	O
contrast	O
to	O
most	O
designs	O
of	O
the	O
era	O
,	O
which	O
were	O
fabricated	O
using	O
the	O
NMOS	O
process	O
,	O
the	O
COSMAC	O
was	O
implemented	O
in	O
CMOS	B-Device
form	O
and	O
used	O
static	B-General_Concept
logic	I-General_Concept
.	O
</s>
<s>
RCA	O
referred	O
to	O
its	O
CMOS	B-Device
process	O
as	O
"	O
complementary	O
silicon/metal	O
-oxide	O
semiconductor	O
"	O
,	O
giving	O
rise	O
to	O
the	O
acronym	O
COS/MAC	O
,	O
which	O
was	O
then	O
backronymed	O
to	O
"	O
complementary-symmetry	O
monolithic-array	O
computer	O
"	O
when	O
referring	O
to	O
the	O
processor	O
.	O
</s>
<s>
RCA	O
also	O
produced	O
radiation	O
hardened	O
versions	O
using	O
a	O
silicon	B-Algorithm
on	I-Algorithm
sapphire	I-Algorithm
process	O
,	O
which	O
found	O
use	O
in	O
the	O
aerospace	O
field	O
.	O
</s>
<s>
Successors	O
to	O
the	O
1802	O
are	O
the	O
CDP1804	O
,	O
CDP1805	O
,	O
and	O
CDP1806	O
,	O
which	O
have	O
an	O
extended	O
instruction	B-General_Concept
set	I-General_Concept
,	O
other	O
enhanced	O
features	O
(	O
like	O
on-chip	O
RAM	O
and	O
ROM	B-Device
,	O
and	O
built-in	O
timer	O
)	O
,	O
with	O
some	O
versions	O
running	O
at	O
faster	O
clock	O
speeds	O
,	O
though	O
not	O
a	O
significant	O
speed	O
difference	O
.	O
</s>
<s>
Some	O
features	O
are	O
also	O
lost	O
,	O
like	O
the	O
DMA	B-General_Concept
auto-boot	O
loader	O
functionality	O
.	O
</s>
<s>
There	O
are	O
also	O
some	O
minor	O
pin	O
function	O
changes	O
,	O
but	O
the	O
line	O
continues	O
to	O
be	O
produced	O
in	O
its	O
original	O
40-pin	O
dual	B-Algorithm
in-line	I-Algorithm
package	I-Algorithm
(	O
DIP	B-Algorithm
)	O
format	O
.	O
</s>
<s>
The	O
technology	O
of	O
the	O
era	O
made	O
small	O
embedded	B-Architecture
computers	I-Architecture
impossible	O
,	O
but	O
the	O
introduction	O
of	O
the	O
integrated	O
circuit	O
(	O
IC	O
)	O
in	O
the	O
1960s	O
changed	O
things	O
dramatically	O
.	O
</s>
<s>
Beginning	O
in	O
1970	O
,	O
Weisbecker	O
began	O
the	O
design	O
of	O
a	O
small	O
machine	O
using	O
RCA	O
transistor-transistor	B-General_Concept
logic	I-General_Concept
(	O
TTL	B-General_Concept
)	O
ICs	O
to	O
construct	O
the	O
processor	O
.	O
</s>
<s>
The	O
result	O
,	O
which	O
he	O
called	O
FRED	O
,	O
ostensibly	O
for	O
Flexible	B-General_Concept
Recreational	I-General_Concept
Educational	I-General_Concept
Device	I-General_Concept
,	O
was	O
packaged	O
into	O
a	O
box	O
that	O
was	O
not	O
unlike	O
the	O
Altair	B-Architecture
8800	I-Architecture
of	O
a	O
few	O
years	O
later	O
,	O
with	O
toggle	O
switches	O
on	O
the	O
front	O
panel	O
for	O
input	O
,	O
lamps	O
for	O
output	O
,	O
and	O
later	O
adding	O
a	O
hex	B-Device
pad	I-Device
keyboard	O
.	O
</s>
<s>
Weisbecker	O
added	O
new	O
features	O
continually	O
and	O
by	O
1972	O
it	O
had	O
gained	O
a	O
character	O
generator	O
and	O
the	O
ability	O
to	O
load	O
and	O
save	O
programs	O
on	O
cassette	B-Device
tapes	I-Device
.	O
</s>
<s>
When	O
RCA	O
entered	O
the	O
game	O
console	O
business	O
in	O
the	O
later	O
1970s	O
,	O
these	O
games	O
were	O
burned	O
to	O
ROM	B-Protocol
cartridge	I-Protocol
form	O
,	O
and	O
Joyce	O
became	O
the	O
first	O
known	O
female	O
commercial	O
videogame	O
developer	O
.	O
</s>
<s>
This	O
was	O
shortly	O
after	O
David	O
Sarnoff	O
had	O
retired	O
and	O
handed	O
the	O
CEO	B-Application
role	O
to	O
his	O
son	O
,	O
Robert	O
Sarnoff	O
.	O
</s>
<s>
Some	O
of	O
the	O
skepticism	O
displayed	O
by	O
management	O
may	O
have	O
had	O
to	O
do	O
with	O
the	O
company	O
's	O
recent	O
sale	O
of	O
their	O
mainframe	B-Architecture
computer	I-Architecture
business	O
to	O
Sperry	O
Rand	O
with	O
a	O
huge	O
writedown	O
.	O
</s>
<s>
A	O
1973	O
lab	O
report	O
refers	O
to	O
a	O
"	O
prototype	O
"	O
being	O
delivered	O
in	O
1972	O
,	O
but	O
this	O
is	O
likely	O
referring	O
to	O
the	O
original	O
TTL	B-General_Concept
implementation	O
.	O
</s>
<s>
It	O
goes	O
on	O
to	O
state	O
that	O
another	O
lab	O
will	O
be	O
producing	O
the	O
system	O
in	O
an	O
8-chip	O
silicon-on-sapphire	B-Algorithm
format	O
,	O
although	O
the	O
date	O
is	O
simply	O
"	O
soon	O
after	O
"	O
the	O
CMOS	B-Device
versions	O
,	O
and	O
that	O
plans	O
for	O
a	O
single-chip	O
version	O
were	O
already	O
being	O
planned	O
.	O
</s>
<s>
Meanwhile	O
,	O
Weisbecker	O
had	O
adapted	O
the	O
original	O
FRED	O
,	O
known	O
within	O
RCA	O
as	O
System	O
00	O
by	O
this	O
time	O
,	O
using	O
the	O
new	O
chipset	O
to	O
produce	O
a	O
greatly	O
simplified	O
single-board	O
system	O
known	O
as	O
then	O
COSMAC	B-Device
ELF	I-Device
.	O
</s>
<s>
A	O
unique	O
feature	O
of	O
the	O
ELF	O
is	O
that	O
it	O
did	O
not	O
require	O
any	O
read	B-Device
only	I-Device
memory	I-Device
(	O
ROM	B-Device
)	O
for	O
startup	O
,	O
instead	O
,	O
the	O
processor	O
's	O
direct	B-General_Concept
memory	I-General_Concept
access	I-General_Concept
(	O
DMA	B-General_Concept
)	O
system	O
was	O
used	O
to	O
read	O
front-panel	O
switches	O
directly	O
into	O
memory	O
.	O
</s>
<s>
After	O
a	O
year	O
of	O
discussion	O
,	O
the	O
company	O
eventually	O
decided	O
to	O
release	O
two	O
mass-market	O
products	O
based	O
on	O
the	O
platform	O
,	O
a	O
kit	O
computer	O
known	O
as	O
the	O
COSMAC	B-Device
VIP	I-Device
,	O
and	O
a	O
game	O
console	O
known	O
as	O
the	O
RCA	B-Device
Studio	I-Device
II	I-Device
.	O
</s>
<s>
The	O
machines	O
had	O
been	O
available	O
since	O
1975	O
,	O
but	O
the	O
Studio	B-Device
II	I-Device
was	O
announced	O
only	O
in	O
January	O
1977	O
,	O
a	O
couple	O
of	O
months	O
after	O
the	O
Fairchild	B-Operating_System
Channel	I-Operating_System
F	I-Operating_System
became	O
the	O
first	O
cartridge-based	O
machine	O
on	O
the	O
market	O
.	O
</s>
<s>
Both	O
would	O
soon	O
be	O
eclipsed	O
and	O
largely	O
forgotten	O
due	O
to	O
the	O
release	O
of	O
the	O
Atari	B-General_Concept
2600	I-General_Concept
later	O
that	O
year	O
.	O
</s>
<s>
RCA	O
canceled	O
the	O
Studio	B-Device
II	I-Device
in	O
February	O
1978	O
.	O
</s>
<s>
The	O
COSMAC	O
was	O
unique	O
among	O
early	O
8-bit	O
processors	O
in	O
that	O
it	O
had	O
been	O
explicitly	O
designed	O
for	O
microcomputer	O
use	O
;	O
other	O
designs	O
of	O
the	O
era	O
were	O
invariably	O
aimed	O
at	O
the	O
embedded	B-Architecture
processor	I-Architecture
space	O
,	O
and	O
those	O
that	O
had	O
been	O
designed	O
for	O
computer	O
use	O
were	O
generally	O
more	O
complex	O
systems	O
,	O
and	O
often	O
16-bit	O
.	O
</s>
<s>
Although	O
the	O
COSMAC	O
had	O
been	O
designed	O
for	O
computer	O
use	O
,	O
RCA	O
's	O
slow	O
market	O
entry	O
and	O
undersupported	O
attempts	O
in	O
this	O
market	O
ultimately	O
failed	O
and	O
other	O
processors	O
like	O
the	O
MOS	B-General_Concept
6502	I-General_Concept
and	O
Zilog	B-General_Concept
Z80	I-General_Concept
would	O
come	O
to	O
dominate	O
this	O
market	O
.	O
</s>
<s>
Ironically	O
,	O
COSMAC	O
would	O
ultimately	O
find	O
great	O
success	O
in	O
the	O
embedded	O
market	O
,	O
because	O
its	O
CMOS	B-Device
design	O
allowed	O
it	O
to	O
work	O
at	O
lower	O
power	O
.	O
</s>
<s>
A	O
number	O
of	O
early	O
microcomputers	O
were	O
based	O
on	O
the	O
1802	O
,	O
including	O
the	O
COSMAC	B-Device
ELF	I-Device
(	O
1976	O
)	O
,	O
Netronics	B-Device
ELF	I-Device
II	I-Device
,	O
Quest	O
SuperELF	O
,	O
COSMAC	B-Device
VIP	I-Device
,	O
Comx-35	B-Device
,	O
Finnish	O
Telmac	B-Device
1800	I-Device
,	O
Telmac	B-Device
TMC-600	I-Device
and	O
Oscom	O
Nano	O
,	O
Yugoslav	O
Pecom	B-Device
32	I-Device
and	O
64	B-Device
,	O
and	O
the	O
Cybervision	O
systems	O
sold	O
through	O
Montgomery	O
Ward	O
in	O
the	O
late	O
1970s	O
,	O
as	O
well	O
as	O
the	O
RCA	B-Device
Studio	I-Device
II	I-Device
video	B-Device
game	I-Device
console	I-Device
(	O
one	O
of	O
the	O
first	O
consoles	O
to	O
use	O
bitmapped	O
graphics	O
)	O
.	O
</s>
<s>
The	O
Edukit	O
single-board	B-Device
computer	I-Device
trainer	O
system	O
,	O
similar	O
to	O
an	O
expanded	O
COSMAC	B-Device
Elf	I-Device
,	O
was	O
offered	O
by	O
Modus	O
Systems	O
Ltd	O
.	O
in	O
Britain	O
in	O
the	O
early	O
1980s	O
.	O
</s>
<s>
In	O
addition	O
to	O
"	O
bulk	O
silicon	O
"	O
C2L	O
CMOS	B-Device
technology	O
,	O
the	O
1802	O
was	O
also	O
available	O
fabricated	O
in	O
Silicon	B-Algorithm
on	I-Algorithm
Sapphire	I-Algorithm
(	O
SOS	O
)	O
semiconductor	O
process	O
technology	O
,	O
which	O
gives	O
it	O
a	O
degree	O
of	O
resistance	O
to	O
radiation	O
and	O
electrostatic	O
discharge	O
(	O
ESD	O
)	O
.	O
</s>
<s>
Along	O
with	O
its	O
extreme	O
low-power	O
abilities	O
,	O
this	O
makes	O
the	O
chip	O
well-suited	O
in	O
space	O
and	O
military	O
applications	O
(	O
also	O
,	O
at	O
the	O
time	O
the	O
1802	O
was	O
introduced	O
,	O
very	O
few	O
,	O
if	O
any	O
,	O
other	O
radiation-hardened	O
microprocessors	B-Architecture
were	O
available	O
in	O
the	O
market	O
)	O
.	O
</s>
<s>
The	O
1802	O
was	O
used	O
in	O
many	O
spacecraft	O
and	O
space	O
science	O
programs	O
,	O
experiments	O
,	O
projects	O
and	O
modules	O
such	O
as	O
the	O
Galileo	O
spacecraft	O
,	O
Magellan	B-Architecture
,	O
the	O
Plasma	O
Wave	O
Analyzer	O
instrument	O
on	O
ESA	O
's	O
Ulysses	O
spacecraft	O
,	O
various	O
Earth-orbiting	O
satellites	O
and	O
satellites	O
carrying	O
amateur	O
radio	O
.	O
</s>
<s>
The	O
first	O
high-level	O
language	O
available	O
for	O
the	O
1802	O
was	O
Forth	B-Application
,	O
provided	O
by	O
Forth	B-Application
,	O
Inc	O
.	O
and	O
it	O
was	O
known	O
as	O
MicroFORTH	O
,	O
in	O
1976	O
(	O
see	O
Forth	B-Application
Inc	O
's	O
archive	O
)	O
.	O
</s>
<s>
Other	O
available	O
programming	O
languages	O
,	O
both	O
interpreters	O
and	O
compilers	O
,	O
are	O
CHIP-8	B-Device
(	O
It	O
was	O
also	O
invented	O
by	O
Joseph	O
Weisbecker	O
)	O
(	O
and	O
variants	O
)	O
,	O
8th	O
(	O
a	O
version	O
of	O
Forth	B-Application
created	O
by	O
Lee	O
Hart	O
)	O
,	O
Tom	O
Pittman	O
's	O
Tiny	B-Language
BASIC	I-Language
,	O
C	O
,	O
various	O
Assemblers	O
and	O
cross-assemblers	O
,	O
and	O
others	O
.	O
</s>
<s>
Other	O
specialty	O
languages	O
were	O
used	O
by	O
federal	O
agencies	O
such	O
as	O
NASA	O
and	O
its	O
installations	O
,	O
including	O
Johnson	O
Space	O
Center	O
,	O
AMES	O
,	O
Goddard	O
,	O
Langley	O
,	O
Marshall	O
,	O
and	O
Jet	O
Propulsion	O
Laboratory	O
(	O
JPL	O
)	O
,	O
which	O
included	O
the	O
HAL/S	O
cross-compiler	O
,	O
STOIC	B-Language
,	O
a	O
Forth-like	O
language	O
,	O
and	O
others	O
.	O
</s>
<s>
The	O
1802	O
chip	O
and	O
computers	O
using	O
the	O
microprocessor	B-Architecture
have	O
been	O
emulated	O
and	O
simulated	O
in	O
hardware	O
and/or	O
software	O
by	O
hobbyists	O
.	O
</s>
<s>
There	O
are	O
three	O
designs	O
in	O
VHDL	B-Language
for	O
an	O
FPGA	B-Architecture
.	O
</s>
<s>
A	O
bus-accurate	O
,	O
full	O
speed	O
COSMAC	B-Device
Elf	I-Device
clone	O
was	O
created	O
without	O
a	O
CDP1802	B-General_Concept
microprocessor	B-Architecture
chip	O
or	O
CDP1861	O
video	B-General_Concept
chip	I-General_Concept
using	O
PIC	B-Architecture
microcontrollers	I-Architecture
.	O
</s>
<s>
An	O
online	O
simulator	O
of	O
the	O
COSMAC	B-Device
Elf	I-Device
(	O
enhanced	O
)	O
written	O
in	O
JavaScript	O
runs	O
in	O
the	O
user	O
's	O
browser	O
with	O
no	O
need	O
to	O
download	O
.	O
</s>
<s>
The	O
RCA	B-General_Concept
1802	I-General_Concept
has	O
a	O
static	B-General_Concept
core	I-General_Concept
CMOS	B-Device
design	O
with	O
no	O
minimum	O
clock	O
frequency	O
,	O
so	O
that	O
it	O
can	O
be	O
run	O
at	O
very	O
low	O
speeds	O
and	O
low	O
power	O
,	O
including	O
a	O
clock	O
frequency	O
of	O
zero	O
to	O
suspend	O
the	O
microprocessor	B-Architecture
without	O
affecting	O
its	O
operation	O
.	O
</s>
<s>
It	O
has	O
two	O
separate	O
8-pin	O
buses	O
:	O
an	O
8-bit	O
bidirectional	O
data	B-General_Concept
bus	I-General_Concept
and	O
a	O
time-multiplexed	O
address	B-Architecture
bus	I-Architecture
,	O
with	O
the	O
high-order	O
and	O
low-order	O
8-bits	O
of	O
the	O
16-bit	O
address	O
being	O
accessed	O
on	O
alternate	O
clock	O
cycles	O
.	O
</s>
<s>
This	O
contrasts	O
with	O
most	O
designs	O
of	O
the	O
era	O
,	O
like	O
the	O
MOS	B-General_Concept
6502	I-General_Concept
and	O
Intel	B-General_Concept
8080	I-General_Concept
,	O
which	O
used	O
a	O
16-bit	O
address	B-Architecture
bus	I-Architecture
.	O
</s>
<s>
These	O
pins	O
allow	O
simple	O
input/output	B-General_Concept
(	O
I/O	B-General_Concept
)	O
tasks	O
to	O
be	O
handled	O
directly	O
and	O
easily	O
programmed	O
.	O
</s>
<s>
For	O
comparison	O
,	O
the	O
6502	B-General_Concept
completes	O
most	O
instruction	B-General_Concept
in	O
2	O
to	O
4	O
clock	O
cycles	O
,	O
with	O
the	O
longest	O
taking	O
7	O
cycles	O
.	O
</s>
<s>
Various	O
suffixes	O
to	O
the	O
CDP1802	B-General_Concept
part	O
number	O
denote	O
technical	O
specifications	O
,	O
including	O
(	O
A	O
,	O
B	O
,	O
&	O
C	O
)	O
operating	O
speed	O
(	O
3.2MHz	O
to	O
6.4MHz	O
)	O
,	O
temperature	O
(	O
-40	O
°C	O
to	O
+85°C	O
,	O
-55	O
°C	O
to	O
+125°C	O
)	O
,	O
and	O
voltage	O
ranges	O
(	O
4V	O
to	O
10.5V	O
)	O
,	O
package	O
type	O
(	O
D	O
,	O
E	O
,	O
Q	O
)	O
,	O
and	O
burn-in	O
(	O
X	O
)	O
.	O
</s>
<s>
Most	O
operations	O
use	O
the	O
D	O
register	O
,	O
including	O
arithmetic	O
and	O
logic	O
functions	O
,	O
and	O
memory	O
referencing	O
load	B-General_Concept
and	I-General_Concept
store	I-General_Concept
instructions	I-General_Concept
.	O
</s>
<s>
Using	O
the	O
SEP	O
instruction	B-General_Concept
,	O
you	O
can	O
select	O
any	O
of	O
the	O
16	O
registers	O
to	O
be	O
the	O
program	B-General_Concept
counter	I-General_Concept
;	O
using	O
the	O
SEX	O
instruction	B-General_Concept
,	O
you	O
can	O
select	O
any	O
of	O
the	O
16-bit	O
registers	O
to	O
be	O
the	O
index	B-General_Concept
register	I-General_Concept
.	O
</s>
<s>
Register	O
R0	O
has	O
the	O
special	O
use	O
of	O
holding	O
the	O
memory	O
address	O
for	O
the	O
built-in	O
DMA	B-General_Concept
controller	I-General_Concept
.	O
</s>
<s>
Register	O
R1	O
has	O
the	O
special	O
use	O
of	O
being	O
the	O
program	B-General_Concept
counter	I-General_Concept
for	O
the	O
interrupt	O
handler	O
.	O
</s>
<s>
The	O
processor	O
has	O
five	O
special	O
I/O	B-General_Concept
lines	O
.	O
</s>
<s>
There	O
is	O
a	O
single	O
Q	O
output	O
that	O
can	O
be	O
set	O
with	O
the	O
SEQ	O
instruction	B-General_Concept
and	O
reset	O
with	O
the	O
REQ	O
instruction	B-General_Concept
.	O
</s>
<s>
It	O
was	O
typical	O
for	O
the	O
Q	O
line	O
to	O
drive	O
a	O
status	O
LED	O
,	O
a	O
cassette	B-Device
interface	O
,	O
an	O
RS-232	O
interface	O
,	O
and	O
the	O
speaker	O
.	O
</s>
<s>
This	O
meant	O
that	O
the	O
user	O
could	O
actually	O
hear	O
RS-232	O
and	O
cassette	B-Device
data	O
being	O
transmitted	O
(	O
unless	O
a	O
volume	O
control	O
was	O
implemented	O
)	O
.	O
</s>
<s>
Traditionally	O
,	O
the	O
EF4	O
line	O
is	O
attached	O
to	O
the	O
INPUT	O
momentary	O
pushbutton	O
on	O
the	O
COSMAC	B-Device
Elf	I-Device
.	O
</s>
<s>
Each	O
Instruction	B-General_Concept
is	O
a	O
single	O
Byte	O
,	O
of	O
8	O
Bits	O
.	O
</s>
<s>
The	O
4	O
Bits	O
to	O
the	O
Left	O
,	O
sometimes	O
called	O
High	O
Order	O
Hex	O
Digit	O
,	O
are	O
to	O
do	O
with	O
the	O
actual	O
nature	O
of	O
the	O
Instruction	B-General_Concept
,	O
and	O
those	O
4	O
Bits	O
are	O
involved	O
with	O
the	O
I	O
Register	O
.	O
</s>
<s>
A	O
few	O
commonly	O
used	O
subroutines	O
can	O
be	O
called	O
quickly	O
by	O
keeping	O
their	O
address	O
in	O
one	O
of	O
the	O
16	O
registers	O
;	O
however	O
,	O
the	O
called	O
subroutine	O
must	O
know	O
(	O
hard	O
coded	O
)	O
what	O
the	O
calling	O
PC	O
register	O
is	O
to	O
perform	O
the	O
"	O
return	O
"	O
instruction	B-General_Concept
.	O
</s>
<s>
The	O
SEP	O
instruction	B-General_Concept
is	O
used	O
to	O
call	O
a	O
subroutine	O
pointed	O
to	O
by	O
one	O
of	O
the	O
16-bit	O
registers	O
and	O
another	O
SEP	O
to	O
return	O
to	O
the	O
caller	O
(	O
SEP	O
stands	O
for	O
Set	O
Program	B-General_Concept
Counter	I-General_Concept
,	O
and	O
selects	O
which	O
one	O
of	O
the	O
16	O
registers	O
is	O
to	O
be	O
used	O
as	O
the	O
program	B-General_Concept
counter	I-General_Concept
from	O
that	O
point	O
onward	O
)	O
.	O
</s>
<s>
Before	O
a	O
subroutine	O
returns	O
,	O
it	O
jumps	O
to	O
the	O
location	O
immediately	O
preceding	O
its	O
entry	O
point	O
so	O
that	O
after	O
the	O
SEP	O
"	O
return	O
"	O
instruction	B-General_Concept
returns	O
control	O
to	O
the	O
caller	O
,	O
the	O
register	O
will	O
be	O
pointing	O
to	O
the	O
right	O
value	O
for	O
next	O
usage	O
.	O
</s>
<s>
Although	O
any	O
of	O
the	O
available	O
registers	O
can	O
be	O
used	O
for	O
this	O
technique	O
,	O
per	O
programmer	O
's	O
preference	O
,	O
many	O
use	O
the	O
routine	O
supplied	O
by	O
RCA	O
in	O
the	O
CDP1802	B-General_Concept
User	O
Manual	O
,	O
where	O
the	O
suggested	O
register	O
usage	O
is	O
R2	O
=	O
Stack	O
Pointer	O
,	O
R3	O
=	O
General	O
Program	B-General_Concept
Counter	I-General_Concept
(	O
PC	O
)	O
,	O
R4	O
=	O
Call	O
,	O
R5	O
=	O
Return	O
,	O
R6	O
=	O
Passed	O
Arguments	O
Pointer	O
(	O
non-destructive	O
)	O
.	O
</s>
<s>
(	O
as	O
opposed	O
to	O
what	O
would	O
be	O
incurred	O
if	O
actual	O
CALL	O
and	O
RET	O
instructions	O
were	O
part	O
of	O
the	O
microprocessor	B-Architecture
's	O
design	O
)	O
This	O
setup	O
allows	O
R0	O
to	O
be	O
used	O
for	O
DMA	B-General_Concept
and	O
R1	O
to	O
be	O
used	O
for	O
Interrupts	O
,	O
if	O
desired	O
,	O
allowing	O
R7	O
through	O
RF	O
(	O
hex	O
)	O
for	O
general	O
program	O
usage	O
.	O
</s>
<s>
Because	O
of	O
the	O
16-bit	O
address	B-Architecture
bus	I-Architecture
,	O
and	O
the	O
8-bit	O
data	B-General_Concept
bus	I-General_Concept
,	O
the	O
sixteen	O
general	O
purpose	O
registers	O
are	O
16	O
bits	O
wide	O
,	O
but	O
the	O
accumulator	O
D-register	O
is	O
only	O
8	O
bits	O
wide	O
.	O
</s>
<s>
Similarly	O
,	O
loading	O
a	O
new	O
constant	O
into	O
a	O
register	O
(	O
such	O
as	O
a	O
new	O
address	O
for	O
a	O
subroutine	O
jump	O
,	O
or	O
the	O
address	O
of	O
a	O
data	O
variable	O
)	O
also	O
involves	O
four	O
instructions	O
(	O
two	O
load	O
immediate	O
,	O
LDI	O
,	O
instructions	O
,	O
one	O
for	O
each	O
half	O
of	O
the	O
constant	O
,	O
each	O
one	O
followed	O
by	O
a	O
Put	O
instruction	B-General_Concept
to	O
the	O
register	O
,	O
PHI	O
and	O
PLO	O
)	O
.	O
</s>
<s>
Thus	O
,	O
the	O
direct	O
addressing	O
mode	O
needs	O
to	O
be	O
emulated	O
using	O
the	O
four	O
instructions	O
mentioned	O
earlier	O
to	O
load	O
the	O
address	O
into	O
a	O
spare	O
register	O
;	O
followed	O
by	O
an	O
instruction	B-General_Concept
to	O
select	O
that	O
register	O
as	O
the	O
index	B-General_Concept
register	I-General_Concept
;	O
followed	O
,	O
finally	O
,	O
by	O
the	O
intended	O
operation	O
on	O
the	O
data	O
variable	O
that	O
is	O
pointed	O
to	O
by	O
that	O
address	O
.	O
</s>
<s>
The	O
CDP1802	B-General_Concept
has	O
a	O
simple	O
built-in	O
DMA	B-General_Concept
controller	I-General_Concept
,	O
having	O
two	O
DMA	B-General_Concept
request	I-General_Concept
lines	O
for	O
DMA	B-General_Concept
input	B-General_Concept
and	I-General_Concept
output	I-General_Concept
.	O
</s>
<s>
External	O
hardware	O
could	O
read	O
or	O
write	O
data	O
during	O
these	O
periods	O
without	O
interrupting	O
the	O
processor	O
,	O
a	O
general	O
concept	O
known	O
as	O
cycle	B-General_Concept
stealing	I-General_Concept
.	O
</s>
<s>
R0	O
is	O
used	O
as	O
the	O
DMA	B-General_Concept
address	O
pointer	O
.	O
</s>
<s>
The	O
starting	O
address	O
of	O
the	O
DMA	B-General_Concept
data	O
would	O
be	O
put	O
in	O
R0	O
and	O
then	O
pulling	O
the	O
appropriate	O
read	O
or	O
write	O
pin	O
on	O
the	O
CPU	O
low	O
.	O
</s>
<s>
The	O
CPU	O
responded	O
to	O
the	O
DMA	B-General_Concept
request	I-General_Concept
by	O
incrementing	O
the	O
value	O
in	O
R0	O
,	O
so	O
that	O
the	O
next	O
request	O
automatically	O
stored	O
in	O
the	O
next	O
location	O
in	O
memory	O
.	O
</s>
<s>
Thus	O
by	O
simply	O
repeatedly	O
triggering	O
the	O
DMA	B-General_Concept
pins	O
,	O
the	O
system	O
would	O
walk	O
through	O
the	O
entire	O
memory	O
.	O
</s>
<s>
The	O
DMA	B-General_Concept
controller	I-General_Concept
also	O
provides	O
a	O
special	O
"	O
load	O
mode	O
"	O
,	O
which	O
allows	O
loading	O
of	O
memory	O
while	O
the	O
CLEAR	O
and	O
WAIT	O
inputs	O
of	O
the	O
processor	O
are	O
active	O
.	O
</s>
<s>
This	O
allows	O
a	O
program	O
to	O
be	O
loaded	O
without	O
the	O
need	O
for	O
a	O
ROM-based	O
bootstrap	O
loader	O
.	O
</s>
<s>
This	O
was	O
used	O
by	O
the	O
COSMAC	B-Device
Elf	I-Device
microcomputer	O
and	O
its	O
successors	O
to	O
load	O
a	O
program	O
from	O
toggle	O
switches	O
or	O
a	O
hexadecimal	O
keypad	B-Device
with	O
no	O
required	O
software	O
and	O
minimal	O
hardware	O
.	O
</s>
<s>
There	O
was	O
no	O
need	O
to	O
change	O
the	O
addresses	O
,	O
that	O
was	O
done	O
automatically	O
by	O
the	O
DMA	B-General_Concept
stepping	O
.	O
</s>
<s>
Clock	O
cycle	O
efficiency	O
is	O
poor	O
in	O
comparison	O
to	O
most	O
8-bit	O
microprocessors	B-Architecture
.	O
</s>
<s>
By	O
comparison	O
,	O
the	O
MOS	B-General_Concept
Technology	I-General_Concept
6502	I-General_Concept
takes	O
two	O
to	O
seven	O
clock	O
cycles	O
to	O
execute	O
an	O
instruction	B-General_Concept
,	O
and	O
the	O
Intel	B-General_Concept
8080	I-General_Concept
takes	O
four	O
to	O
18	O
clock	O
cycles	O
.	O
</s>
<s>
In	O
early	O
1802-based	O
microcomputers	O
,	O
the	O
companion	O
graphics	O
Video	B-General_Concept
Display	I-General_Concept
Controller	I-General_Concept
chip	O
,	O
RCA	O
CDP1861	O
(	O
for	O
the	O
NTSC	O
video	O
format	O
,	O
CDP1864	O
variant	O
for	O
PAL	B-Language
)	O
,	O
used	O
the	O
built-in	O
DMA	B-General_Concept
controller	I-General_Concept
to	O
display	O
black	O
and	O
white	O
bitmapped	O
graphics	O
on	O
standard	O
TV	O
screens	O
at	O
up	O
to	O
64	B-Device
pixels	O
horizontally	O
by	O
128	O
pixels	O
vertically	O
.	O
</s>
<s>
Although	O
the	O
faster	O
versions	O
of	O
1802	O
could	O
operate	O
at	O
45MHz	O
(	O
at	O
5V	O
;	O
it	O
was	O
faster	O
(	O
6.4MHz	O
)	O
at	O
10V	O
)	O
,	O
it	O
was	O
usually	O
operated	O
at	O
3.58MHz	O
,	O
divided	O
by	O
2	O
(	O
1.79MHz	O
)	O
to	O
suit	O
the	O
requirements	O
of	O
the	O
1861	O
chip	O
,	O
which	O
gave	O
a	O
speed	O
of	O
a	O
little	O
over	O
100,000	O
instructions	O
per	O
second	O
,	O
though	O
some	O
ran	O
at	O
other	O
speeds	O
such	O
as	O
the	O
~	O
2.8MHz	O
of	O
the	O
Comx	B-Device
or	O
5MHz	O
of	O
the	O
Pecom	B-Device
.	O
</s>
<s>
The	O
COSMAC	B-Device
VIP	I-Device
,	O
which	O
integrated	O
the	O
video	B-General_Concept
chip	I-General_Concept
with	O
the	O
processor	O
as	O
a	O
single	O
purpose-built	O
computer	O
(	O
rather	O
than	O
as	O
an	O
add-on	O
to	O
a	O
hobbyist	O
kit	O
)	O
,	O
notably	O
ran	O
the	O
1802	O
much	O
slower	O
,	O
synchronising	O
it	O
exactly	O
with	O
the	O
1861	O
-	O
at	O
a	O
non-standard	O
1.76064MHz	O
,	O
as	O
recommended	O
in	O
the	O
Pixie	O
's	O
spec	O
sheet	O
reference	O
design	O
.	O
</s>
<s>
Some	O
computer	O
systems	O
,	O
like	O
the	O
Pecom	B-Device
64	I-Device
,	O
used	O
the	O
VIS	O
(	O
Video	O
Interface	O
System	O
)	O
,	O
consisting	O
of	O
the	O
CDP1869	O
and	O
CDP1870	O
companion	O
ICs	O
,	O
for	O
distinctly	O
higher	O
resolution	O
color	O
graphics	O
,	O
comparable	O
to	O
other	O
8-bit	O
systems	O
of	O
the	O
1980s	O
.	O
</s>
<s>
This	O
code	O
snippet	O
example	O
is	O
a	O
diagnostic	O
routine	O
that	O
tests	O
ALU	B-General_Concept
(	O
Arithmetic	B-General_Concept
and	I-General_Concept
Logic	I-General_Concept
Unit	I-General_Concept
)	O
Operations	O
.	O
</s>
<s>
Note	O
:	O
The	O
above	O
routine	O
presumes	O
that	O
the	O
CDP1802	B-General_Concept
microprocessor	B-Architecture
is	O
in	O
an	O
initial	O
reset	O
state	O
(	O
or	O
that	O
it	O
has	O
been	O
set	O
as	O
such	O
prior	O
to	O
executing	O
this	O
code	O
)	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
program	B-General_Concept
counter	I-General_Concept
(	O
PC	O
)	O
and	O
the	O
X	O
indirect	O
register	O
'	O
pointer	O
 '	O
are	O
both	O
set	O
to	O
16-bit	O
register	O
R0	O
.	O
</s>
<s>
The	O
PC	O
is	O
incremented	O
after	O
the	O
opcode	O
instruction	B-General_Concept
byte	O
is	O
retrieved	O
from	O
memory	O
,	O
so	O
it	O
points	O
to	O
the	O
next	O
address	O
when	O
the	O
OUT	O
4	O
is	O
executed	O
.	O
</s>
<s>
The	O
OUT	O
instruction	B-General_Concept
also	O
increments	O
the	O
X	O
register	O
,	O
which	O
is	O
R0	O
,	O
which	O
is	O
also	O
the	O
PC	O
,	O
so	O
it	O
outputs	O
the	O
immediate	O
value	O
after	O
the	O
OUT	O
and	O
continues	O
program	O
execution	O
at	O
the	O
next	B-General_Concept
instruction	I-General_Concept
address	I-General_Concept
after	O
the	O
immediate	O
value	O
.	O
</s>
<s>
The	O
routine	O
also	O
presumes	O
that	O
OUT	O
4	O
will	O
display	O
the	O
value	O
in	O
the	O
CPU	O
system	O
's	O
8-bit	O
LED	O
or	O
2-digit	O
hex	O
display	O
,	O
and	O
IN	O
4	O
gets	O
the	O
value	O
from	O
the	O
eight	O
toggle	O
switches	O
(	O
or	O
possibly	O
the	O
hex	O
keypad	B-Device
)	O
.	O
</s>
