From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10f8a1,d690d6329d9c19b2,start X-Google-Attributes: gid10f8a1,public X-Google-Thread: 10cbb9,d690d6329d9c19b2,start X-Google-Attributes: gid10cbb9,public X-Google-Thread: 1164f8,d690d6329d9c19b2,start X-Google-Attributes: gid1164f8,public X-Google-Thread: 102591,71125f6769da70ae X-Google-Attributes: gid102591,public From: bayko@pollux.cs.uregina.ca (John Bayko) Subject: Re: Legacy CPU emulators Date: 1998/01/11 Message-ID: <69b85c$g98$1@sue.cc.uregina.ca>#1/1 X-Deja-AN: 315022325 References: <34b11d3c.165187@news.prestel.co.uk> <34b33ae7.150367@news.prestel.co.uk> <34B8E81A.8B0C17A9@compuserve.com> Organization: University of Regina, Dept. of Computer Science Newsgroups: comp.sys.amiga.advocacy,comp.sys.mac.advocacy,vmsnet.alpha,comp.sys.dec In article <34B8E81A.8B0C17A9@compuserve.com>, Ed Dana II wrote: [...] >I assume that these emulators operate by taking the original machine co >de and translating it to native >machine code. This makes it a machine code interpreter. Is it possible >for such a legacy emulator to >compile this code rather than interpret it? > >It would be nice, naturally, not only to have your legacy applications, > but to have it operating at >speeds comparable to your current CPU. > >I assume that this has not been done, and for practical reasons. It is done, just not very widely. There are two strategies for this, called just-in-time (JIT) recompiling and binary translation. Apple's PowerPC emulation of the 68040 uses JIT to translate segments of 68040 code to PowerPC code as it encounters it. The payoff to doing this is in loops, where a block of code is executed over and over. I believe that DEC also has a product to do this so you can run x86 binaries on an Alpha under NT. Some Java Virtual Machines also do this, translating Java Bytecode to the native instruction set. The IBM AS/400 uses binary translation, I believe. Programs written for an abstract machine are translated to the native CPU when they are run for the first time, and saved for future use. This allowed IBM to switch AS/400 systems to PowerPC CPUs without any compatibility problems, and increased performance. DEC also used binary translation to convert old VAX VMS programs to OpenVMS on Alpha CPUs. The factors which make binary translation easy are a well defined and behaved operating system and programs. Programs which modify their own code, such as earlier DOS and Macintosh programs, can't be translated. Operating systems which have hidden or unreliable APIs or functionality like Windows are hard. If you're wondering about the Amiga, it has badly behaved programs which would probably make this hard. Emulation would be more reliable. -- John Bayko (Tau). bayko@cs.uregina.ca http://www.cs.uregina.ca/~bayko