[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emulator Project Question
Bryan Parkoff wrote:
Emulator Project Question
I am curious why C++ is written to read 6502 opcode before C++ function
has to be built in order to translate 6502 opcode into 80x86 opcode. I
believe that function is not needed however we must match each opcode code.
I'm confused. Are you referring to a generic C++ or some specific
program? A C++ compiler running under an emulator should still produce
6502 code. A cross compiler for C++ would produce native code for the
processor in use.
If, as the subject suggests, this is to be run under an emulator the
internal workings of the emulator should be understood. Does the
emulator completely emulate the 6502 or does it translate instructions?
I haven't seen the program you are talking about. In fact you never
mentioned its name. Therefore I will try to keep the answers general.
Actually the method you describe above will not produce compatible 6502
code. In otherwords if you are writing a program in the C++ compiler to
work on an Apple// it won't do so. It looks more like you are talking
about a program translator. This is more likely to translate 6502
programs into something to work only on a PC.
For example: 0x4C is the JMP for 6502 and we need to find 80x86 opcode
that has similiar JMP opcode. If hex code is found, then we can be able to
translate from 4C to ?? without using C++ function.
My personal favourite is to use a lookup table. This way the emulation
will always be fast.
If 6502 and 80x86 opcodes are very similar, but they are never
compatible then function is necessary to be written. I am curious.
Well, yes and no. On the microprocessor level there have to be analogues
of certain types of instructions. These are the minimum instruction set
for things to work. You need to be able to bring things in and send
things out of the processor to the RAM. You need to be able to set
various status flags. Addition and subtraction are necessary. The
program needs to know where in the RAM the next instruction is (and to
jump to a new location if necessary). For the most part these seem to
work the same on most processors.
On a specific processor the analogues may be direct such as the various
jump instructions. Others might need to have a few lines of code in
order to emulate the specific function. The Jump is easy. Change the
program counter.
Later
Mike
--
+----------------------------------------------------------------------+
| Digital Civilization magazine: http://www.digitalcivilization.ca |
| http://members.shaw.ca/pfaiffer = Mike Pfaiffer (B.A., B.Sc.) |
| See my web page before you think about spamming me. I charge cash. |
+----------------------------------------------------------------------+
----- BEGIN GEEK CODE BLOCK -----
Version: 3.12
GCS/G/IT/PA/SS d s+:- a? C++ UL L++ W++ N++ o+ K- w(---) O+@ M++@ V PS+
PE !PGP t+ 5+ X R tv b+ DI+++ D++ G e++* h! r-- !y-- UF++
------ END GEEK CODE BLOCK ------