当前位置:网站首页>Original reverse compensation and size end
Original reverse compensation and size end
2022-07-24 19:21:00 【The moon chews into a star~】


Author's brief introduction : A freshman
Personal home page : The moon chews into a star ~
personal WeChat:yx1552029968
Series column :C Advanced language
One sentence per day : Don't spill a pot of cream just because you fall into a handful of cow hair , Don't throw away your career just because you made a mistake .
In the computer Integers There are three representations , namely Original code 、 Inverse and complement .
There are three ways of expression Sign bit and Value bits Two parts , The sign bits are all used 0 Express “ just ”, use 1 Express “ negative ”, And the number bit
The three representations of negative integers are different .
Original code
Directly translate binary into binary in the form of positive and negative numbers .
Inverse code
Change the sign bit of the original code , The other bits can be inverted in turn .
Complement code
Inverse code +1 You get the complement .
A positive number 、 back 、 The complement is the same . For plastic surgery : Data stored in memory is actually stored in the complement .
Why? ?
In computer system , All values are represented and stored by complements . The reason lies in , Use complement , You can combine sign bits and numeric fields One processing ; meanwhile , Addition and subtraction can also be handled in a unified way (CPU Only adders ) Besides , Complement code and original code are converted to each other , Its operation process It's the same , No need for additional hardware circuits .
Let's look at the storage in memory :



We can see that for a and b The complement code is stored separately . But we found something wrong with the order . That's why ?
Introduction to big and small end
What is big end, small end :
Big end ( Storage ) Pattern , The low bit of data is stored in the high address of memory , And the high end of the data , Low address saved in memory in ;
The small end ( Storage ) Pattern , The low bit of data is stored in the low address of memory , And the high end of the data ,, Stored in memory Address .
Suppose there is a number of 16 Into the system is 0x11223344

Why there are big end and small end :
Why are there big and small end patterns ? This is because in a computer system , We are in bytes , Each address unit Each corresponds to a byte , A byte is 8bit. But in C In language, except 8 bit Of char outside , also 16 bit Of short type ,32 bit Of long type ( It depends on the specific compilation Translator ), in addition , For digits greater than 8 position The processor of , for example 16 Bits or 32 Bit processor , Because the register width is larger than one byte , Then there must be a problem such as How to arrange multiple bytes . So This leads to large 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 by High byte ,0x22 Is low byte . For big end Pattern , 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 Structure is The small end model , 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 It is up to the hardware to choose whether it is the big end mode or the small end mode
Thank you, brothers
It's not easy to code words , For a third company .

边栏推荐
- Sequences, time series and prediction in tessorflow quizs on coursera (II)
- Compressed string
- Interceptors and filters
- MySQL1
- MySQL1
- PostgreSQL Elementary / intermediate / advanced certification examination (7.16) passed the candidates' publicity
- Serial vector format (SVF) file format
- 关于core文件
- Wireshark simple filter rule
- Why are there loopholes in the website to be repaired
猜你喜欢

2022杭电多校第二场1009 ShuanQ(数学)

文献阅读:GoPose 3D Human Pose Estimation Using WiFi

High speed ASIC packaging trends: integration, SKU and 25g+

Decision tree_ ID3_ C4.5_ CART
Siyuan notes V2.1.2 synchronization problem

原反补及大小端
思源笔记 v2.1.2 同步问题
![[JVM learning 03] class loading and bytecode Technology](/img/b4/9482b02b58580171235fd4c36129e9.png)
[JVM learning 03] class loading and bytecode Technology

LSTM and Gru of RNN_ Attention mechanism

Crazy God redis notes 11
随机推荐
2022杭电多校第一场Dragon slayer(dfs+状态压缩)
Convolutional Neural Networks in TensorFlow quizs on Coursera
MySQL version 5.7.9 SQL_ mode=only_ full_ group_ By question
Excel practice notes 1
Sequences, time series and prediction in tessorflow quizs on coursera (I)
Summary of articles in 2020
Serial vector format (SVF) file format
Nezha monitoring - server status monitoring, SSL certificate change expiration, Ping monitoring and scheduled task reminder
Pay close attention! List of the latest agenda of 2022 open atom open source Summit
day 3
MySQL1
Tcl/tk file operation
多线程与并发编程常见问题(未完待续)
知乎上的那些神回复
FPGA 20个例程篇:9.DDR3内存颗粒初始化写入并通过RS232读取(下)
Calendar common methods
OPENGL学习(二)OPENGL渲染管线
Hucang integrated release of full data value, sequoiadb V5.2 online conference heavy attack
Tclsh array operation
About core files
Author's brief introduction : A freshman
Personal home page :
personal WeChat:yx1552029968
Series column :
One sentence per day :