> Bit 0 is the LSB and bit 31 is the MSB by definition
No. Bit 0 is the MSB and bit 31 is the LSB by IBM's definition, going all the way back to the 1950's.
That was the whole point of my reply. I'm sorry I didn't make it clearer.
Bit-numbering is a CONVENTION, not a "LAW". There are two common conventions. IBM/POWER uses the opposite one to almost everyone else. But they did get there first.
> // BR0: 0xFF800801
> lis r4, 0xFF80
> ori r4, r4, 0x0801
> stw r4, 0x100(r3) // BR0
>
> The 32 bit word 0xFF800801 I think translates to LSB>801001FF<MSB when mapped
> to the datasheet. I say this because if the V (bit 31) is set it's neighbors
> (bits 26 to 30) should be zero.
Yes, but why reverse the writing order, just to put Bit31 on the left?
The Data Sheet details BRn as:
| 0 | | | | 16 17 18 19 | 20 21 22 23 | 24 25 26 27 | 28 29 30 31 |---------------------------------------------------------------------------| BA | - | PS | DECC| WP| MSEL | - | ATOM | -| V |---------------------------------------------------------------------------
The 32 bit word 0xFF800801 matches the above exactly, left to right. "BA" is "FF80", "DECC" is "2" ("10" in binary) and "V" is "1"
"BA" is bits 0-16 which are the upper 16 MSbits in the word. "V" is Bit 31, which is the LSB. Ignore the bit numbering, accept the bit reversal and it all makes perfect normal sense.
> I haven't read all the datasheets or found a statement that explains the format.
That was also the point of my email. The "original defintion" is "buried in history", and since everyone KNOWS that the Power chip uses te opposite convention, Freescale doesn't explicitly document it anywhere. They do state in some documents that it is stated in other documents, but I've looked, and it isn't.
I would also hope you followed the links I provided. The one showing a picture of an old IBM Mainframe front panel shows that they numbered the switches and lights right-to-left and that set their convention. The links to the other forum articles might also help your understanding, and also point out some other traps you might fall into.
Tom