> 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.