Binary Expression and Value Expression
2016-03-06 16:12
387 查看
Hi guys
My Email: jakezhang1989@hotmail.comMy GitHub Link
Thank you for taking time to go through this post from which you would get what you want.
If you have any problems or opinions that are different form mins, please email me or leave a comments. I will reply as soon as possible.
OK, Let us get started!
Glossory
HMA : High Memory AddressLMA : Low Memory Address
HB : High Byte
LB : Low Byte
Little endian : a HB is stored in HMA, a LB is stored at LMA
Big endian: a HB is stored in LMA, a LB is stored at HMA
Topic
This blog is to highlight a misunderstanding I used to have that I mixed up the binary expression and value expression regarding to endian swapArgument
Binary expression is a format used to store a variable in memory whereas value expression is the human-readable values that represents.Supporting Statements
Say we have (other types follow the same rules)short a = 128;
Its value expression may look like this:
HB<- - - - - - - - LB
00000000 10000000
{highbyte} {lowbyte}
Its little endian binary expression may look like this:
LMA- - - - - - - - - ->HMA
{lowbyte} {highbyte}
10000000 00000000
Its big endian binary expression may look like this:
LMA- - - - - - - - - ->HMA
{highbyte} {lowbyte}
00000000 10000000
Take the example of little endian a above, I used to think that little endian a has a decimal value of 2^15 as bit 1 is at the index of 15, which should have been decimal value of 128.
Actually, the correct way to represent the value of little endian a by little endian CPU is based on the fact that CPU will always obtain the value expression from binary expression and the value of a variable we often talk about actually points out the value expression (10 base, binary base or 8 base):
When CPU meets the first byte 100000, it knows this byte should be low byte in value expression since the byte is stored in LMA. And the second byte 000000 should be the high byte in value expression. So, the final binary base value expression should be 00000000 10000000, and its decimal value is therefore 2^8 that equals to one we assigned before.
End of the post.
相关文章推荐
- UIActivityIndicatorView的使用
- 如何设置约束让三个按钮平分UIView容器的宽度的方法
- UIActivityViewController头文件学习
- Android UI优化
- 1051. Pop Sequence (25) 判断出栈序列是否合理
- [LeetCode]62. Unique Paths
- LA 4287(p322)----Proving Equivalences
- 一起看代码来玩玩QT之18 database (last QSqlQueryModel 对数据库进行操作(只查不能改)QTableModel 可改,但是QSqlQueryModel也可以添加代理等功)
- Maximum Subsequence Sum
- hdoj 2734 Quicksum(字符串)
- [LeetCode] Closest Binary Search Tree Value II 最近的二分搜索树的值之二
- 关于UEditor配合TP框架使用
- Surface用户千万不要升级Win10 build 14279:有冻屏BUG
- String、StringBuffer与StringBuilder之间区别
- 浅浅的介绍一下android里面Handler、Looper、Message和MessageQueue是怎么联系到一起的.
- UGUI基本属性设置
- UITableView性能优化
- 怎么读取二代身份证UUID----在STM32+CLRC663平台试验成功
- 记一次深刻的教训-----将mat数据转化为SequenceFile
- java.util.Queue用法