[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emulator Project Question



I understand what you are trying to do, but the Apple II is propably the
least ideal environment to emulate in this fashion.

You *could* have a "virtual" machine in which you pre-translate 65x02/816
code into 80386 code. In this scenario, you would essentially remap all
memory access and branch operations.

This would be a great way of doing the emulation, if it weren't for the fact
that Apple II machines have a historical obscene way of doing things.

For instance, many programs load in segments. And it is not clearly defined
if a segment being loaded is data or code. In addition, many older pieces of
software were polymorphic. They altered the internal program during runtime
to suit various conditions.

This was all due to the fact that the Apple II memory footprint was very
small, and larger software required this type of junk.

If you could clearly define which bytes were "code" and which were "Data",
performing assembly conversion at runtime wouldn't be so difficult.

The problem is that you cannot "translate as you go", and you have no
guaranteed method of identifying which is code and which is data.

The fastest method so far has been a simple jump table. Define an array of
function pointers that is 255 bytes long. Each element points to a function
that handles that particular opcode. Simply do a array[opcodenumber]; and
you can call the emulated CPU. It is slower than native code, but it is far
more reliable.


"Bryan Parkoff" <BParkoff@satx.rr.com> wrote in message
news:YHYO7.45020$tf5.2452398@bin5.nnrp.aus1.giganews.com...
> 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.
>     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.
>     If 6502 and 80x86 opcodes are very similar, but they are never
> compatible then function is necessary to be written. I am curious.
>
> --
>
> Yours Truly,
>
> Bryan Parkoff
> BParkoff@satx.rr.com
>
>
>