<s>
The	O
W65C816S	B-General_Concept
(	O
also	O
65C816	B-General_Concept
or	O
65816	B-General_Concept
)	O
is	O
an	O
8/16	O
-bit	O
microprocessor	B-Architecture
(	O
MPU	O
)	O
developed	O
and	O
sold	O
by	O
the	O
Western	O
Design	O
Center	O
(	O
WDC	O
)	O
.	O
</s>
<s>
Introduced	O
in	O
1983	O
,	O
the	O
W65C816S	B-General_Concept
is	O
an	O
enhanced	O
version	O
of	O
the	O
WDC	B-General_Concept
65C02	I-General_Concept
8-bit	O
MPU	O
,	O
itself	O
a	B-General_Concept
CMOS	B-Device
enhancement	O
of	O
the	O
venerable	O
MOS	B-General_Concept
Technology	I-General_Concept
6502	I-General_Concept
NMOS	B-Algorithm
MPU	O
.	O
</s>
<s>
The	O
65C816	B-General_Concept
is	O
the	O
CPU	O
for	O
the	O
Apple	B-Device
IIGS	I-Device
and	O
,	O
in	O
modified	O
form	O
,	O
the	O
Super	B-Application
Nintendo	I-Application
Entertainment	I-Application
System	I-Application
.	O
</s>
<s>
The	O
65	O
in	O
the	O
part	O
's	O
designation	O
comes	O
from	O
its	O
65C02	B-General_Concept
compatibility	O
mode	O
,	O
and	O
the	O
816	O
signifies	O
that	O
the	O
MPU	O
has	O
selectable	O
8	O
-	O
and	O
16-bit	B-Device
register	B-General_Concept
sizes	O
.	O
</s>
<s>
In	O
addition	O
to	O
the	O
availability	O
of	O
16-bit	B-Device
registers	O
,	O
the	O
W65C816S	B-General_Concept
extends	O
memory	B-General_Concept
addressing	I-General_Concept
to	O
24	O
bits	O
,	O
supporting	O
up	O
to	O
16	O
megabytes	O
of	O
random-access	B-Architecture
memory	I-Architecture
.	O
</s>
<s>
It	O
has	O
an	O
enhanced	O
instruction	B-General_Concept
set	I-General_Concept
and	O
a	B-General_Concept
16-bit	B-Device
stack	B-Application
pointer	I-Application
,	O
as	O
well	O
as	O
several	O
new	O
electrical	O
signals	O
for	O
improved	O
system	O
hardware	O
management	O
.	O
</s>
<s>
Despite	O
24-bit	O
addressing	O
,	O
the	O
65816	B-General_Concept
is	O
n't	O
a	B-General_Concept
true	O
24-bit	O
computer	O
.	O
</s>
<s>
Programs	O
still	O
operate	O
in	O
64K	O
chunks	O
since	O
registers	O
are	O
16-bit	B-Device
.	O
</s>
<s>
To	O
access	O
other	O
parts	O
of	O
internal	O
memory	O
a	B-General_Concept
technique	O
similar	O
to	O
bank	B-General_Concept
switching	I-General_Concept
is	O
needed	O
.	O
</s>
<s>
Apple	O
,	O
Atari	O
and	O
Commodore	O
all	O
opted	O
for	O
the	O
Motorola	B-Device
68000	I-Device
processor	I-Device
alternative	O
that	O
offered	O
a	B-General_Concept
fully	O
32-bit	O
programming	O
model	O
when	O
it	O
came	O
to	O
replacing	O
their	O
6502-based	O
lines	O
of	O
8-bit	O
computers	O
,	O
despite	O
the	O
65816	B-General_Concept
being	O
faster	O
cycle	O
for	O
cycle	O
.	O
</s>
<s>
At	O
reset	B-General_Concept
,	O
the	O
W65C816S	B-General_Concept
starts	O
in	O
"	O
emulation	B-Application
mode	O
"	O
,	O
meaning	O
it	O
substantially	O
behaves	O
as	O
a	B-General_Concept
65C02	B-General_Concept
.	O
</s>
<s>
Thereafter	O
,	O
the	O
W65C816S	B-General_Concept
may	O
be	O
switched	O
to	O
"	O
native	O
mode	O
"	O
with	O
a	B-General_Concept
two	O
instruction	O
sequence	O
,	O
causing	O
it	O
to	O
enable	O
all	O
enhanced	O
features	O
,	O
yet	O
still	O
maintain	O
a	B-General_Concept
substantial	O
degree	O
of	O
backward	B-General_Concept
compatibility	I-General_Concept
with	O
most	O
65C02	B-General_Concept
software	O
.	O
</s>
<s>
However	O
,	O
unlike	O
the	O
PDIP40	B-Algorithm
version	O
of	O
the	O
65C02	B-General_Concept
,	O
which	O
is	O
a	B-General_Concept
pin-compatible	O
replacement	O
for	O
its	O
NMOS	B-Algorithm
ancestor	O
,	O
the	O
PDIP40	B-Algorithm
W65C816S	B-General_Concept
is	O
not	O
pin-compatible	O
with	O
any	O
other	O
6502	B-General_Concept
family	O
MPU	O
.	O
</s>
<s>
The	O
W65C802	O
has	O
the	O
same	O
internal	O
structure	O
and	O
16-bit	B-Device
support	O
,	O
but	O
a	B-General_Concept
40-pin	O
layout	O
compatible	O
with	O
the	O
original	O
6502	B-General_Concept
.	O
</s>
<s>
This	O
allows	O
it	O
to	O
be	O
used	O
as	O
a	B-General_Concept
drop-in	O
replacement	O
in	O
certain	O
roles	O
.	O
</s>
<s>
However	O
,	O
the	O
65C802	B-General_Concept
cannot	O
emit	O
a	B-General_Concept
full	O
24-bit	O
address	O
,	O
limiting	O
it	O
to	O
64KB	O
of	O
memory	O
.	O
</s>
<s>
The	O
65C802	B-General_Concept
and	O
its	O
relatives	O
are	O
no	O
longer	O
produced	O
.	O
</s>
<s>
In	O
1981	O
,	O
Bill	O
Mensch	O
,	O
founder	O
and	O
CEO	O
of	O
WDC	O
,	O
began	O
development	O
of	O
the	O
65C02	B-General_Concept
with	O
his	O
production	O
partners	O
,	O
primarily	O
Rockwell	O
Semiconductor	O
and	O
Synertek	O
.	O
</s>
<s>
The	O
primary	O
goal	O
of	O
the	O
65C02	B-General_Concept
effort	O
was	O
to	O
move	O
from	O
the	O
original	O
6502	B-General_Concept
's	O
NMOS	B-Algorithm
process	O
to	O
the	O
65C02	B-General_Concept
's	O
CMOS	B-Device
,	O
which	O
would	O
allow	O
it	O
to	O
run	O
at	O
much	O
lower	O
power	O
levels	O
,	O
somewhere	O
between	O
and	O
when	O
running	O
at	O
the	O
same	O
clock	O
speeds	O
.	O
</s>
<s>
A	B-General_Concept
number	O
of	O
new	O
opcodes	B-Language
and	O
bug	O
fixes	O
were	O
also	O
worked	O
into	O
the	O
design	O
.	O
</s>
<s>
Development	O
of	O
the	O
W65C816S	B-General_Concept
commenced	O
in	O
1982	O
after	O
Mensch	O
consulted	O
with	O
Apple	O
Computer	O
on	O
a	B-General_Concept
new	O
version	O
of	O
the	O
Apple	B-Device
II	I-Device
series	O
of	O
personal	B-Device
computers	I-Device
that	O
would	O
,	O
among	O
other	O
things	O
,	O
have	O
improved	O
graphics	O
and	O
sound	O
.	O
</s>
<s>
Apple	O
wanted	O
an	O
MPU	O
that	O
would	O
be	O
software	O
compatible	O
with	O
the	O
6502	B-General_Concept
then	O
in	O
use	O
in	O
the	O
Apple	B-Device
II	I-Device
but	O
with	O
the	O
ability	O
to	O
address	O
more	O
memory	O
,	O
and	O
to	O
load	O
and	O
store	O
16	B-Device
bit	I-Device
words	O
.	O
</s>
<s>
The	O
result	O
was	O
the	O
65C816	B-General_Concept
,	O
finished	O
in	O
March	O
1984	O
,	O
with	O
samples	O
provided	O
to	O
both	O
Apple	O
and	O
Atari	O
in	O
the	O
second	O
half	O
of	O
the	O
year	O
and	O
full	O
release	O
in	O
1985	O
.	O
</s>
<s>
The	O
same	O
process	O
also	O
led	O
to	O
the	O
65C802	B-General_Concept
,	O
which	O
was	O
identical	O
inside	O
to	O
the	O
65C816	B-General_Concept
.	O
</s>
<s>
In	O
the	O
65C802	B-General_Concept
,	O
those	O
pins	O
had	O
the	O
same	O
layout	O
as	O
the	O
original	O
6502	B-General_Concept
,	O
which	O
allowed	O
it	O
to	O
be	O
used	O
as	O
a	B-General_Concept
drop-in	O
replacement	O
while	O
still	O
allowing	O
the	O
16-bit	B-Device
processing	O
of	O
the	O
CPU	O
to	O
be	O
used	O
.	O
</s>
<s>
Typically	O
,	O
when	O
hardware	O
manufacturers	O
designed	O
a	B-General_Concept
project	O
from	O
the	O
ground	O
up	O
,	O
they	O
used	O
the	O
65C816	B-General_Concept
rather	O
than	O
the	O
65C802	B-General_Concept
,	O
resulting	O
in	O
the	O
latter	O
being	O
withdrawn	O
from	O
production	O
.	O
</s>
<s>
Apple	O
subsequently	O
integrated	O
the	O
65C816	B-General_Concept
into	O
the	O
Apple	B-Device
IIGS	I-Device
computer	O
.	O
</s>
<s>
The	O
basic	O
65C816	B-General_Concept
design	O
was	O
second-sourced	O
by	O
GTE	O
,	O
Sanyo	O
and	O
others	O
from	O
the	O
mid-to-late	O
1980s	O
to	O
the	O
early	O
1990s	O
.	O
</s>
<s>
In	O
the	O
1990s	O
,	O
both	O
the	O
65C816	B-General_Concept
and	O
65C02	B-General_Concept
were	O
converted	O
to	O
a	B-General_Concept
fully	O
static	B-General_Concept
core	I-General_Concept
,	O
which	O
made	O
it	O
possible	O
to	O
completely	O
stop	O
the	O
processor	O
's	O
Ø2	O
clock	O
without	O
loss	O
of	O
register	B-General_Concept
contents	O
.	O
</s>
<s>
This	O
feature	O
,	O
along	O
with	O
the	O
use	O
of	O
asynchronous	B-Architecture
static	I-Architecture
RAM	I-Architecture
,	O
made	O
it	O
possible	O
to	O
produce	O
designs	O
that	O
used	O
minimal	O
power	O
when	O
in	O
a	B-General_Concept
standby	O
state	O
.	O
</s>
<s>
,	O
the	O
W65C816S	B-General_Concept
is	O
available	O
from	O
WDC	O
in	O
40	O
pin	O
PDIP	B-Algorithm
,	O
PLCC44	B-Algorithm
or	O
44-pin	O
TQFP	O
packaging	O
,	O
as	O
well	O
as	O
a	B-General_Concept
core	O
for	O
ASIC	O
integration	O
(	O
for	O
example	O
Winbond	O
's	O
W55V9x	O
series	O
of	O
TV	O
Edutainment	O
ICs	O
)	O
.	O
</s>
<s>
WDC	O
,	O
itself	O
a	B-General_Concept
fabless	B-Algorithm
semiconductor	I-Algorithm
company	I-Algorithm
,	O
works	O
with	O
various	O
foundries	B-Algorithm
to	O
produce	O
the	O
W65C816S	B-General_Concept
,	O
as	O
well	O
as	O
other	O
compatible	O
products	O
.	O
</s>
<s>
Discrete	O
processors	O
are	O
available	O
through	O
a	B-General_Concept
number	O
of	O
electronics	O
distributors	O
.	O
</s>
<s>
For	O
designers	O
who	O
wish	O
to	O
include	O
W65C816S	B-General_Concept
functionality	O
into	O
a	B-General_Concept
custom	O
ASIC	O
,	O
WDC	O
offers	O
RTL	O
(	O
register-transfer	O
level	O
)	O
code	O
in	O
Verilog	B-Language
.	O
</s>
<s>
WDC	B-General_Concept
65c816	I-General_Concept
features	O
:	O
</s>
<s>
Fully	O
static	O
CMOS	B-Device
design	O
offers	O
low	O
power	O
consumption	O
(	O
300µA	O
at	O
1MHz	O
)	O
and	O
increased	O
noise	O
immunity	O
.	O
</s>
<s>
Wide	O
operating	O
frequency	O
range	O
,	O
officially	O
14MHz	O
maximum	O
at	O
5	O
volts	O
(	O
20Mhz	O
in	O
SuperCPU	O
)	O
,	O
using	O
a	B-General_Concept
single-phase	O
clock	O
source	O
(	O
hobbyists	O
have	O
successfully	O
operated	O
the	O
65C816	B-General_Concept
beyond	O
20MHz	O
)	O
.	O
</s>
<s>
Emulation	B-Application
mode	O
allows	O
substantial	O
software	O
compatibility	O
with	O
the	O
NMOS	B-Algorithm
6502	B-General_Concept
and	O
CMOS	B-Device
65C02	B-General_Concept
,	O
excepting	O
undocumented	O
opcodes	B-Language
.	O
</s>
<s>
All	O
256	O
opcodes	B-Language
in	O
the	O
65C816	B-General_Concept
are	O
functional	O
in	O
both	O
operating	O
modes	O
.	O
</s>
<s>
24-bit	O
memory	B-General_Concept
addressing	I-General_Concept
provides	O
access	O
to	O
16MB	O
of	O
memory	O
space	O
.	O
</s>
<s>
16-bit	B-Device
ALU	B-General_Concept
,	O
accumulator	B-General_Concept
(	O
C	O
)	O
,	O
stack	B-Application
pointer	I-Application
(	O
S	O
)	O
,	O
and	O
index	B-General_Concept
registers	I-General_Concept
(	O
X	O
and	O
Y	O
)	O
.	O
</s>
<s>
16-bit	B-Device
Direct	O
Page	O
(	O
aka	O
zero	O
page	O
)	O
register	B-General_Concept
(	O
D	O
)	O
.	O
</s>
<s>
Separate	O
program	O
and	O
data	O
bank	O
registers	O
allow	O
program	O
segmentation	B-General_Concept
and	O
16MB	O
linear	O
data	O
addressing	O
.	O
</s>
<s>
Valid	O
data	O
address	O
(	O
VDA	O
)	O
and	O
valid	O
program	O
address	O
(	O
VPA	O
)	O
control	O
outputs	O
for	O
memory	O
qualification	O
,	O
dual	O
cache	B-General_Concept
and	O
cycle	O
steal	O
DMA	B-General_Concept
implementation	O
.	O
</s>
<s>
Vector	O
pull	O
(	O
VPB	O
)	O
control	O
output	O
to	O
indicate	O
when	O
an	O
interrupt	B-General_Concept
vector	I-General_Concept
is	O
being	O
fetched	O
.	O
</s>
<s>
Abort	O
(	O
ABORTB	O
)	O
input	O
and	O
associated	O
vector	O
supports	O
processor	O
repairs	O
of	O
bus	O
error	O
conditions	O
,	O
such	O
as	O
page	B-General_Concept
faults	I-General_Concept
and	O
memory	O
access	O
violations	O
.	O
</s>
<s>
Direct	O
Page	O
register	B-General_Concept
and	O
stack	B-Application
relative	O
addressing	O
provides	O
capability	O
for	O
reentrant	B-Operating_System
,	O
recursive	O
and	O
re-locatable	B-Library
programming	O
.	O
</s>
<s>
24	O
addressing	O
modes13	O
original	O
6502	B-General_Concept
modes	O
with	O
92	O
instructions	B-General_Concept
using	O
256	O
op	B-Language
codes	I-Language
,	O
including	O
most	O
new	O
opcodes	B-Language
implemented	O
in	O
the	O
65C02	B-General_Concept
.	O
</s>
<s>
Block-copy	O
instructions	B-General_Concept
,	O
allowing	O
rapid	O
copying	O
of	O
data	O
structures	O
from	O
one	O
area	O
of	O
RAM	B-Architecture
to	O
another	O
with	O
minimal	O
code	O
.	O
</s>
<s>
Wait-for-Interrupt	O
(	O
WAI	O
)	O
and	O
Stop-the-Clock	O
(	O
STP	O
)	O
instructions	B-General_Concept
further	O
reduce	O
power	O
consumption	O
,	O
decrease	O
interrupt	B-General_Concept
latency	I-General_Concept
and	O
allow	O
synchronization	O
with	O
external	O
events	O
.	O
</s>
<s>
Co-Processor	B-General_Concept
(	O
COP	O
)	O
instruction	O
with	O
associated	O
vector	O
supports	O
co-processor	B-General_Concept
configurations	O
,	O
e.g.	O
,	O
floating	B-General_Concept
point	I-General_Concept
processors	I-General_Concept
.	O
</s>
<s>
Reserved	O
"	O
escape	O
"	O
(	O
WDM	O
)	O
instruction	O
for	O
future	O
two-byte	O
opcodes	B-Language
and	O
a	B-General_Concept
link	O
to	O
future	O
designs	O
(	O
WDM	O
are	O
the	O
initials	O
of	O
W65C816S	B-General_Concept
designer	O
William	O
D	O
.	O
Mensch	O
)	O
.	O
</s>
<s>
The	O
65C816	B-General_Concept
has	O
two	O
operating	O
modes	O
:	O
"	O
emulation	B-Application
mode	O
"	O
,	O
in	O
which	O
the	O
16-bit	B-Device
operations	O
are	O
invisible	O
—	O
the	O
index	B-General_Concept
registers	I-General_Concept
are	O
forced	O
to	O
eight	O
bits	O
—	O
and	O
the	O
chip	O
appears	O
to	O
be	O
very	O
similar	O
to	O
the	O
6502	B-General_Concept
,	O
with	O
the	O
same	O
cycle	O
timings	O
for	O
the	O
opcodes	B-Language
;	O
and	O
"	O
native	O
mode	O
"	O
,	O
which	O
exposes	O
all	O
new	O
features	O
.	O
</s>
<s>
The	O
CPU	O
automatically	O
enters	O
emulation	B-Application
mode	O
when	O
it	O
is	O
powered	O
on	O
or	O
reset	B-General_Concept
,	O
which	O
allows	O
it	O
to	O
replace	O
a	B-General_Concept
65(C )	O
02	O
,	O
assuming	O
one	O
makes	O
the	O
required	O
circuit	O
changes	O
to	O
accommodate	O
the	O
different	O
pin	O
layout	O
.	O
</s>
<s>
The	O
most	O
obvious	O
change	O
to	O
the	O
65C816	B-General_Concept
when	O
running	O
in	O
native	O
mode	O
is	O
the	O
expansion	O
of	O
the	O
various	O
registers	O
from	O
8-bit	O
to	O
16-bit	B-Device
sizes	O
.	O
</s>
<s>
This	O
enhancement	O
affects	O
the	O
accumulator	B-General_Concept
(	O
A	B-General_Concept
)	O
,	O
the	O
X	O
and	O
Y	O
index	B-General_Concept
registers	I-General_Concept
,	O
and	O
the	O
stack	B-Application
pointer	I-Application
(	O
S	O
)	O
.	O
</s>
<s>
It	O
does	O
not	O
affect	O
the	O
program	B-General_Concept
counter	I-General_Concept
(	O
PC	O
)	O
,	O
which	O
has	O
always	O
been	O
16-bit	B-Device
.	O
</s>
<s>
When	O
running	O
in	O
native	O
mode	O
,	O
two	O
bits	O
in	O
the	O
status	B-General_Concept
register	I-General_Concept
change	O
their	O
meaning	O
.	O
</s>
<s>
In	O
the	O
original	O
6502	B-General_Concept
,	O
bits	O
4	O
and	O
5	O
were	O
not	O
used	O
,	O
although	O
bit	O
4	O
is	O
referred	O
to	O
as	O
the	O
break	O
(	O
b	O
)	O
flag	O
.	O
</s>
<s>
These	O
bits	O
control	O
whether	O
or	O
not	O
the	O
index	B-General_Concept
registers	I-General_Concept
(	O
x	O
)	O
and/or	O
accumulator/memory	O
(	O
m	O
)	O
are	O
8-bit	O
or	O
16-bit	B-Device
in	O
size	O
.	O
</s>
<s>
Zeros	O
in	O
these	O
bits	O
set	O
16-bit	B-Device
sizes	O
,	O
ones	O
set	O
8-bit	O
sizes	O
.	O
</s>
<s>
These	O
bits	O
are	O
fixed	O
at	O
ones	O
when	O
the	O
processor	O
is	O
powered	O
on	O
or	O
reset	B-General_Concept
,	O
but	O
become	O
changeable	O
when	O
the	O
processor	O
is	O
switched	O
to	O
native	O
mode	O
.	O
</s>
<s>
It	O
might	O
not	O
be	O
immediately	O
obvious	O
why	O
one	O
would	O
want	O
to	O
use	O
the	O
now	O
16-bit	B-Device
registers	O
in	O
8-bit	O
mode	O
.	O
</s>
<s>
Switching	O
to	O
8-bit	O
mode	O
using	O
the	O
new	O
SEP	O
(	O
SEt	O
Processor	O
status	O
bit	O
)	O
and	O
REP	O
(	O
REset	B-General_Concept
Processor	O
status	O
bit	O
)	O
instructions	B-General_Concept
means	O
that	O
all	O
subsequent	O
instructions	B-General_Concept
accessing	O
those	O
registers	O
will	O
only	O
read	O
or	O
write	O
a	B-General_Concept
single	O
byte	O
instead	O
of	O
two	O
.	O
</s>
<s>
For	O
instance	O
,	O
if	O
the	O
m	O
bit	O
is	O
set	O
to	O
1	O
when	O
an	O
LDA	O
$1234	O
instruction	O
is	O
executed	O
,	O
only	O
a	B-General_Concept
single	O
byte	O
at	O
address	O
$1234	O
will	O
be	O
read	O
,	O
thereby	O
reducing	O
the	O
number	O
of	O
cycles	O
needed	O
to	O
execute	O
the	O
instruction	O
.	O
</s>
<s>
When	O
register	B-General_Concept
sizes	O
are	O
set	O
to	O
16	B-Device
bits	I-Device
,	O
memory	O
access	O
will	O
access	O
two	O
contiguous	O
bytes	O
of	O
memory	O
,	O
at	O
the	O
cost	O
of	O
one	O
extra	O
clock	O
cycle	O
.	O
</s>
<s>
Furthermore	O
,	O
a	B-General_Concept
read-modify-write	O
instruction	O
,	O
such	O
as	O
ROR	O
<addr>	O
,	O
when	O
used	O
while	O
the	O
accumulator	B-General_Concept
is	O
set	O
to	O
16	B-Device
bits	I-Device
,	O
will	O
affect	O
two	O
contiguous	O
bytes	O
of	O
memory	O
,	O
not	O
one	O
.	O
</s>
<s>
Similarly	O
,	O
all	O
arithmetic	O
and	O
logical	O
operations	O
will	O
be	O
16-bit	B-Device
operations	O
.	O
</s>
<s>
The	O
other	O
major	O
change	O
to	O
the	O
system	O
while	O
running	O
in	O
native	O
mode	O
is	O
that	O
the	O
memory	O
model	O
is	O
expanded	O
to	O
a	B-General_Concept
24-bit	O
format	O
from	O
the	O
original	O
16-bit	B-Device
format	O
of	O
the	O
6502	B-General_Concept
.	O
</s>
<s>
The	O
65c816	B-General_Concept
makes	O
use	O
of	O
two	O
8-bit	O
registers	O
,	O
the	O
data	O
bank	O
register	B-General_Concept
(	O
DB	O
)	O
and	O
the	O
program	O
bank	O
register	B-General_Concept
(	O
PB	O
)	O
,	O
to	O
set	O
bits	O
16-23	O
of	O
the	O
address	O
,	O
effectively	O
generating	O
24-bit	O
addresses	O
.	O
</s>
<s>
In	O
both	O
cases	O
,	O
'	O
bank	O
 '	O
refers	O
to	O
a	B-General_Concept
contiguous	O
64KB	O
segment	O
of	O
memory	O
that	O
is	O
bounded	O
by	O
the	O
address	O
range	O
$	O
xx0000-	O
$xxFFFF	O
,	O
where	O
xx	O
is	O
the	O
bank	O
address	O
,	O
that	O
is	O
,	O
bits	O
16-23	O
of	O
the	O
effective	B-Language
address	I-Language
.	O
</s>
<s>
Both	O
DB	O
and	O
PB	O
are	O
initialized	O
to	O
$00	O
at	O
power-on	O
or	O
reset	B-General_Concept
.	O
</s>
<s>
During	O
an	O
opcode	B-Language
or	O
operand	O
fetch	O
cycle	O
,	O
PB	O
is	O
prepended	O
to	O
the	O
program	B-General_Concept
counter	I-General_Concept
(	O
PC	O
)	O
to	O
form	O
the	O
24-bit	O
effective	B-Language
address	I-Language
.	O
</s>
<s>
Hence	O
a	B-General_Concept
program	O
is	O
bounded	O
by	O
the	O
limits	O
of	O
the	O
bank	O
in	O
which	O
it	O
is	O
executing	O
.	O
</s>
<s>
During	O
a	B-General_Concept
data	O
fetch	O
or	O
store	O
cycle	O
,	O
DB	O
is	O
prepended	O
to	O
a	B-General_Concept
16-bit	B-Device
data	O
address	O
to	O
form	O
the	O
24-bit	O
effective	B-Language
address	I-Language
at	O
which	O
data	O
will	O
be	O
accessed	O
.	O
</s>
<s>
This	O
processor	O
characteristic	O
makes	O
it	O
possible	O
to	O
sanely	O
execute	O
6502	B-General_Concept
or	O
65c02	B-General_Concept
code	O
that	O
uses	O
16-bit	B-Device
addresses	O
to	O
reference	O
data	O
elements	O
.	O
</s>
<s>
Unlike	O
PB	O
,	O
DB	O
can	O
be	O
changed	O
under	O
program	O
control	O
,	O
something	O
that	O
might	O
be	O
done	O
to	O
access	O
data	O
beyond	O
the	O
limits	O
of	O
16-bit	B-Device
addressing	O
.	O
</s>
<s>
DB	O
is	O
ignored	O
if	O
a	B-General_Concept
24-bit	O
address	O
is	O
specified	O
as	O
the	O
operand	O
to	O
a	B-General_Concept
data	O
fetch/store	O
instruction	O
,	O
or	O
if	O
the	O
effective	B-Language
address	I-Language
is	O
on	O
direct	O
(	O
zero	O
)	O
page	O
or	O
the	O
hardware	O
stack	B-Application
.	O
</s>
<s>
In	O
the	O
latter	O
case	O
,	O
an	O
implied	O
bank	O
$00	O
is	O
used	O
to	O
generate	O
the	O
effective	B-Language
address	I-Language
.	O
</s>
<s>
A	B-General_Concept
further	O
addition	O
to	O
the	O
register	B-General_Concept
set	O
is	O
the	O
16-bit	B-Device
direct	O
page	O
register	B-General_Concept
(	O
D	O
)	O
,	O
which	O
sets	O
the	O
base	O
address	O
for	O
what	O
was	O
formerly	O
called	O
the	O
zero	O
page	O
,	O
but	O
now	O
referred	O
to	O
as	O
direct	O
page	O
.	O
</s>
<s>
Direct	O
page	O
addressing	O
uses	O
an	O
8-bit	O
address	O
,	O
which	O
results	O
in	O
faster	O
access	O
than	O
when	O
a	B-General_Concept
16	O
-	O
or	O
24-bit	O
address	O
is	O
used	O
.	O
</s>
<s>
Also	O
,	O
some	O
addressing	B-Language
modes	I-Language
that	O
offer	O
indirection	O
are	O
only	O
possible	O
on	O
direct	O
page	O
.	O
</s>
<s>
In	O
native	O
mode	O
,	O
the	O
65c816	B-General_Concept
can	O
relocate	O
direct	O
(	O
zero	O
)	O
page	O
anywhere	O
in	O
bank	O
$00	O
(	O
the	O
first	O
64KB	O
of	O
memory	O
)	O
by	O
writing	O
the	O
16-bit	B-Device
starting	O
address	O
into	O
D	O
.	O
There	O
is	O
a	B-General_Concept
one-cycle	O
access	O
penalty	O
if	O
D	O
is	O
not	O
set	O
to	O
an	O
even	O
page	O
boundary	O
.	O
</s>
<s>
The	O
current	O
mode	O
of	O
operation	O
is	O
stored	O
in	O
the	O
emulation	B-Application
(	O
e	O
)	O
bit	O
.	O
</s>
<s>
Having	O
already	O
added	O
the	O
new	O
x	O
and	O
m	O
bits	O
to	O
the	O
previous	O
set	O
of	O
six	O
flags	O
in	O
the	O
status	B-General_Concept
register	I-General_Concept
(	O
P	O
)	O
,	O
there	O
were	O
not	O
enough	O
bits	O
left	O
to	O
hold	O
the	O
new	O
mode	O
bit	O
.	O
</s>
<s>
Instead	O
,	O
a	B-General_Concept
unique	O
solution	O
was	O
used	O
in	O
which	O
the	O
mode	O
bit	O
was	O
left	O
"	O
invisible	O
"	O
,	O
unable	O
to	O
be	O
directly	O
accessed	O
.	O
</s>
<s>
The	O
new	O
XCE	O
(	O
eXchange	O
Carry	O
with	O
Emulation	B-Application
)	O
instruction	O
exchanges	O
the	O
value	O
of	O
the	O
emulation	B-Application
bit	O
with	O
the	O
carry	O
(	O
c	O
)	O
bit	O
,	O
bit	O
0	O
in	O
the	O
status	B-General_Concept
register	I-General_Concept
.	O
</s>
<s>
For	O
instance	O
,	O
if	O
one	O
wants	O
to	O
enter	O
native	O
mode	O
after	O
the	O
processor	O
has	O
started	O
up	O
,	O
one	O
would	O
use	O
CLC	O
to	O
clear	O
the	O
carry	O
bit	O
,	O
and	O
then	O
XCE	O
to	O
write	O
it	O
to	O
the	O
emulation	B-Application
bit	O
.	O
</s>
<s>
Returning	O
to	O
65c02	B-General_Concept
emulation	B-Application
mode	O
uses	O
SEC	O
followed	O
by	O
XCE	O
.	O
</s>
<s>
Internally	O
,	O
the	O
65c816	B-General_Concept
is	O
a	B-General_Concept
fully	O
16-bit	B-Device
design	O
.	O
</s>
<s>
The	O
m	O
and	O
x	O
bits	O
in	O
P	O
determine	O
how	O
the	O
user	O
registers	O
(	O
accumulator	B-General_Concept
and	O
index	O
)	O
appear	O
to	O
the	O
rest	O
of	O
the	O
system	O
.	O
</s>
<s>
Upon	O
reset	B-General_Concept
,	O
the	O
65c816	B-General_Concept
starts	O
in	O
6502	B-General_Concept
emulation	B-Application
mode	O
,	O
in	O
which	O
m	O
and	O
x	O
are	O
set	O
to	O
1	O
and	O
cannot	O
be	O
changed	O
.	O
</s>
<s>
The	O
most	O
significant	O
byte	O
(	O
MSB	O
)	O
of	O
the	O
accumulator	B-General_Concept
(	O
the	O
B-accumulator	O
)	O
is	O
not	O
directly	O
accessible	O
but	O
can	O
be	O
swapped	O
with	O
the	O
least	O
significant	O
byte	O
(	O
LSB	O
)	O
of	O
the	O
accumulator	B-General_Concept
(	O
the	O
A-accumulator	O
)	O
by	O
using	O
the	O
XBA	O
instruction	O
.	O
</s>
<s>
There	O
is	O
no	O
corresponding	O
operation	O
for	O
the	O
index	B-General_Concept
registers	I-General_Concept
(	O
X	O
and	O
Y	O
)	O
.	O
</s>
<s>
Upon	O
being	O
switched	O
to	O
native	O
mode	O
,	O
the	O
MSB	O
of	O
X	O
and	O
Y	O
will	O
be	O
zero	O
,	O
and	O
the	O
B-accumulator	O
will	O
be	O
unchanged	O
.	O
</s>
<s>
If	O
the	O
m	O
bit	O
in	O
P	O
is	O
cleared	O
,	O
the	O
B-accumulator	O
is	O
"	O
ganged	O
"	O
to	O
the	O
A-accumulator	O
to	O
form	O
a	B-General_Concept
16-bit	B-Device
register	B-General_Concept
(	O
called	O
the	O
C-accumulator	O
)	O
.	O
</s>
<s>
A	B-General_Concept
load/store	O
or	O
arithmetic/logical	O
operation	O
involving	O
the	O
accumulator	B-General_Concept
and/or	O
memory	O
will	O
be	O
a	B-General_Concept
16-bit	B-Device
operation	O
—	O
two	O
bus	O
cycles	O
are	O
required	O
to	O
fetch/store	O
a	B-General_Concept
16-bit	B-Device
value	O
.	O
</s>
<s>
If	O
the	O
x	O
bit	O
in	O
P	O
is	O
cleared	O
,	O
both	O
index	B-General_Concept
registers	I-General_Concept
will	O
be	O
set	O
to	O
16	B-Device
bits	I-Device
.	O
</s>
<s>
If	O
used	O
to	O
index	O
an	O
address	O
,	O
e.g.	O
,	O
LDA	O
SOMEWHERE	O
,	O
X	O
,	O
the	O
16-bit	B-Device
value	O
in	O
the	O
index	B-General_Concept
register	I-General_Concept
will	O
be	O
added	O
to	O
the	O
base	O
address	O
to	O
form	O
the	O
effective	B-Language
address	I-Language
.	O
</s>
<s>
If	O
the	O
m	O
bit	O
in	O
P	O
is	O
set	O
the	O
accumulator	B-General_Concept
will	O
return	O
to	O
being	O
an	O
8-bit	O
register	B-General_Concept
and	O
subsequent	O
operations	O
on	O
the	O
accumulator	B-General_Concept
,	O
with	O
a	B-General_Concept
few	O
exceptions	O
,	O
will	O
be	O
8-bit	O
operations	O
.	O
</s>
<s>
The	O
B-accumulator	O
will	O
retain	O
the	O
value	O
it	O
had	O
when	O
the	O
accumulator	B-General_Concept
was	O
operating	O
in	O
16-bit	B-Device
mode	O
.	O
</s>
<s>
The	O
exceptions	O
are	O
the	O
instructions	B-General_Concept
that	O
transfer	O
the	O
direct	O
page	O
register	B-General_Concept
(	O
D	O
)	O
and	O
stack	B-Application
pointer	I-Application
(	O
S	O
)	O
to/from	O
the	O
accumulator	B-General_Concept
.	O
</s>
<s>
These	O
operations	O
are	O
always	O
16	B-Device
bits	I-Device
wide	O
in	O
native	O
mode	O
,	O
regardless	O
of	O
the	O
condition	O
of	O
the	O
m	O
bit	O
in	O
the	O
status	B-General_Concept
register	I-General_Concept
.	O
</s>
<s>
If	O
the	O
x	O
bit	O
in	O
P	O
is	O
set	O
,	O
not	O
only	O
will	O
the	O
index	B-General_Concept
registers	I-General_Concept
return	O
to	O
being	O
8	O
bits	O
,	O
whatever	O
was	O
in	O
the	O
MSB	O
while	O
in	O
16-bit	B-Device
mode	O
will	O
be	O
lost	O
,	O
something	O
an	O
assembly	O
language	O
programmer	O
cannot	O
afford	O
to	O
forget	O
.	O
</s>
<s>
Systems	O
based	O
on	O
65c816	B-General_Concept
variants	O
:	O
</s>
<s>
Super	B-Application
Nintendo	I-Application
Entertainment	I-Application
System	I-Application
:	O
the	O
console	B-Device
's	O
Ricoh	B-General_Concept
5A22	I-General_Concept
CPU	O
is	O
based	O
on	O
the	O
65c816	B-General_Concept
.	O
</s>
<s>
Additionally	O
,	O
30+	O
Super	B-Application
NES	I-Application
games	O
include	O
the	O
Nintendo	B-General_Concept
SA1	I-General_Concept
,	O
a	B-General_Concept
65c816-based	O
co-processor	B-General_Concept
chip	O
,	O
in	O
each	O
cartridge	O
.	O
</s>
