Path: utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!pepper!cmcmanis From: cmcmanis%pepper@Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga Subject: Re: Amiga Emulators Message-ID: <72321@sun.uucp> Date: 10 Oct 88 20:16:05 GMT References: Sender: news@sun.uucp Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 36 All "good" emulators compile the object code into native code before running. If everyone wrote completely vanilla programs this would make for very fast emulators, unfortunately not everyone does. Instead they do things like self modifying code, and pushing data on the stack and then doing a "return" (sort of a poor man's computed branch). Consequently, emulators have to constantly test for these cases and work around them. The other major problem with emulating different architectures are the various ways in which internal pieces of the architecture are handled. In the case of the Intel and x80 architectures one of the big problems is the flags, especially the half carry flag. Because there is no real equivalent of half carry on the 68K, to emulate it requires several computations on the result register. (generally two masks and an XOR operation). Many compiler techniques can help, in particular things like register/flag following. Register/flag following is a technique that "knows" all routines that affect the flags, when a "flag instruction" is encountered you can look ahead to see if another instruction is going to change that flag before it is used and if so, *not* compute the flag value. Another problem which is less severe is people who use undocumented opcodes. These will cause you compatibility nightmares too. And of course last but not least, when you say "emulate and 8086" do you really mean "emulate an IBM-PC?" because in that case you have to emulate such things as floppy controllers, DMA channels, and interrupt controllers. None of which can be "compiled" per se. Finally, if you do this, and it is reccomended because it can really broaden your "systems" view of the world. You will find you have a tool that is not only capable of running programs written for a different machine, but also a fantastic simulator/debugger for programs and hardware for that machine. --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you.