Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!van-bc!rsoft!mindlink!a218 From: Charlie_Gibbs@mindlink.UUCP (Charlie Gibbs) Newsgroups: comp.sys.amiga.emulations Subject: Re: Emulator Mechanics (sorry long post) Message-ID: <5008@mindlink.UUCP> Date: 5 Mar 91 21:29:11 GMT Organization: MIND LINK! - British Columbia, Canada Lines: 27 In article <1991Mar6.010141.5905@mintaka.lcs.mit.edu> rjc@pogo.ai.mit.edu (Ray Cromwell) describes a 6502 emulator that looks a lot like my SimCPM. You're right that it would be better to use MOVE from SR instead of GetCC() to get the flags. Before anybody unholsters their flame throwers, I would hasten to point out that normally I wouldn't think of doing such a dastardly thing, but in this case it's too much of a performance hit to do otherwise. We have to keep that loop as tight as possible if we're going to get any speed at all. As in your example, SimCPM's individual instruction emulation routines fetch the flags so that I can use custom-tailored conversion routines for more speed. One trick I use is to use the entire flag byte as an index into a 256-byte table form which I pull the translated flag values, again trading memory for speed. This makes for lots of places where I need to get the flags. What I've done in SimCPM is to define a macro that generates either MOVE from SR or MOVE from CCR depending on the setting of an assembly-time switch. The result is two versions of SimCPM - one runs only on the 68000, while the other runs only on 68010 and higher processors. I can't think of any other way to do it that doesn't itself involve a prohibitive amount of overhead or lots of self-modifying code. Charlie_Gibbs@mindlink.UUCP "I'm cursed with hair from HELL!" -- Night Court