<s>
The	O
Mac	B-Device
68k	I-Device
emulator	I-Device
is	O
a	O
software	B-Application
emulator	I-Application
built	O
into	O
all	O
versions	O
of	O
the	O
classic	B-Application
Mac	I-Application
OS	I-Application
for	O
PowerPC	B-Architecture
.	O
</s>
<s>
This	O
emulator	B-Application
enabled	O
running	O
applications	O
and	O
system	O
code	O
that	O
were	O
originally	O
written	O
for	O
the	O
680x0-based	O
Macintosh	B-Device
models	O
.	O
</s>
<s>
With	O
a	O
few	O
exceptions	O
,	O
notably	O
Connectix	O
's	O
RAM	O
Doubler	O
,	O
the	O
emulator	B-Application
ran	O
all	O
software	O
with	O
no	O
noticeable	O
impact	O
other	O
than	O
lower	O
performance	O
relative	O
to	O
the	O
same	O
program	O
when	O
compiled	O
for	O
PowerPC	B-Architecture
.	O
</s>
<s>
The	O
first	O
version	O
was	O
written	O
by	O
Gary	O
Davidian	O
,	O
who	O
had	O
originally	O
created	O
it	O
for	O
use	O
on	O
the	O
Motorola	B-Architecture
88000	I-Architecture
CPU	O
,	O
used	O
in	O
Apple	O
's	O
abortive	O
first	O
attempt	O
at	O
a	O
RISC	B-Architecture
target	O
platform	O
.	O
</s>
<s>
A	O
later	O
version	O
,	O
using	O
dynamic	O
recompilation	O
,	O
was	O
developed	O
by	O
Eric	O
Traut	O
,	O
who	O
later	O
worked	O
on	O
successful	O
emulation	B-Application
projects	O
at	O
Connectix	O
such	O
as	O
Virtual	B-Operating_System
Game	I-Operating_System
Station	I-Operating_System
and	O
Virtual	B-Application
PC	I-Application
.	O
</s>
<s>
Prior	O
to	O
Traut	O
's	O
arrival	O
there	O
,	O
Connectix	O
had	O
released	O
Speed	O
Doubler	O
,	O
which	O
included	O
an	O
even	O
faster	O
PowerPC	B-Architecture
68k	B-Device
emulator	B-Application
.	O
</s>
<s>
All	O
versions	O
of	O
this	O
emulator	B-Application
emulated	B-Application
the	O
"	O
user	O
"	O
subset	O
of	O
the	O
68EC040	O
instruction	B-General_Concept
set	I-General_Concept
with	O
a	O
68020/68030	O
exception	B-General_Concept
stack	O
frame	O
.	O
</s>
<s>
Apple	O
developer	O
documents	O
indicate	O
that	O
the	O
emulator	B-Application
provided	O
an	O
operating	O
environment	O
most	O
closely	O
resembling	O
that	O
of	O
the	O
Macintosh	B-Device
Centris	I-Device
610	I-Device
,	O
a	O
system	O
based	O
on	O
the	O
Motorola	O
68LC040	O
microprocessor	O
.	O
</s>
<s>
Early	O
versions	O
emulated	B-Application
it	O
by	O
decoding	O
each	O
instruction	O
and	O
immediately	O
carrying	O
out	O
a	O
series	O
of	O
equivalent	O
PowerPC	B-Architecture
instructions	O
.	O
</s>
<s>
For	O
the	O
PCI	B-Protocol
PowerMacs	B-Device
,	O
the	O
dynamic	O
recompilation	O
emulator	B-Application
was	O
used	O
to	O
boost	O
performance	O
.	O
</s>
<s>
Dynamic	O
recompilation	O
works	O
by	O
"	O
recompiling	O
"	O
common	O
sections	O
of	O
the	O
code	O
into	O
faster	O
,	O
PowerPC-native	O
,	O
sequences	O
that	O
were	O
locally	O
cached	O
.	O
</s>
<s>
The	O
emulator	B-Application
could	O
recognise	O
the	O
same	O
sequence	O
of	O
680x0	B-Device
code	O
and	O
run	O
the	O
previously-cached	O
PowerPC	B-Architecture
code	O
to	O
avoid	O
doing	O
the	O
translation	O
again	O
.	O
</s>
<s>
This	O
emulator	B-Application
was	O
theoretically	O
capable	O
of	O
emulating	B-Application
680x0	B-Device
code	O
faster	O
than	O
any	O
real	O
680x0	B-Device
was	O
capable	O
of	O
running	O
it	O
.	O
</s>
<s>
One	O
reason	O
that	O
this	O
emulation	B-Application
was	O
so	O
successful	O
is	O
that	O
many	O
of	O
the	O
APIs	B-General_Concept
for	O
the	O
Mac	B-Application
OS	I-Application
were	O
originally	O
implemented	O
as	O
traps	B-Application
on	O
the	O
680x0	B-Device
processor	O
;	O
therefore	O
,	O
calling	O
an	O
API	B-General_Concept
actually	O
was	O
recognised	O
by	O
the	O
680x0	B-Device
as	O
the	O
equivalent	O
of	O
an	O
error	O
condition	O
,	O
which	O
would	O
cause	O
it	O
to	O
handle	O
that	O
error	O
through	O
one	O
of	O
its	O
hardware	O
vectors	O
.	O
</s>
<s>
In	O
the	O
emulator	B-Application
,	O
such	O
traps	B-Application
could	O
be	O
replaced	O
by	O
native	O
PowerPC	B-Architecture
code	O
,	O
so	O
the	O
only	O
code	O
being	O
emulated	B-Application
was	O
the	O
application	O
itself	O
,	O
and	O
any	O
system	O
API	B-General_Concept
it	O
called	O
could	O
be	O
accelerated	O
with	O
native	O
PowerPC	B-Architecture
code	O
.	O
</s>
<s>
This	O
also	O
allowed	O
Apple	O
time	O
to	O
port	O
the	O
OS	O
to	O
the	O
PowerPC	B-Architecture
.	O
</s>
<s>
At	O
first	O
only	O
time-critical	O
aspects	O
were	O
rewritten	O
in	O
native	O
code	O
,	O
leaving	O
much	O
of	O
the	O
OS	O
emulated	B-Application
.	O
</s>
<s>
For	O
the	O
programmer	O
,	O
the	O
transition	O
to	O
the	O
PowerPC	B-Architecture
was	O
made	O
fairly	O
painless	O
,	O
because	O
the	O
emulator	B-Application
was	O
started	O
and	O
stopped	O
automatically	O
.	O
</s>
<s>
For	O
68k	B-Device
code	O
,	O
this	O
pointer	O
appeared	O
to	O
be	O
an	O
ordinary	O
pointer	O
to	O
code	O
and	O
could	O
be	O
used	O
as	O
such	O
.	O
</s>
<s>
However	O
,	O
it	O
actually	O
led	O
to	O
a	O
data	O
structure	O
which	O
contained	O
a	O
special	O
trap	B-Application
instruction	O
and	O
flags	O
indicating	O
the	O
instruction	B-General_Concept
set	I-General_Concept
architecture	I-General_Concept
(	O
ISA	O
)	O
of	O
the	O
called	O
code	O
.	O
</s>
<s>
From	O
PowerPC	B-Architecture
code	O
,	O
this	O
UPP	O
could	O
be	O
passed	O
to	O
the	O
CallUniversalProc( )	O
function	O
to	O
call	O
it	O
.	O
</s>
<s>
The	O
68k	B-Device
emulator	B-Application
then	O
dealt	O
with	O
details	O
such	O
as	O
presenting	O
passed	O
parameters	O
in	O
the	O
right	O
order	O
for	O
the	O
ISA	O
in	O
question	O
,	O
as	O
well	O
as	O
starting	O
and	O
stopping	O
the	O
emulator	B-Application
as	O
required	O
.	O
</s>
<s>
The	O
compilers	O
for	O
Mac	B-Application
OS	I-Application
created	O
such	O
UPPs	O
automatically	O
when	O
the	O
proper	O
macros	O
were	O
used	O
,	O
and	O
the	O
PowerPC	B-Architecture
system	O
libraries	O
contained	O
native	O
stubs	O
to	O
transparently	O
call	O
through	O
to	O
native	O
or	O
still-68k	O
functions	O
as	O
needed	O
.	O
</s>
<s>
This	O
meant	O
that	O
dealing	O
with	O
the	O
dual	O
architecture	O
required	O
very	O
little	O
work	O
for	O
the	O
programmer	O
,	O
and	O
just	O
like	O
the	O
OS	O
,	O
applications	O
themselves	O
could	O
mix	O
and	O
match	O
680x0	B-Device
and	O
PowerPC	B-Architecture
code	O
fairly	O
easily	O
.	O
</s>
<s>
Because	O
it	O
was	O
built	O
into	O
all	O
PowerPC	B-Architecture
versions	O
of	O
the	O
classic	B-Application
Mac	I-Application
OS	I-Application
,	O
the	O
emulator	B-Application
was	O
also	O
part	O
of	O
the	O
Classic	O
environment	O
in	O
Mac	B-Operating_System
OS	I-Operating_System
X	I-Operating_System
.	O
PowerPC	B-Architecture
Macintosh	B-Device
emulators	B-Application
such	O
as	O
SheepShaver	B-Application
therefore	O
use	O
the	O
emulator	B-Application
as	O
well	O
when	O
running	O
the	O
classic	B-Application
Mac	I-Application
OS	I-Application
.	O
</s>
<s>
Native	O
Mac	B-Operating_System
OS	I-Operating_System
X	I-Operating_System
outside	O
of	O
Classic	O
never	O
used	O
the	O
emulator	B-Application
.	O
</s>
