View Single Post
Old 31st August 2013, 05:27 PM   #6
Gotta fill something here.
Miksy91's Avatar
Join Date: Jul 2013
Location: Northern Europe
Age: 26
Posts: 117

Big endian number format is the way you would like to read the bytes as. The GBA pointer to rom address $72A569 is 08 72 A5 69 in big endian data format. In little-endian, the bytes are in reversed order.

I can't say about ARM/Thumb assembly, but in GB/C assembly, most data inside rom is presented in little-endian data format (a.k.a reversed order) because coding the routines that use little-endian data tables is "easier" than coding routines that use big endian data tables.
However, nothing prevents you from coding tables that are stored inside ROM/RAM so that the data is presented in big endian format instead of little-endian. In fact, I have coded some new routines in my own hack so that they actually use big endian data tables instead!

So let's say that even though in pokemon FireRed, GBA pointers tend to be in little-endian format, that doesn't mean you couldn't find some of the routines using straight big endian addresses used as pointers as well.

Anyway, what comes to your question;

Data tends to be stored in ram in little-endian format, but it's not always there that way. For example in this case with the general 16-bit LCD Status "register", I'd assume it to work so that the value (according to that documentation) is in big endian format and the first 8 bits of it work as the V-Count Setting.

Originally Posted by karatekid552
0010|1001 1001|0110

0 0 1 0 | 1 0 0 1 1 0 0 1 | 0 1 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
/-V-count setting--/ /nop//-- flags --/
Yeah, that's how I would assume it to be (though I don't have much knowledge about GBA hardware, or playing with 16-bit data for that matter either).

Endianness in Wikipedia

The solution I made with LCD Status register being in big endian format instead comes from the fact that it would be stupid to give documentation about something that wouldn't be "accurate" just yet. In this case, it's easy to perceive V-Blank flag (bit 0) being the rightmost bit since that way, you don't have to "look for it".
If that data was in little-endian format instead, V-Blank flag would be in the middle of the 16-bit value, as the eight bit from the left.

The location of V-Blank flag (Bit 0)

Possibility #1 (Big Endian):
0010|1001 1001|0110

Possibility #2 (Little-endian):
1001|0110 0010|1001

Last edited by Miksy91; 31st August 2013 at 05:39 PM.
Miksy91 is offline