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 byBart T.
Posted on09/18/05 01:46 PM

> 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 09:05 AM
.*Re: Amiga 500 --> PC  nikoniko197511/07/05 06:49 PM
..Re: Amiga 500 --> PC  Bart T.09/18/05 01:46 PM
..*Re: Amiga 500 --> PC  amilator09/22/05 08:22 AM
..*Re: Amiga 500 --> PC  smf09/21/05 03:25 AM
...*Re: Amiga 500 --> PC  amilator09/22/05 08:27 AM