Endianness
来源:互联网 发布:数易文化计算法 编辑:程序博客网 时间:2024/05/16 11:23
Endianness
seuchenrui@126.com
reference: Daniel Page. A practical introduction to computer architecture. Springer-Verlag London, 2009: 28 - 29
Usually, we use a little-endian convention by reading the bits from right to left, giving each bit is given an index. So writing the number 1111011(2) as the vector 1111011 we have that
- x0 = 1
- x1 = 1
- x2 = 0
- x3 = 1
- x4 = 1
- x5 = 1
- x6 = 1
If we interpret this vector as a binary number, it therefore represents 1111011(2) = 123(10). In this case, the right-most bit (bit zero or x0) is termed the least-significant while the left-most bit (bit n-1 or xn-1) is the most-significant. However, there is no reason why little-endian this is only option: a big-endian naming convention reverses the indices so we now read them left to right. The left-most (bit n-1 or xn-1) is the least siginificant. If the same vector is interpreted in big-endian notation, we find that
- x0 = 1
- x1 = 1
- x2 = 1
- x3 = 1
- x4 = 0
- x5 = 1
- x6 = 1
and if interpreted as a binary number, the value now represents 1101111(2) = 111(10).
The same issues of endianness need consideration in the context of bytes and words.
For example, one can regard a 32-bit word as consisting of four 8-bit bytes.
Taking W, X, Y and Z as bytes, we can see that the word can be constructed two ways.
- Using a little-endian approach, Z is byte zero, Y is byte one, X is byte two and W is byte three; we have the word constructed as W : X : Y : Z.
- Using a big-endian approach the order is swapped so that Z is byte three, Y is byte two, X is byte one and W is byte zero; we have the word constructed as Z : Y : X : W.
The following figure is demonstration of byte-ording.
Jari Nurmi. Processor design: system-on-chip computing for ASICs and FPGAs. Springer, 2007: 166
The following figure is another demonstration of byte-ording.
Patrick R. Schaumont. A Practical Introduction to Hardware/Software Codesign, second edition. Springer, 2013: 207
- endianness
- Endianness
- Endianness
- Endianness
- endianness
- Endianness浅析
- endianness test
- Endianness一点通
- [转帖]Endianness一点通
- 关于Endianness【转】
- Endianness浅析
- 字节序问题 Endianness
- MSB&LSB与Endianness
- 字节序(Endianness)
- MSB&LSB与Endianness
- 浅谈字节序(Endianness)
- 浅谈字节序(Endianness)
- 从零开始学习嵌入式 - 什么是Endianness?
- GoogleAPI-Adwords Labels
- C++:const和指针
- 关于solver文件中test_iter和test_interval设置问题
- POJ2955 Brackets(区间dp)
- STL_算法_重排和分区(random_shuffle、partition、stable_partition)
- Endianness
- Linux 设备驱动中的阻塞和同步机制
- 敏捷开发 scrum 宣言
- 2.2.2 数与字符串
- Java栈
- Pipe
- xib中使用auto layout
- NGUI 实现对UISprite 的拖拽
- 从静态库中提取文件