We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

little endian

From SnesLab
Revision as of 00:09, 10 November 2019 by Vitor Vilela (talk | contribs) (Vitor Vilela moved page Little endian to little endian)
Jump to: navigation, search

Little endian refers to a storage of values beyond one byte. It's also known as LSB (least significant byte), since the low byte is stored first leading up to the high byte. It's a contrast to big endian which stores in the opposite fashion. The SNES CPU, the 65c816, uses little endian.

Example

The 16-bit value $5035 would be stored as $35 $50 in ROM and the 24-bit value $708000 would be stored as $00 $80 $70. Note how the high byte comes after the low byte(s), and the bank byte after the high byte. That's how little endian works.

In assembly

The parameters of the opcodes are stored as little endian too (ONLY if they're numbers), but the opcode themselves are not. For example, LDA $449922 would be stored as $AF $22 $99 $44 in the ROM. The first byte is the opcode; it doesn't participate in the little endian concept. Therefore, it will remain as the first byte to appear. Its parameter, $449922, does participate though.