Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectRe: Amiga 500 --> PC Reply to this message
Posted byamilator
Posted on09/22/05 12:22 PM



Thank you for the reply.

After playing some with type casting and the logical operation OR, below is what I'm doing right now.

I have this function 'UWORD GetOpcode(address)' that reads from mem_chip[] (or mem_slow[] or mem_rom[]) like this: 'word = (UWORD) (mem_chip[address] << 8) | (UWORD) mem_chip[address+1];

note: the memory arrays I'm using are supposed to always follow the 68000 way of storing words/longwords (thats: mem[0] = highest byte, mem[1] = second highest byte, etc..
So I'm reading from emulated amiga memory, converting words/longwords by switching the order of the bytes and store in a variable, do the necessary operations etc.., switch the order of the bytes place that into the amiga memory.

Now I have not run any tests of the cpu emulator yet as I am far from nearly finished, so it would be informative to know what you feel about my way of doing this.


> > Hi, I've just started coding what is ment to be an emulator of the Amiga 500
> in
> > C, advice needed.
> >
> > The first thing I've wondered about is this: the mc 68000 reads/writes
> > words/longwords "normal" as opposed to the x86 (in the PC I'm trying to code
> an
> > emulator for) that swaps the cointained bytes (LO-to-HI).
> >
> > what is the easiest way to deal with this ? I've got somwhat confused for the
> > past ours to be honest.
>
> There are a few ways to deal with this depending on which version of the 68K you
> have to emulate. If dealing with the 68000 or 68010, you can actually byteswap
> every 16-bit word in your emulated memory spaces and then use normal
> loads/stores on X86. This is platform-specific of course. To access bytes,
> you'll have to XOR the address with 1 to get at the right part.
>
> For the 68020 and higher, this won't work because the processor can perform
> unaligned memory access and you have to either use a really tricky backwards
> memory scheme or simply byteswap everything after you've read it from memory.
>
> This works for the 68000 and any processor: just shift the bytes around using
> standard C bit shift and logical AND/OR operators.
>




-
Entire Thread
Subject  Posted byPosted On
*Amiga 500 --> PC  amilator09/17/05 01:05 PM
.*Re: Amiga 500 --> PC  nikoniko197511/07/05 11:49 PM
.*Re: Amiga 500 --> PC  Bart T.09/18/05 05:46 PM
...Re: Amiga 500 --> PC  amilator09/22/05 12:22 PM
..*Re: Amiga 500 --> PC  smf09/21/05 07:25 AM
...*Re: Amiga 500 --> PC  amilator09/22/05 12:27 PM