当前位置:网站首页>Description of large and small end mode
Description of large and small end mode
2022-07-24 19:22:00 【senseshield】
summary
In calculation , Byte order refers to the bytes in the binary representation of numbers ( Or sometimes bit ) The order of . It can also be used more generally to refer to the internal ordering of any representation , For example, the part of a number or date in a digital system .
In the most common usage , Byte order represents the byte order within a multibyte number . Small end sorting puts the least significant byte first , Put the most significant byte last , The big end sort is the opposite . for example , Consider unsigned hexadecimal numbers 0x1234, This requires at least two bytes to represent . In small end sorting , The bytes will be arranged as [0x34,0x12], In the big end sort, they will be [0x12,0x34].
In memory form
Such as the int Integer numbers , Its value is expressed in hexadecimal :0x12345678, Then the storage in memory is shown in the following figure :

Why are there big and small ends
The description given online is : This is because in a computer system , We are in bytes , Each address corresponds to a byte , A byte is 8bit. But in C In language, except 8bit Of char outside , also 16bit Of short type ,32bit Of long type ( It depends on the compiler ), in addition , For digits greater than 8 Bit processor , for example 16 Bits or 32 Bit processor , Because the register width is larger than one byte , Then there must be a problem of arranging multiple bytes . So it leads to big end storage mode and small end storage mode . For example, one 16bit Of short type x, The address in memory is 0x0010, for example ,x The value of is 0x1122, that 0x11 For high byte ,0x22 Is low byte . For big end mode , will 0x11 Put it in the low address , namely 0x0010 in ,0x22 Put it in a high address , namely 0x0011 in . The small end model , Just the opposite . That we use a lot X86 The structure is small end mode , and KEIL C51 It's the big end mode . A great deal of ARM,DSP It's all small end mode . There are some ARM The processor can also choose the big end mode or the small end mode by the hardware .
In a nutshell , There is no unified specification for early computer hardware design , So there are hardware designs with inconsistent size ends , And their respective development is very good , When everything is interconnected , Data interaction , The size end has become a problem that must be considered .
present situation
at present Intel Of 80×86 Series chip is the only chip that still insists on using small end ,ARM The chip adopts small end by default , But you can switch to big end ; and MIPS And other chips can be stored in all big end ways , Or provide options to support big end —— You can switch between big and small ends . in addition , The processing of the size end is also related to the implementation of the compiler , stay C In language , The default is small end ( But in some single-chip implementation is based on the big end , such as Keil 51C),Java It's platform independent , The default is big end . The big end is widely used to transmit data on the network .
Pay attention to the scene at the size end
- Different end modes must be considered when data transfer is carried out by processors with different end modes
- Be careful Java and C/C++ The conversion of size end when data is exchanged between programs developed by language
- When transmitting data over the network , Because the two ends of data transmission correspond to different hardware platforms , The storage byte order used may be inconsistent . So in TCP/IP The protocol stipulates that the network byte order must be adopted on the network , That's the big end mode . about char Type data only takes up one byte , It doesn't matter whether the big end or the small end . But not for char Type data , The data must be converted to big end mode before it is sent to the network . When receiving network data, it shall be received according to the environment of the receiving host .
Reference resources
Reference link https://en.wikipedia.org/wiki/Endianness
边栏推荐
- [question 39] special question for Niuke in-depth learning
- 2022 Hangdian multi school second session 1009 shuangq (Mathematics)
- On dynamic application of binary array
- Anaconda installs labelimg (super simple and available)
- Mysql数据库,子查询,union,limit篇
- Tupu software digital twin civil aviation flight networking, building a new business form of smart Civil Aviation
- Channel state information (CSI) conjugate multiplication denoising method
- MySQL sort. Sort by field value
- pyhanlp安装教程
- Getaverse,走向Web3的远方桥梁
猜你喜欢

Nftscan and port3 have reached strategic cooperation in the field of NFT data

Sequences, time series and prediction in tessorflow quizs on coursera (I)

day 1
![[JVM learning 03] class loading and bytecode Technology](/img/b4/9482b02b58580171235fd4c36129e9.png)
[JVM learning 03] class loading and bytecode Technology

How to encrypt your own program with dongle
Siyuan notes V2.1.2 synchronization problem

湖仓一体释放全量数据价值,SequoiaDB v5.2线上发布会重磅来袭

MySQL1

Common methods of string class

Feature extraction tool transformer Bert
随机推荐
Mysql数据库,去重,连接篇
Wireshark simple filter rule
How to encrypt your own program with dongle
OPENGL学习(三)GLUT二维图像绘制
[Huawei lyevk-3861a intelligent IOT development board evaluation] unpacking experience and Hisilicon hi3861v100 chip learning experience
TCL programming style guide
Techempower web framework performance test 21st round results release --asp Net core continue to move forward
Install SSL Certificate in Litespeed web server
Unity code imports packages through package manager
Nezha monitoring - server status monitoring, SSL certificate change expiration, Ping monitoring and scheduled task reminder
day 2
思源笔记 v2.1.2 同步问题
PCI express physical layer - electrical part
Get module handle / base address
OpenGL learning (III) glut two-dimensional image rendering
Modelarts, Pangu big model, ModelBox... Detailed explanation of Huawei cloud AI development production line
On July 31, 2022, the dama-cdga/cdgp data governance certification class was opened!
[laser principle and application -6]:q switching element and Q drive circuit board
OpenGL learning (V) modern OpenGL triangle rendering
MySQL8.0学习记录20 - Trigger