当前位置:网站首页>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.
边栏推荐
- Uniapp mobile terminal forced update function
- [matlab] when matrix multiplication in Simulink user-defined function does not work properly, matrix multiplication module in module library can be used instead
- WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
- 通俗易懂单点登录SSO
- Implementation of replacement function of shell script
- 微信小程序基本组件使用介绍
- Linux server development, redis protocol and asynchronous mode
- C language flight booking system
- The legend about reading the configuration file under SRC
- 追风赶月莫停留,平芜尽处是春山
猜你喜欢
LeetCode简单题之字符串中最大的 3 位相同数字
Dedecms collects content without writing rules
Custom class loader loads network class
王爽 《汇编语言》之寄存器
【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习
Qt学习26 布局管理综合实例
探索干货篇!Apifox 建设思路
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
Cnopendata American Golden Globe Award winning data
【数字IC验证快速入门】17、SystemVerilog学习之基本语法4(随机化Randomization)
随机推荐
Linux server development, redis protocol and asynchronous mode
追风赶月莫停留,平芜尽处是春山
[matlab] when matrix multiplication in Simulink user-defined function does not work properly, matrix multiplication module in module library can be used instead
Binary tree and heap building in C language
【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
Hisense TV starts the developer mode
Recursive method to construct binary tree from preorder and inorder traversal sequence
Myabtis_Plus
Rust versus go (which is my preferred language?)
The principle and implementation of buffer playback of large video files
Real time monitoring of dog walking and rope pulling AI recognition helps smart city
Search for an element in a binary search tree (BST)
力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
Implementation of replacement function of shell script
微信小程序基本组件使用介绍
MySQL multi column index (composite index) features and usage scenarios
JS quick start (I)
dash plotly
Quickly use Jacobo code coverage statistics
Ansible