Page 1 of 1
68k endianess question
Posted: Tue Feb 03, 2009 10:48 pm
by Jorge Nuno
When I want to program the word #$00E0 (appearing like that in a HEX editor) into a memory, at address 0, to be read by the 68k, where does the byte #$00 goes to? d15-d8 or d7-d0?
Thanks

Posted: Tue Feb 03, 2009 11:15 pm
by TmEE co.(TM)
I just changed my flashing code when I found out that upper and lower bytes were swapped on my flashcart
00 should be on 0 (D0 to D7), and E0 should be on 1 (D8 to D15)... I think, I may be wrong...
EDIT, no, the other way....
Posted: Tue Feb 03, 2009 11:24 pm
by Jorge Nuno
TmEE co.(TM) wrote:I just changed my flashing code when I found out that upper and lower bytes were swapped on my flashcart
00 should be on 0 (D0 to D7), and E0 should be on 1 (D8 to D15)... I think, I may be wrong...
EDIT, no, the other way....
So in 00E0, 00 goes to d15-d8 and E0 is in d7-d0.
Posted: Tue Feb 03, 2009 11:33 pm
by TmEE co.(TM)
I think so... 00E0 looks like 00E0 to 68K, while it would look like E000 to x86 or other little-endian things...
If the ROM won't work, you know you got things the wrong way

Posted: Tue Feb 03, 2009 11:34 pm
by Jorge Nuno
TmEE co.(TM) wrote:I think so... 00E0 looks like 00E0 to 68K, while it would look like E000 to x86 or other little-endian things...
If the ROM won't work, you know you got things the wrong way

Heh... Or not, when it comes to...
D-RAM!
BAHH...
Posted: Tue Feb 03, 2009 11:38 pm
by Chilly Willy
The 68000 is big endian. The value in a register 0x11223344 would be 0x11 0x22 0x33 0x44 in memory seen as bytes in a row from low address to high.
Posted: Wed Feb 04, 2009 3:46 am
by HardWareMan
Chilly Willy wrote:The 68000 is big endian. The value in a register 0x11223344 would be 0x11 0x22 0x33 0x44 in memory seen as bytes in a row from low address to high.
Confirm. So if memory has at some addr (i.e. $000000) 11 22 33 44, it will be:
Code: Select all
move.b $000000,d0 * d0 = $xxxxxx11
move.b $000001,d1 * d1 = $xxxxxx22
move.b $000002,d2 * d2 = $xxxxxx33
move.b $000003,d3 * d3 = $xxxxxx44
move.w $000000,d0 * d0 = $xxxx1122
move.w $000002,d1 * d1 = $xxxx3344
move.l $000000,d0 * d0 = $11223344
xx means unchanged previous value
word and longword access must be only at even address, or it will generate Address Error exception.
And write to memory is similar with read from it.
Posted: Wed Feb 04, 2009 4:05 am
by Chilly Willy
Exactamundo! Big-endian data in a nutshell. The SH2 used by the 32X is also big-endian. Funny enough, the Z80 is not. 16 bit values used by the Z80 are little-endian. That's because the Z80 is based on Intel's 8080 line of CPUs, and all Intel CPUs are little-endian.