# Big endian or Little endian?

Discussion in 'Engineering & Reverse Engineering' started by XFox Prower, Jan 31, 2004.

Not open for further replies.
1. ### XFox Prower

Member
1,196
0
0
x86 Assembly, Tails Search Assistant
I was making a chart to log the password patterns in Megaman X for different items and events as follows:

Beating Storm Eagle modifies the PW like this:
_= didn't change
*= changed

___*
*_*_
__*_

So if I were to put that in binary it would be:

0001
1010
0010

The thing is, it's 1 byte and 1 nybble. There's two ways I could organize this (red means padded 0s):

Taking the first 8 as they come and pad
00011010 00000010 (1A 02 in hex)

Taking the first 4 bits and treating it as a nybble:
00000001 10100010 (01 A2 in hex)

I'm curious, is this how big endian and little endian are? Or is it simply Flipping the 4 bits in a byte to change something like FA to AF? It's not something that's preventing me from completing my project. And this isn't just concerning a Megaman game either. But I'm certain this question would be asked sooner or later by someone who just learned hex and got lost in a 68k tutorial.

*For those just learning hex, a nybble is a 4-bit binary number such as 1011 (a single hex digit or half-byte).

2. ### LocalH

3,309
29
28
wouldn't you like to know
Guitar Hero II Deluxe
No. Endianness never breaks apart a byte into it's nybbles on most anything you'll work with today (at most, bit-endianness determines the order of the bits in each byte, whether it's 76543210 or 01234567 - most systems today have the most significant bit first). Endianness only comes into play when storing values larger than the native integer size. For example, let's say you want to store \$004488CC in memory. On a big-endian CPU, this is stored as \$00 \$44 \$88 \$CC in consecutive bytes, whereas with a little-endian CPU it's stored 'backwards', as \$CC \$88 \$44 \$00. The Genesis is bigendian, and any system with a 6502 CPU is littleendian (this includes the SNES as the 65816 is basically a 16-bit 6502).

3. ### XFox Prower

Member
1,196
0
0
x86 Assembly, Tails Search Assistant
Does that mean a word containing bits 1234 would be 4321? Maybe I misread. But according to HiveBrain's Sonic 2 SMS Guide, the 2 bytes in a word were reversed, and no changes were made to the bits in any way. So that would mean:

byte ab would remain as ab
word 00ab would become word ab00

Does that mean a longword 000000ab would be 0000ab00? Or does the 2 words in a longword get swapped as well, making it ab000000?

4. ### Quickman

be attitude for gains Tech Member
5,596
18
18
:x
omg porjcet
Word ABCD becomes CDAB.
Longword ABCDEFGH becomes GHEFCDAB.