Mac 68K emulator
Encyclopedia
The Mac 68K emulator was a software emulator
Emulator
In computing, an emulator is hardware or software or both that duplicates the functions of a first computer system in a different second computer system, so that the behavior of the second system closely resembles the behavior of the first system...

 built into all versions of the Mac OS
Mac OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

 for PowerPC
PowerPC
PowerPC is a RISC architecture created by the 1991 Apple–IBM–Motorola alliance, known as AIM...

. This emulator permitted the running of applications and system code that were originally written for the 680x0 based Macintosh models. The emulator was completely seamless for users, and reasonably seamless for programmer
Programmer
A programmer, computer programmer or coder is someone who writes computer software. The term computer programmer can refer to a specialist in one area of computer programming or to a generalist who writes code for many kinds of software. One who practices or professes a formal approach to...

s. It is thought that this aspect of the Mac OS is the first time that such a dual hardware architecture operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

 had ever been successfully implemented.

Origins

The first version was written by Gary Davidian, who had originally created it for use on the Motorola 88000
Motorola 88000
The 88000 is a RISC instruction set architecture developed by Motorola. The 88000 was Motorola's attempt at a home-grown RISC architecture, started in the 1980s. The 88000 arrived on the market some two years after the competing SPARC and MIPS...

 CPU, used in Apple's abortive first attempt at a RISC target platform. A later version, using dynamic recompilation
Dynamic recompilation
In computer science, dynamic recompilation is a feature of some emulators and virtual machines, where the system may recompile some part of a program during execution...

, was developed by Eric Traut
Eric Traut
Eric Traut is an American software engineer and software emulation pioneer. Traut graduated from Stanford University in 1992. From 1993 to 1995 he worked for Apple Computer, creating a Mac 68K emulator to be used in PowerPC-based Macintoshes...

, who later worked on successful emulation projects at Connectix
Connectix
Connectix Corporation was a software and hardware company, noted for having released innovative products that were either made obsolete as Apple Computer incorporated the ideas into system software, or were sold to other companies once they become popular...

 such as Speed Doubler (which included an even faster PowerPC 68k emulator), Virtual Game Station, and Virtual PC.

Implementation

All versions of this emulator emulated the "user" subset of the 68EC040 instruction set
Instruction set
An instruction set, or instruction set architecture , is the part of the computer architecture related to programming, including the native data types, instructions, registers, addressing modes, memory architecture, interrupt and exception handling, and external I/O...

 with a 68020/68030 exception
Exception handling
Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....

 stack frame. Apple developer documents indicate that the emulator provided an operating environment most closely resembling that of the Macintosh Centris 610, a system based on the Motorola 68LC040 microprocessor. Early versions emulated it by decoding each instruction and immediately carrying out a series of equivalent PowerPC instructions. For the PCI PowerMacs
Power Macintosh
Power Macintosh, later Power Mac, was a line of Apple Macintosh workstation-class personal computers based on various models of PowerPC microprocessors that were developed, marketed, and supported by Apple Inc. from March 1994 until August 2006. The first models were the Power Macintosh 6100,...

, the dynamic recompilation
Dynamic recompilation
In computer science, dynamic recompilation is a feature of some emulators and virtual machines, where the system may recompile some part of a program during execution...

 emulator was used to boost performance. Dynamic recompilation works by "recompiling" common sections of the code into faster, PowerPC-native, sequences that were locally cached. The emulator could recognise the same sequence of 680x0 code and run the previously-cached PowerPC code to avoid doing the translation again. This emulator was theoretically capable of emulating 680x0 code faster than any real 680x0 was capable of running it. The 68LC040 had no floating point instructions, making this feat slightly simpler but no less impressive.

One reason that this emulation was so successful is that many of the APIs for the Mac OS were originally implemented as traps
Trap (computing)
In computing and operating systems, a trap, also known as an exception or a fault, is typicallyThere is a wide variation in the nomenclature...

 on the 680x0 processor; therefore, calling an API actually was recognised by the 680x0 as the equivalent of an error condition, which would cause it to handle that error through one of its hardware vectors. In turn, this vector would look up and run the operating system routine from ROM or RAM. In the emulator, such traps could be replaced by native PowerPC code, so the only code being emulated was the application itself, and any system API it called could be accelerated with native PowerPC code. This also allowed Apple time to port
Porting
In computer science, porting is the process of adapting software so that an executable program can be created for a computing environment that is different from the one for which it was originally designed...

 the OS to the PowerPC. At first only time-critical aspects were rewritten in native code, leaving much of the OS emulated. Gradually most of the OS was rewritten to be native, so the OS got faster over time.

For the programmer, the transition to the PowerPC was made fairly painless, because the emulator was started and stopped automatically. This was achieved using a new type of pointer called a Universal Procedure Pointer (UPP). For 68k code, this pointer appeared to be an ordinary pointer to code and could be used as such. However, it actually led to a data structure which contained a special trap instruction and flags indicating the instruction set architecture (ISA)
Instruction set
An instruction set, or instruction set architecture , is the part of the computer architecture related to programming, including the native data types, instructions, registers, addressing modes, memory architecture, interrupt and exception handling, and external I/O...

 of the called code. From PowerPC code, this UPP could be passed to the CallUniversalProc function to call it. The 68k emulator then dealt with details such as presenting passed parameters in the right order for the ISA in question, as well as starting and stopping the emulator as required. The compilers for Mac OS created such UPPs automatically when the proper macros were used, and the PowerPC system libraries contained native stubs to transparently call through to native or still-68k functions as needed. This meant that dealing with the dual architecture required very little work for the programmer, and just like the OS, applications themselves could mix and match 680x0 and PowerPC code fairly easily.

Current status

The emulator is no longer part of Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, though it remains as an integral part of both the Classic environment
Classic (Mac OS X)
Classic, or Classic Environment, was a hardware and software abstraction layer in Mac OS X that allowed applications compatible with Mac OS 9 to run on the Mac OS X operating system...

 and SheepShaver
SheepShaver
SheepShaver is an open source PowerPC Apple Macintosh emulator originally designed for BeOS and Linux. The name is a play on ShapeShifter, a Macintosh II emulator for AmigaOS , which is in turn not to be confused with a third-party preference pane for Mac OS X with the same name...

.

See also

  • Mac OS nanokernel
    Mac OS nanokernel
    Before Mac OS X, PowerPC versions of the Mac OS were based on a nanokernel, or extremely simple operating system kernel. The initial revision of this software is an extremely simple, single tasking system which delegates most tasks to an emulator running the Motorola 68K version of the operating...

  • Alpha Microsystems
    Alpha Microsystems
    Alpha Microsystems is a computer company founded in 1977 by John French, Dick Wilcox and Bob Hitchcock. The first Alpha Micro computer was the S-100 AM-100, based upon the WD16 microprocessor chipset from Western Digital...

     for a similar architecture to run 68K code on x86
  • Rosetta
    Rosetta (software)
    Rosetta was a lightweight and dynamic binary translator for Mac OS X which Apple released in 2006 when it transitioned the Macintosh from PowerPC to Intel processors. It allowed pre-existing software to run on the new systems without modification....

    , a similar feature in Mac OS X that translates PowerPC
    PowerPC
    PowerPC is a RISC architecture created by the 1991 Apple–IBM–Motorola alliance, known as AIM...

     instructions to x86 instructions
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK