当前位置:网站首页>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.
边栏推荐
- Real time monitoring of dog walking and rope pulling AI recognition helps smart city
- 【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
- JSON data flattening pd json_ normalize
- 复杂网络建模(二)
- Linux server development, SQL statements, indexes, views, stored procedures, triggers
- OpenJudge NOI 2.1 1752:鸡兔同笼
- 王爽 《汇编语言》之寄存器
- [Matlab] Simulink 自定义函数中的矩阵乘法工作不正常时可以使用模块库中的矩阵乘法模块代替
- 探索干货篇!Apifox 建设思路
- 让Livelink初始Pose与动捕演员一致
猜你喜欢

海信电视开启开发者模式

JS quick start (I)

JSON data flattening pd json_ normalize

让Livelink初始Pose与动捕演员一致
![[matlab] when matrix multiplication in Simulink user-defined function does not work properly, matrix multiplication module in module library can be used instead](/img/e3/cceede6babae3c8a24336c81d98aa7.jpg)
[matlab] when matrix multiplication in Simulink user-defined function does not work properly, matrix multiplication module in module library can be used instead

Ansible

复杂网络建模(一)

Main window in QT learning 27 application

Thinkcmf6.0安装教程

Linux server development, redis source code storage principle and data model
随机推荐
Linux server development, redis protocol and asynchronous mode
Merging binary trees by recursion
OpenJudge NOI 2.1 1752:鸡兔同笼
The zblog plug-in supports the plug-in pushed by Baidu Sogou 360
QT learning 28 toolbar in the main window
Complex network modeling (II)
Li Kou interview question 04.01 Path between nodes
Linux server development, detailed explanation of redis related commands and their principles
C语言队列
Example of file segmentation
Linux server development, MySQL stored procedures, functions and triggers
基于Pytorch 框架手动完成线性回归
通俗易懂单点登录SSO
Cnopendata American Golden Globe Award winning data
【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习
青龙面板--花花阅读
【踩坑系列】uniapp之h5 跨域的问题
Recursive method to construct binary tree from preorder and inorder traversal sequence
[UVM practice] Chapter 2: a simple UVM verification platform (2) only driver verification platform
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne