当前位置:网站首页>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.
边栏推荐
- Niu Mei's mathematical problem --- combinatorial number
- The element with setfieldsvalue set is obtained as undefined with GetFieldValue
- Cnopendata list data of Chinese colleges and Universities
- Yugu p1020 missile interception (binary search)
- Blob object introduction
- Quick analysis of Intranet penetration helps the foreign trade management industry cope with a variety of challenges
- CDC (change data capture technology), a powerful tool for real-time database synchronization
- Linux server development, SQL statements, indexes, views, stored procedures, triggers
- 探索干货篇!Apifox 建设思路
- 芯片 設計資料下載
猜你喜欢

Few shot Learning & meta learning: small sample learning principle and Siamese network structure (I)

Network learning (II) -- Introduction to socket

2022 Inner Mongolia latest advanced fire facility operator simulation examination question bank and answers

Shell 脚本的替换功能实现

JS quick start (I)

uniapp 移动端强制更新功能

调用 pytorch API完成线性回归

Network learning (I) -- basic model learning

Empire CMS collection Empire template program general

Notes on PHP penetration test topics
随机推荐
通俗易懂单点登录SSO
青龙面板-今日头条
Linux server development, MySQL transaction principle analysis
dash plotly
Paddlepaddle 29 dynamically modify the network structure without model definition code (relu changes to prelu, conv2d changes to conv3d, 2D semantic segmentation model changes to 3D semantic segmentat
Who has docker to install MySQL locally?
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
Linux server development, redis source code storage principle and data model
【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
复杂网络建模(一)
Thinkcmf6.0 installation tutorial
Network learning (I) -- basic model learning
Complex network modeling (II)
青龙面板--整理能用脚本
JS cross browser parsing XML application
Linux server development, detailed explanation of redis related commands and their principles
Linux server development, MySQL index principle and optimization
These five fishing artifacts are too hot! Programmer: I know, delete it quickly!
【数字IC验证快速入门】14、SystemVerilog学习之基本语法1(数组、队列、结构体、枚举、字符串...内含实践练习)
Few shot Learning & meta learning: small sample learning principle and Siamese network structure (I)