当前位置:网站首页>Difference between big end mode and small end mode

Difference between big end mode and small end mode

2022-06-12 16:54:00 icejuhua

for example The data is 0x01234567  The memory address is 0x101 0x102 0x103 0x104 among 0 Symbol bit

Big end model :

The big end mode means that the high bit of data is stored in the low address in the memory , The low order of the data is stored in the high address of the memory

The small end model :

Small end mode means that the high bit of data is stored in the high address in the memory , The lower order of the data is stored in the lower address of the address , Opposite to small end mode

As shown in the figure below :

Memory address 0x101 0x102 0x103 0x104
Big end model 01234567
The small end model 67452301

Application of large and small end mode :

The use of large and small end mode mainly depends on what mode the MCU supports , The correct way to use it is to choose different modes according to different machines

eg: Big end model :KEIL C51

The small end model : A great deal of ARM,DSP Both use the small end mode ( More common )

There are also microcontrollers that can choose to use different modes

Why is there a difference between the big and small end modes

         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 specific compiler and system environment ), 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,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 .

Finally, let's talk about the advantages and disadvantages

  In fact, there are no so-called advantages and disadvantages of the large and small end mode

The small end model : There is no error in the data during the cast , Because the data is stored from small to large according to the memory increment

Big end model : Because the highest bit is the sign bit , So it's easier to judge symbols

原网站

版权声明
本文为[icejuhua]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206121641335887.html