@Bloodline:
"I have no idea how one could actually do that... Why don't you build an emulator as you've described so that we can see it."
Firstly I would need an MMU.hidd. ;-)
And later AROS would need virtual addressing to make it work efficiently, otherwise we would have to reserve the memory of each cpu zone
@falemagna:
Of course OS4 (I ommit the "A" because it is THE AmigaOS) doesn't need to switch words, it's running on a big-endian cpu so no need to do that...
If you have the x86 and the 68k data long-word aligned you could do it this way:
|0A|0B|0C|0D| addresses-> 01,02,03,04
if I wanted to read the 2nd byte from the little endian ram zone the first thing I would do is to check what byte of the longword would it be part of...
if the byte is in the address from 01-04 it is part of the first longword, if the byte is in the address 05-08 etc...
so we read the address 02 and it's detected that it's part of the first longword, so we flip the bytes and we read 0C. If we read the third byte we read 0B, if we read the 4th, 0A. So now we have in the 680x0 memory area:
0D|0C|0B|0A
if the x86 native program tries to access some bytes, as the memory will be aligned we will choose the right byte thanks to the memory alignment.
So basicly we would check ALL the accesses to memory and we would byteswap absolutly everything.
In conclusion:
-we have an MMU to mark one zone as 68k and other as x86 (that would require MMU.hidd to work, and virtual addressing activated to be efficient and to avoid wasting too much memory)
-we have everything long-word aligned (more or less easy)
-we determine if a byte is part of one longword or part of the next one (a bit slow, I know)
-we swap the bytes to copy the right one to the different memory areas (680x0 and x86)
I said that it was similar to the OS4 approach only because they also split the memory in two parts, the 680x0 zone and the x86 zone.
BTW, I've translated the AROS introduction to Spanish, where should I send it?
-edit-
I've read the other comment later...
"what if the data is NOT in litte-endian mode, but it's just text being copied from one memory location to another? You see, it doesn't work. "
mmm If I read a text in a little-endian machine, wouldn't it be stored this way?:
Original text: "THIS_IS_TEXT"
1st longword: SIHT
2nd longword: _SI_
3rd longword: TXET
Then it would be copied correctly to the 680x0 memory area swapping the bytes just like in the other situation