<s>
The	O
COP400	B-Device
or	O
COP	O
II	O
is	O
a	O
4-bit	O
microcontroller	B-Architecture
family	O
introduced	O
in	O
1977	O
by	O
National	O
Semiconductor	O
as	O
a	O
follow-on	O
product	O
to	O
their	O
original	O
PMOS	B-Algorithm
COP	O
microcontroller	B-Architecture
.	O
</s>
<s>
COP400	B-Device
family	O
members	O
are	O
complete	O
microcomputers	O
containing	O
internal	O
timing	O
,	O
logic	O
,	O
ROM	B-Device
,	O
RAM	B-Architecture
,	O
and	O
I/O	O
necessary	O
to	O
implement	O
dedicated	O
controllers	O
.	O
</s>
<s>
Some	O
COP400	B-Device
devices	O
were	O
second-sourced	O
by	O
Western	O
Digital	O
as	O
the	O
WD4200	O
family	O
.	O
</s>
<s>
In	O
the	O
Soviet	O
Union	O
several	O
COP400	B-Device
microcontrollers	B-Architecture
were	O
manufactured	O
as	O
the	O
1820	O
series	O
(	O
e.g.	O
</s>
<s>
The	O
COP400	B-Device
is	O
implemented	O
in	O
CMOS	B-Device
or	O
N-channel	B-Algorithm
silicon	I-Algorithm
gate	I-Algorithm
MOS	O
technology	O
.	O
</s>
<s>
It	O
was	O
typically	O
packaged	O
in	O
24	O
-	O
or	O
28-pin	O
DIP	B-Algorithm
packages	O
.	O
</s>
<s>
The	O
COP400	B-Device
family	O
offered	O
several	O
memory	O
and	O
pinout	O
configurations	O
.	O
</s>
<s>
The	O
COP400	B-Device
uses	O
separate	O
memory	O
spaces	O
for	O
ROM	B-Device
and	O
RAM	B-Architecture
.	O
</s>
<s>
ROM	B-Device
addresses	O
are	O
11-bit	O
maximum	O
,	O
while	O
data	O
addresses	O
are	O
7-bit	O
maximum	O
.	O
</s>
<s>
Program	B-Device
memory	I-Device
consists	O
of	O
a	O
512	O
,	O
1024	O
,	O
or	O
2048	O
×	O
8-bit	O
ROM	B-Device
.	O
</s>
<s>
ROM	B-Device
bytes	B-Application
may	O
be	O
program	O
instructions	O
,	O
program	O
data	O
,	O
or	O
jump	O
address	O
pointers	O
.	O
</s>
<s>
Due	O
to	O
the	O
special	O
characteristics	O
associated	O
with	O
the	O
JP	O
and	O
JSRP	O
instructions	O
,	O
ROM	B-Device
must	O
often	O
be	O
conceived	O
of	O
as	O
organized	O
into	O
pages	O
of	O
64	O
bytes	B-Application
each	O
.	O
</s>
<s>
Also	O
,	O
because	O
of	O
the	O
unique	O
operations	O
performed	O
by	O
the	O
LQID	O
and	O
JID	O
instructions	O
,	O
ROM	B-Device
pages	O
must	O
sometimes	O
be	O
thought	O
of	O
as	O
organized	O
into	O
blocks	O
of	O
256	O
bytes	B-Application
.	O
</s>
<s>
Data	O
memory	O
consists	O
of	O
a	O
32	O
,	O
64	O
,	O
or	O
128	O
×	O
4-bit	O
RAM	B-Architecture
,	O
organized	O
as	O
several	O
data	O
registers	O
of	O
16	O
4-bit	O
digits	O
.	O
</s>
<s>
RAM	B-Architecture
addressing	O
is	O
implemented	O
by	O
the	O
6	O
-	O
or	O
7-bit	O
B	O
register	O
used	O
as	O
a	O
pointer	O
.	O
</s>
<s>
The	O
4-bit	O
contents	O
of	O
the	O
RAM	B-Architecture
digit	O
pointed	O
to	O
by	O
the	O
B	O
register	O
are	O
usually	O
loaded	O
into	O
,	O
exchanged	O
with	O
,	O
or	O
operate	O
on	O
the	O
A	O
register	O
.	O
</s>
<s>
The	O
register	O
configuration	O
shown	O
in	O
the	O
diagram	O
is	O
for	O
the	O
COP400	B-Device
family	O
members	O
with	O
maximum	O
ROM	B-Device
(	O
2048	O
×	O
8	O
bits	O
)	O
and	O
RAM	B-Architecture
(	O
128	O
×	O
4	O
bits	O
)	O
.	O
</s>
<s>
Family	O
members	O
with	O
only	O
512	O
or	O
1024	O
bytes	B-Application
of	O
ROM	B-Device
will	O
have	O
only	O
a	O
9	O
-	O
or	O
10-bit	O
PC	O
.	O
</s>
<s>
Those	O
with	O
64	O
or	O
32	O
locations	O
of	O
RAM	B-Architecture
will	O
have	O
only	O
a	O
2-bit	O
Br	O
register	O
.	O
</s>
<s>
A	O
4-bit	O
ALU	B-General_Concept
performs	O
the	O
arithmetic	O
and	O
logic	O
functions	O
,	O
storing	O
results	O
in	O
A	O
.	O
ASC	O
and	O
CASC	O
operations	O
output	O
a	O
carry	O
to	O
the	O
1-bit	O
C	B-Algorithm
register	O
,	O
most	O
often	O
employed	O
to	O
indicate	O
arithmetic	O
overflow	O
.	O
</s>
<s>
All	O
ROM	B-Device
addressing	O
is	O
accomplished	O
via	O
the	O
9-	O
,	O
10-	O
,	O
or	O
11-bit	O
PC	O
register	O
.	O
</s>
<s>
Its	O
binary	O
value	O
selects	O
one	O
of	O
the	O
bytes	B-Application
contained	O
in	O
ROM	B-Device
,	O
usually	O
the	O
next	O
program	O
instruction	O
.	O
</s>
<s>
The	O
value	O
of	O
PC	O
is	O
automatically	O
incremented	O
by	O
1	O
prior	O
to	O
the	O
execution	O
of	O
the	O
current	O
instruction	O
to	O
point	O
to	O
the	O
next	O
sequential	O
ROM	B-Device
location	O
,	O
unless	O
the	O
current	O
instruction	O
is	O
a	O
transfer	O
of	O
control	O
instruction	O
.	O
</s>
<s>
The	O
PC	O
automatically	O
rolls	O
over	O
to	O
point	O
to	O
the	O
next	O
64	O
byte	B-Application
page	O
or	O
256	O
byte	B-Application
block	O
of	O
program	B-Device
memory	I-Device
.	O
</s>
<s>
There	O
are	O
no	O
port	O
numbers	O
or	O
memory	O
addresses	O
associated	O
with	O
the	O
COP400	B-Device
I/O	O
devices	O
.	O
</s>
<s>
All	O
the	O
physical	O
I/O	O
registers	O
and	O
ports	O
are	O
referenced	O
by	O
the	O
COP400	B-Device
assembly	O
language	O
directly	O
by	O
name	O
.	O
</s>
<s>
Nearly	O
all	O
COP400	B-Device
family	O
devices	O
implement	O
the	O
following	O
:	O
</s>
<s>
The	O
D	O
register	O
is	O
useful	O
for	O
synchronizing	O
up	O
to	O
16	O
external	O
devices	O
associated	O
with	O
the	O
RAM	B-Architecture
pointed	O
to	O
by	O
the	O
B	O
register	O
.	O
</s>
<s>
The	O
Q	O
register	O
is	O
an	O
internal	O
,	O
latched	O
,	O
8-bit	O
register	O
used	O
to	O
hold	O
data	O
loaded	O
to	O
or	O
from	O
RAM(B )	O
and	O
A	O
,	O
as	O
well	O
as	O
8-bit	O
program	O
data	O
from	O
ROM	B-Device
.	O
</s>
<s>
Also	O
,	O
the	O
contents	O
of	O
L	O
may	O
be	O
read	O
directly	O
into	O
A	O
and	O
RAM(B )	O
.	O
</s>
<s>
Some	O
low-end	O
COP400	B-Device
family	O
members	O
do	O
not	O
have	O
this	O
time	O
base	O
counter	O
nor	O
the	O
SKT	O
instruction	O
.	O
</s>
<s>
Some	O
high-end	O
COP400	B-Device
devices	O
can	O
read	O
and	O
write	O
the	O
upper	O
eight	O
bits	O
of	O
the	O
timer	O
.	O
</s>
<s>
There	O
are	O
a	O
few	O
high	O
end	O
members	O
of	O
the	O
COP400	B-Device
family	O
such	O
as	O
the	O
COP440	O
and	O
COP2440	O
that	O
have	O
40-pins	O
.	O
</s>
<s>
The	O
input	O
path	O
is	O
from	O
the	O
pins	O
to	O
the	O
accumulator	O
and	O
RAM	B-Architecture
.	O
</s>
<s>
N4-IN5	O
select	O
interrupt	B-Application
sources	O
.	O
</s>
<s>
The	O
COP400	B-Device
family	O
is	O
designed	O
to	O
have	O
very	O
compact	O
code	O
.	O
</s>
<s>
The	O
most	O
frequently	O
used	O
instructions	O
are	O
one	O
byte	B-Application
.	O
</s>
<s>
In	O
some	O
cases	O
there	O
are	O
special	O
one-byte	O
forms	O
of	O
two	O
byte	B-Application
instructions	O
.	O
</s>
<s>
The	O
general-form	O
instruction	O
takes	O
two	O
bytes	B-Application
.	O
</s>
<s>
There	O
is	O
a	O
one-byte	O
form	O
of	O
LBI	O
that	O
can	O
only	O
set	O
Br	O
to	O
0	O
,	O
1	O
,	O
2	O
,	O
and	O
3	O
and	O
can	O
only	O
set	O
Bd	O
to	O
9	O
,	O
10	O
,	O
11	O
,	O
12	O
,	O
13	O
,	O
14	O
,	O
15	O
,	O
and	O
0	O
(	O
decimal	O
)	O
.	O
</s>
<s>
The	O
single	O
byte	B-Application
LBI	O
can	O
only	O
access	O
32	O
RAM	B-Architecture
locations	O
.	O
</s>
<s>
JSR	O
,	O
in	O
the	O
general	O
subroutine	O
branch	O
form	O
,	O
is	O
two	O
bytes	B-Application
and	O
can	O
access	O
any	O
memory	O
location	O
directly	O
.	O
</s>
<s>
JSRP	O
is	O
a	O
single	O
byte	B-Application
form	O
of	O
subroutine	O
branch	O
that	O
can	O
access	O
only	O
the	O
locations	O
in	O
the	O
third	O
64-byte	O
page	O
.	O
</s>
<s>
JMP	O
,	O
in	O
the	O
general	O
branch	O
form	O
,	O
is	O
two	O
bytes	B-Application
and	O
can	O
access	O
any	O
memory	O
location	O
directly	O
.	O
</s>
<s>
JP	O
is	O
a	O
single	O
byte	B-Application
form	O
of	O
branch	O
that	O
can	O
access	O
any	O
location	O
in	O
the	O
current	O
64-byte	O
page	O
.	O
</s>
<s>
This	O
is	O
useful	O
for	O
creating	O
a	O
one	O
byte	B-Application
JSRP	O
entry	O
point	O
in	O
page	O
2	O
that	O
can	O
then	O
branch	O
to	O
a	O
subroutine	O
on	O
page	O
3	O
with	O
a	O
single	O
byte	B-Application
JP	O
.	O
</s>
<s>
The	O
B	O
register	O
can	O
be	O
used	O
to	O
point	O
to	O
up	O
to	O
four	O
RAM	B-Architecture
strings	O
with	O
little	O
overhead	O
.	O
</s>
<s>
All	O
COP400	B-Device
devices	O
that	O
have	O
28	O
pins	O
or	O
more	O
support	O
a	O
single	O
interrupt	B-Application
.	O
</s>
<s>
The	O
IN	O
1	O
line	O
is	O
used	O
as	O
the	O
interrupt	B-Application
input	O
.	O
</s>
<s>
Interrupt	B-Application
is	O
enabled	O
by	O
setting	O
bit	O
1	O
of	O
the	O
EN	O
register	O
to	O
1	O
with	O
a	O
LEI	O
instruction	O
.	O
</s>
<s>
The	O
PC	O
is	O
then	O
pushed	O
on	O
the	O
subroutine	O
stack	O
and	O
control	O
is	O
transferred	O
to	O
the	O
interrupt	B-Application
handler	O
at	O
address	O
0xFF	O
.	O
</s>
<s>
No	O
subroutines	O
may	O
be	O
called	O
in	O
the	O
interrupt	B-Application
service	O
routine	O
.	O
</s>
<s>
Although	O
the	O
majority	O
of	O
COP400	B-Device
devices	O
were	O
targeted	O
at	O
low-end	O
applications	O
,	O
several	O
extensions	O
to	O
the	O
architecture	O
were	O
created	O
to	O
address	O
more	O
demanding	O
applications	O
.	O
</s>
<s>
Dual	O
CPU	O
,	O
a	O
deeper	O
stack	O
in	O
RAM	B-Architecture
,	O
and	O
larger	O
address	O
spaces	O
were	O
added	O
to	O
some	O
devices	O
by	O
1985	O
.	O
</s>
<s>
“	O
Dual	O
CPU	O
”	O
versions	O
of	O
the	O
COP400	B-Device
were	O
announced	O
by	O
National	O
Semiconductor	O
in	O
1981	O
.	O
</s>
<s>
In	O
reality	O
,	O
the	O
CPUs	O
are	O
not	O
fully	O
independent	O
and	O
share	O
hardware	O
resources	O
similar	O
to	O
Intel	O
processors	O
with	O
Hyper-Threading	B-Operating_System
Technology	I-Operating_System
(	O
HTT	O
)	O
.	O
</s>
<s>
Like	O
HTT	O
,	O
the	O
dual	O
CPU	O
version	O
works	O
by	O
duplicating	O
certain	O
sections	O
of	O
the	O
processor	O
—	O
those	O
that	O
store	O
the	O
architectural	B-General_Concept
state	I-General_Concept
—	O
but	O
not	O
duplicating	O
the	O
main	O
execution	O
resources	O
such	O
as	O
ALU	B-General_Concept
,	O
buses	O
,	O
and	O
memory	O
.	O
</s>
<s>
Separate	O
architectural	B-General_Concept
states	I-General_Concept
for	O
each	O
of	O
the	O
two	O
virtual	O
processors	O
is	O
established	O
with	O
duplicated	O
A	O
(	O
accumulators	O
)	O
,	O
B	O
(	O
pointer	O
registers	O
)	O
,	O
C	B-Algorithm
(	O
carry	B-Algorithm
flags	I-Algorithm
)	O
,	O
N	O
(	O
stack	O
pointers	O
)	O
,	O
and	O
PC	O
(	O
program	O
counters	O
)	O
.	O
</s>
<s>
The	O
processors	O
will	O
then	O
alternately	O
execute	O
one	O
byte	B-Application
of	O
code	O
each	O
.	O
</s>
<s>
At	O
maximum	O
clock	O
frequency	O
,	O
the	O
instruction	O
execution	O
time	O
(	O
single	O
byte	B-Application
instruction	O
)	O
for	O
each	O
processor	O
is	O
4	O
microseconds	O
,	O
hence	O
,	O
the	O
instruction	O
cycle	O
time	O
for	O
either	O
processor	O
is	O
twice	O
that	O
amount	O
,	O
8	O
microseconds	O
.	O
</s>
<s>
Earlier	O
COP400	B-Device
devices	O
included	O
a	O
two	O
or	O
three	O
level	O
dedicated	O
hardware	O
return	O
stack	O
.	O
</s>
<s>
Later	O
devices	O
such	O
as	O
the	O
COP440	O
feature	O
a	O
4-level	O
return	O
stack	O
implemented	O
with	O
a	O
2-bit	O
stack	O
pointer	O
and	O
RAM	B-Architecture
.	O
</s>
<s>
Dual	O
CPU	O
versions	O
have	O
two	O
separate	O
4-level	O
return	O
stacks	O
implemented	O
with	O
a	O
two	O
2-bit	O
stack	O
pointers	O
and	O
two	O
different	O
RAM	B-Architecture
areas	O
.	O
</s>
<s>
The	O
basic	O
COP400	B-Device
instruction	O
set	O
supports	O
ROM	B-Device
addresses	O
of	O
up	O
to	O
11-bits	O
(	O
2,048	O
bytes	B-Application
)	O
,	O
while	O
data	O
addresses	O
are	O
7-bits	O
maximum	O
(	O
128	O
locations	O
)	O
.	O
</s>
<s>
The	O
so-called	O
group	O
4	O
devices	O
extended	O
the	O
memory	O
limit	O
by	O
adding	O
three-byte	O
JMP	O
,	O
JSR	O
,	O
and	O
LBI	O
instructions	O
with	O
more	O
address	O
bits	O
.	O
</s>
<s>
These	O
support	O
ROM	B-Device
addresses	O
of	O
15-bits	O
maximum	O
(	O
32,768	O
bytes	B-Application
)	O
,	O
while	O
data	O
addresses	O
are	O
9-bits	O
maximum	O
(	O
512	O
locations	O
)	O
.	O
</s>
<s>
Apple	B-Device
Lisa	I-Device
utilized	O
a	O
COP421	O
to	O
control	O
the	O
keyboard	O
,	O
mouse	O
,	O
RTC	O
,	O
and	O
soft	O
power	O
switch	O
.	O
</s>
<s>
Several	O
manufacturers	O
used	O
COP400	B-Device
in	O
their	O
early	O
electronic	O
games	O
:	O
</s>
<s>
COP410	O
and	O
COP411	O
,	O
512	O
byte	B-Application
ROM	B-Device
,	O
32	O
x	O
4	O
RAM	B-Architecture
:	O
Mattel	O
's	O
Funtronics	O
Jacks	O
,	O
Red	O
Light	O
Green	O
Light	O
,	O
Tag	O
,	O
and	O
Plus	O
One	O
.	O
</s>
<s>
COP420	O
and	O
COP421	O
,	O
1024	O
byte	B-Application
ROM	B-Device
,	O
64	O
x	O
4	O
RAM	B-Architecture
:	O
Milton	O
Bradley	O
Lightfight	O
,	O
Einstein	O
,	O
and	O
Electronic	O
Battleship	O
1982	O
.	O
</s>
<s>
COP444	O
,	O
2048	O
byte	B-Application
ROM	B-Device
,	O
128	O
x	O
4	O
RAM	B-Architecture
:	O
Entex	O
Space	O
Invader	O
.	O
</s>
<s>
The	O
Grundy	B-Device
Newbrain	I-Device
computer	O
uses	O
a	O
COP420	O
to	O
manage	O
its	O
keyboard	O
,	O
tape	O
I/O	O
,	O
and	O
its	O
built-in	O
16	O
character	O
VF	B-General_Concept
alphanumeric	O
display	O
.	O
</s>
<s>
There	O
is	O
an	O
open-source	O
MAME	B-Device
emulator	O
for	O
the	O
COP400	B-Device
family	O
and	O
several	O
hand	O
held	O
games	O
and	O
specialty	O
calculators	O
.	O
</s>
