Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.sinclair > #4135
| From | Guesser <alistair@zxnet.co.uk> |
|---|---|
| Newsgroups | comp.sys.sinclair |
| Subject | Re: How does a Spectrum emulator work? |
| Date | 2016-04-02 18:14 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <ndoufq$d08$1@dont-email.me> (permalink) |
| References | <cb4d972b-4829-4377-b4f1-ce90924d0c7d@googlegroups.com> |
On 02/04/2016 17:40, bit-naughty@hotmail.com wrote: > ..... I remember having a small discussion with Gasman about this right here (and btw, Gasman, I'm still looking to get in touch with you, if you're reading this, please post here!), but I got to thinking about it, and..... how is it done? > > How do you actually *send* a stream of hex to your CPU? (I'm talking about the machine your emulator is running on,.. that is to say, in general, Mister Intel...) I mean, figuring out the Z80 code, and figuring out what it's Intel equivalent will be is obviously the *main* task of an emulator, and hard enough by itself, but... once you know what instructions you want to *send* to Mr. Intel, .... how do you do it? > In 2016 you don't. You write some code for each instruction and another bit of code reads from the memory that represents the spectrum's memory at the appropriate offset saved in some kind of variable representing the program counter. You read the bytes and call the relevant routine for that opcode. They update other variables for other registers and read or write bytes in the memory array. Then you do it all again for the next instruction etc. You also need some counters for things like interrupts, and some code to interpret the contents of the memory array and generate the display. Then you compile all that code into a binary and let the operating system and standard libraries worry about making it run. > I once heard or read somewhere of a trick where you put an instruction on the stack (like, the hex code), and then do, essentially, a POP EIP (I'm using 32-bit terminology), but then what do you do if that instruction is a JMP? What is the actual _essence_ of emulation....? :) > > ....And of course THEN there is the question of how the actual *conversion* is done....I'm emphatically NOT a C programmer, so please don't tell me to read FUSE code or something, to figure out how THAT's done.... :) > Was the source for the Z80 emulator ever released, or was it only made freeware? I seem to remember than translating Z80 to x86 instructions was one of the tricks it used to get acceptable emulation speed out of the processors of the time.
Back to comp.sys.sinclair | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How does a Spectrum emulator work? bit-naughty@hotmail.com - 2016-04-02 09:40 -0700
Re: How does a Spectrum emulator work? Guesser <alistair@zxnet.co.uk> - 2016-04-02 18:14 +0100
Re: How does a Spectrum emulator work? jbkoelman.sp@gmail.com - 2016-04-02 12:43 -0700
Re: How does a Spectrum emulator work? "Brian Gaff" <briang1@blueyonder.co.uk> - 2016-04-02 21:22 +0100
Re: How does a Spectrum emulator work? jbkoelman.sp@gmail.com - 2016-04-02 13:49 -0700
Re: How does a Spectrum emulator work? Leiradella <aleiradella@gmail.com> - 2016-04-02 14:01 -0700
Re: How does a Spectrum emulator work? "Brian Gaff" <briang1@blueyonder.co.uk> - 2016-04-02 21:17 +0100
Re: How does a Spectrum emulator work? Leiradella <aleiradella@gmail.com> - 2016-04-02 13:56 -0700
Re: How does a Spectrum emulator work? Andre Majorel <cheney@halliburton.com> - 2016-04-06 11:56 +0000
Re: How does a Spectrum emulator work? Tyrell <on4ssc@gmail.com> - 2017-01-28 15:59 +0100
Re: How does a Spectrum emulator work? AndyW <Andy@nojunqmail.com> - 2017-01-30 07:33 +0000
csiph-web