| Related sites for http://www.byte.com/art/9711/sec4/art4.htm |
| Systems_Solution_Inc Apple Mac and PC systems specialist in Philadelphia, PA area. | | Bombyx Bombyx is a graphical client for SILC (Secure Internet Live Conferencing). It is written in C++ and uses FLTK as the widget set, plus a few other libraries. | | Restored_whwan_com Project to scan old 8-bit magazines like Zzap!64 and Commodore User and distribute them via BitTorrent. | | Steven_L__Adams Satellite image overlay test using SOPack plugin. | | Gleason_Research An authorized seller of the MIT Handyboard and the smaller Handy Cricket. They also offer a variety of other robot components. | | David_Pilling David Pilling's software, including SparkFS, ArcFax fax modem software, TWAIN drivers, and ImageMaster. | | RFC_1312 Message Send Protocol 2. R. Nelson, G. Arnold. April 1992. | | Gholami,_Omid_-_Omid_G_L_ Personal information, projects and programs, downloads and sourcecodes, | | JSpamFilter JSpamFilter is Java-based, performs both source and content filtering, and provides a variety of treatment options. It is high-performance and highly customizable. [Java] | | Motion_Controls_Robotics A level 4 servicing integrator that offers full service robotic solutions from concept to installation as well as service and support. | | Soft_Plan_User_Group Resource site about SoftPlan, with membership information, a gallery, forums, chat, and classified ads. | | Chris_Bregler\'s_home_page Research and recent papers on video-based capture of human movements. The main applications are feature animation, video games, and analyzing Movement Disorder | | Nakencow A chatclient and several remakes of classic games. | | RFC_1916 Enterprise Renumbering: Experience and Information Solicitation. H. Berkowitz, P. Ferguson, W. Leland, P. Nesser. February 1996. | | RFC_0291 Data Management Meeting Announcement. D.B. McKay. January 1972. | | Yahoo_Groups__Corel-Beginners A list that will answer basic questions for the beginner users of Corel Draw and Corel Photo Paint. | | pgLOGd Takes web server log entries and sends them to a database, originally designed for PostgreSQL. BSD Open Source License. | | Ink2Art Specializing in small business and personal websites. Offering optional hosting. Based in Wisconsin, United States. | | Baldwin_Web_Design Services include site development, custom graphics, scripting, Flash, database, multimedia presentations, and hosting packages. | | More_Neo_Graphics A site with backgrounds, adoptables, banners, user lookups and also offers help, tips and a color chart. |
|
BYTE.com
Archives
Columns
Features
Print Archives
1994-1998
Special
BYTE Digest
Michael Abrash's Graphics Programming Black Book
101 Perl Articles
About Us
How to Access BYTE.com
Write to BYTE.com
Advertise with BYTE.com
Newsletter
Free E-mail Newsletter from BYTE.com
Jump to...
Columns:
Advanced Software and Technologies
BYTE Media Lab
Chaos Manor
Conference Reports
Features
Free Features
Gigglebytes
Letters to BYTE.com
Mr. Computer Language Person
New Products
Op/Ed
Portable Computing
Serving with Linux
The Upgrade Advisor
HOME
ABOUT US
ARCHIVES
CONTACT US
ADVERTISE
REGISTER
    Building the Virtual PCNovember 1997 / Core Technologies / Building the Virtual PCA software emulator shows that the PowerPC can emulate another computer, down to its very hardware.Eric TrautDevelopment of Virtual PC -- Connectix Corporation's Macintosh application that emulates a PC and its peripherals -- began almost two years ago, in October 1995. The goal from the beginning was to create a fully Intel-compatible PC in software. The effort centered around a core Pentium instruction-set emulator, complete with MMX instructions. True PC emulation also required the reverse-engineering and development of a dozen other PC motherboard devices, including modern peripherals such as an accelerated SVGA card, an Ethernet controller, a Sound Blaster Pro sound card, IDE/ATAPI controller, and PCI bridge interface. This strategy of hardware-level emulation resulted in an application that allows Macintosh users to run not only Windows programs and DOS games but several x86-based OSes, including Windows 95, NT, and NeXT OpenStep.Pentium EmulationThe heart of Virtual PC is the Pentium recompiling emulator, a sophisticated piece of software written entirely in hand-coded PowerPC assembly language. Its job is to translate Pentium instruction sequences into a set of optimized PowerPC instructions that perform the same operation. Translation occurs on a "basic-block" basis, where a basic block consists of a sequence of decoded x86 instructions. Basic blocks end on an instruction that abruptly changes the flow of execution (typically a jump, call, or return-from-subroutine instruction). As the recompiler decodes x86 instructions, it analyzes them for "condition code" usage. Finally, it generates a block of PowerPC code that accomplishes the same task. For more details on this process, see "Virtual PC Operation". For purposes of speeding things up, the emulator employs the following tricks. Translation cache: Even though written in PowerPC assembly language, the translator still requires substantial time to generate optimized instruction translations. To reduce this overhead, the emulator caches blocks of translated code. Interinstruction optimization: Because the Pentium is a CISC processor, most instructions perform more than one operation. For example, the ADD instruction not only adds two values together, it also produces a number of condition- code flags that tell programs whether the addition produced a zero or negative result. Such codes are used, for example, to determine if a program performs a conditional jump. Most of the time these codes are ignored. The translator analyzes blocks of x86 instructions to determine which flags the program uses (if any). It then generates PowerPC code for those flags actually used. The first two listings in "Translated Code" show how one Pentium instruction translates into three PowerPC instructions, while three Pentium instructions can be optimized from nine into five PowerPC instructions. Address translation: One of the most difficult Pentium features to emulate is its built-in memory management unit (MMU). This hardware translates linear (or logical) addresses into physical memory addresses. Operating systems use the MMU to implement virtual memory and memory protection. Because of the Pentium's small register file, about three in four Pentium instructions reference memory in one way or another. Each memory address potentially needs to be translated before the emulator loads from, or stores to, the referenced address. An MMU implemented in software would impose a high overhead, which would degrade performance. Luckily, this overhead can be avoided: The Connectix engineers were able to program the PowerPC's MMU to mimic the Pentium MMU's behavior, thus managing the address translations in hardware. The Pentium's memory page attributes can also be mirrored in the PowerPC's MMU. For example, if Virtual PC's emulated OS marks a memory page as write-protected, the page mappings are modified so the corresponding PowerPC page is write-protected. Segment bounds checking: The Pentium architecture includes the archaic notion of memory segments. Every memory reference, such as instruction fetches, stack operations, loads, and stores, has an associated memory segment. When a segment's bounds are exceeded, the Pentium's MMU generates a general protection fault (GPF). The OS uses GPFs for more than detecting bugs in applications: They enable a program to "thunk" down into privileged driver-level code not accessible at the application level. Therefore, the Pentium emulator must detect segment bound faults where appropriate. Although the PowerPC does not contain segmentation hardware akin to the Pentium, Connectix used PowerPC trap instructions to perform segment bounds checks with little or no overhead.Hardware EmulationBesides the Pentium processor, a typical PC motherboard contains a dozen or so chips that work together concurrently. All these chips need to be emulated faithfully for compatibility. The Intel architecture provides an I/O address space that's used to access hardware outside of the CPU. You work with this "I/O space" through two instructions -- IN and OUT. When using these instructions, software must specify an I/O port (or address). Virtual PC routes I/O accesses to code modules that emulate each chip. For example, if Virtual PC encounters an IN instruction referencing port 0x21, it calls a routine in the interrupt-controller emulation module that returns the current interrupt mask. Similar module calls occur for every I/O space access, as the third listing in "Translated Code" shows. Many of the extra chips on a PC motherboard control I/O devices such as the hard drive, CD-ROM, keyboard, and mouse. For compatibility with the Mac OS and all Macintosh hardware, Virtual PC performs all I/O through the standard Mac OS drivers. So, a request sent to the emulated PC's IDE controller to read a sector from the hard drive gets translated into a read operation that's sent to the Mac OS SCSI driver. The most difficult hardware components to emulate involve precise timing. For example, sound is a real-time operation, and any timing perturbation results in clicks or pops as digitally sampled data fails to arrive on time. Because Virtual PC is hosted on the Mac OS (which gives time to other Mac programs running concurrently, as well as Virtual PC), and it needs to emulate several dozen PC chips in parallel, precise timing isn't always possible. Virtual PC compensates by placing the highest priority on tasks that directly affect the user, such as sound and video.PerformanceEmulated systems are naturally going to be slower than real hardware. But Connectix engineers concentrated on tuning aspects of the emulated hardware required to run popular PC games and productivity applications at a usable performance level. This was especially challenging given that the PowerPC processor emulates not only the Pentium but all the other chips on a PC motherboard. Performance of Virtual PC is also greatly affected by the host hardware system. The latest PowerPC processors with high clock rates and large on-chip caches will run it best. The speed and size of the system's L2 cache is also critical because of the code expansion that occurs during the translation process. While users will take a performance hit because this is an emulator, Virtual PC successfully emulates the entire PC at a very low level. PC programs -- applications, device drivers, and operating systems alike -- cannot tell they are not running on actual PC hardware.Translated CodeTranslation of Single Pentium InstructionPentium instruction PowerPC instructionsADD EAX,20 li rTemp1,20 addco. PF,rTemp1,rEAX mr rEAX,rPFTranslation of Pentium Instruction BlockPentium instructions PowerPC instructionsADD EAX,20 add rEAX,rEAX,20ADD EBX,30 add rEBX,rEBX,30ADD ECX,40 li rTemp1,40 addco. rPF,rTemp1,rECX mr rECX,rPFCode Translation for Pentium I/O InstructionsPentium instructions PowerPC instructionsMOV AL,8 li rAL,8MOV DX,0x1F0 li rDX,0x1F0OUT DX,AL bl HandleIDEPortWriteADD DX,7 addi rDX,rDX,7IN AL,DX bl HandleIDEPortReadRET addi rIP,rIP,8 b DispatchToNextBlockVirtual PC Operationillustration_link (24 Kbytes) Eric Traut (traut@connectix.com) is lead engineer for Virtual PC at Connectix. At Apple Computer, he wrote the 680x0 dynamic recompiling emulator for PowerPC-based Macs. 
Flexible C++
Matthew Wilson
My approach to software engineering is far more pragmatic than it
is
theoretical--and no language better exemplifies this than C++.
more...
BYTE Digest
BYTE Digest editors every month analyze and evaluate the best articles from Information Week, EE Times, Dr. Dobb's Journal, Network Computing, Sys Admin,
and dozens of other CMP publications—bringing
you critical news and information about wireless communication,
computer security, software development, embedded systems,
and more!
Find out more
BYTE.com Store
BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than
8 years of BYTE.
The Best of BYTE
Volume 1: Programming Languages
In this issue of Best of BYTE, we bring together some of the leading programming language designers and implementors...
Copyright © 2005 CMP Media LLC,
Privacy Policy,
Your California Privacy rights,
Terms of Service
Site comments:
webmaster@byte.com
SDMG Web Sites:
BYTE.com,
C/C++ Users Journal,
Dr. Dobb's Journal,
MSDN Magazine,
New Architect,
SD Expo,
SD Magazine,
Sys Admin,
The Perl Journal,
UnixReview.com,
Windows Developer Network
|
|