当前位置:网站首页>Register of assembly language by Wang Shuang
Register of assembly language by Wang Shuang
2022-07-07 08:09:00 【Huaze flowers】
Register concept
The register is CPU The main components in , yes CPU Parts that programmers can read and write in . The programmer changes the contents of various registers to achieve the goal of CPU The control of .
Different CPU, The number of registers 、 The structure is different .8086CPU Yes 14 A register , Each register has a name . These registers are :AX、BX、CX、SI、DI、SP、BP、IP、CS、SS、DS、ES、PSW.
General registers
8086CPU All the registers of are 16 Bit , It can hold two bytes .AX、AB、CX、DX this 4 Registers are usually used to store general data , It's called a general register .

One 16 The bit register can store a 16 A data .
8086CPU The last generation of CPU The registers in are 8 Bit , To ensure compatibility , Based on the previous generation CPU The program can run in with a little modification 8086 above ,8086CPU Of AX、BX、CX、DX this 4 Each register can be divided into two independent 8 Bit register to use :
- AX Can be divided into AH and AL;
- BX Can be divided into BH and BL;
- CX Can be divided into CH and CL;
- DX Can be divided into DH and DL;

AX It's low 8 position (0 position ~7 position ) Constitute the AL register , high 8 position (8 position ~15 position ) Constitute the AH register .AH and AL Registers can be used independently 8 Bit register .

The storage of words in registers
For compatibility reasons .8086CPU The following two sizes of data can be processed at one time .
- byte : Write it down as byte, One byte by 8 individual bit form , Can exist 8 Bit register .
- word : Write it down as word, A word consists of two bytes , These two bytes become the upper byte and the lower byte of the word respectively .

A word can have a 16 Bit register . The upper and lower bytes of this word naturally exist The height of this register 8 Bit register and low 8 Bit register , Pictured 2.4, A font data 20000, There is AX In the register , stay AH Its low... Is stored in 8 position .AH and AL Data in , That is, it can be regarded as the height of a font data 8 Bit and low 8 position , The size of this font data is 20000, It can also be regarded as two independent byte data , Their sizes are 78 and 32.
Several assembly instructions
| Assembly instruction | control CPU Completed operation | Use the syntax of high-level language to describe |
|---|---|---|
| mov ax,18 | take 18 Into the register AX | AX=18 |
| mov ah,78 | take 78 Into the register AH | AH=78 |
| add ax,8 | Register AX Add... To the number in 8 | AX=AX+8 |
| mov ax,bx | Register BX The data in is sent to the register AX | AX=BX |
| add ax,bx | take AX and BX Add the values in , The result is AX in | AX=AX+BX |
Be careful , In order to make readers with high-level language foundation better understand the meaning of instructions , Sometimes the meaning of an assembly instruction is described in two ways: text description and high-level language description . Case insensitive when writing an assembly instruction or the name of a register . Such as :mov ax,18 and MOV AX,18 It means the same thing ;bx and BX It means the same thing .
PS: If the data size exceeds the register size , Then the highest data will not be stored . If you will 16 Bit register AX As two 8 Bit register AH and AL, So when doing the operation , Will be AL or AH As 1 Independent 8 Bit register , It's going on add The data size exceeds 8 position , Then the highest bit is lost ( The lost here , It means that the carry value cannot be in 8 Save... In bit register , But when CPU This carry value is not really discarded .)
In data transmission or computation , Note that the number of bits of the two operands of the instruction should be the same .
Address adders
The address adder uses Physical address = Segment address x16+ offset The physical address is composed of segment address and offset address . for example ,8086CPU The address to access is 123C8H The memory unit of , here , The operation of the address adder is shown in the figure 2.7 Shown :

“ Segment address x16” A more common expression is shift left 4 position .“ Move left 4 position ” In the middle , It refers to binary bits .
| Shift left digit | Binary system | Hexadecimal | Decimal system |
| 0 | 10B | 2H | 2 |
| 1 | 100B | 4H | 4 |
| 2 | 1000B | 8H | 8 |
| 3 | 10000B | 10H | 16 |
| 4 | 100000B | 20H | 32 |
- The binary form of a data is shifted left 1 position , It is equivalent to multiplying the data by 2;
- The binary form of a data is shifted left N position , It is equivalent to multiplying the data by 2 Of N Power ;
- Address segment x16 Arithmetic , Is to move the address segment stored in binary form to the left 4 position .
further , It is not difficult for us to get a left shift of Hexadecyl lactone form of data , Equivalent to times 16; The decimal form of a data is shifted one bit to the left , Equivalent to times 10; One X The hexadecimal data is shifted one bit to the left , Equivalent to times X.
边栏推荐
- LeetCode简单题之字符串中最大的 3 位相同数字
- 2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
- 【无标题】
- 芯片 設計資料下載
- Quick analysis of Intranet penetration helps the foreign trade management industry cope with a variety of challenges
- Linux server development, MySQL transaction principle analysis
- ZCMU--1492: Problem D(C语言)
- 太真实了,原来自己一直没有富裕起来是有原因的
- C language queue
- uniapp 移动端强制更新功能
猜你喜欢

Notes on PHP penetration test topics

LeetCode中等题之我的日程安排表 I

【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门

Real time monitoring of dog walking and rope pulling AI recognition helps smart city

【数字IC验证快速入门】14、SystemVerilog学习之基本语法1(数组、队列、结构体、枚举、字符串...内含实践练习)

Qt学习27 应用程序中的主窗口

Li Kou interview question 04.01 Path between nodes

2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers

QT learning 26 integrated example of layout management

Padavan manually installs PHP
随机推荐
Example of file segmentation
Linux server development, MySQL process control statement
Recursive construction of maximum binary tree
【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门
面试题(CAS)
game攻防世界逆向
青龙面板--整理能用脚本
json 数据展平pd.json_normalize
Call pytorch API to complete linear regression
Roulette chart 2 - writing of roulette chart code
The legend about reading the configuration file under SRC
Zsh shell adds automatic completion and syntax highlighting
Who has docker to install MySQL locally?
力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
贝叶斯定律
复杂网络建模(二)
DNS server configuration
dash plotly
ROS Bridge 笔记(05)— carla_ackermann_control 功能包(将Ackermann messages 转化为 CarlaEgoVehicleControl 消息)
Real time monitoring of dog walking and rope pulling AI recognition helps smart city