当前位置:网站首页>Assembly learning register
Assembly learning register
2022-06-30 07:22:00 【Yangxiaomeng】
List of articles
Two 、 register ( With 8086 As a prototype )
1. General registers
With 8086cpu For example , All of its registers are 16 Bit , It can be stored 2 Bytes .
AX BX CX DX It's called a general-purpose register , Used to store general data
AX Can be divided into AH and AL ( according to 16 The height of the bit )
BX Can be divided into BH and BL
CX Can be divided into CH and CL
DX Can be divided into DH and DL
With AX For example Look at the picture below

2. The storage of words in registers
8086cpu The following can be handled at one time 2 Data of three sizes :
1. byte (byte),1byte = 8bit, Can exist 8 Bit register
2. word , A word consists of two bytes , The two bytes are called the upper byte and the position byte of the word respectively , Stored separately in AH and AL in
3. Preliminary knowledge of assembly instructions
Assembly instructions or register names are not case sensitive
| Assembly instruction format | control cpu Completed operation | Use the syntax of high-level language to describe |
|---|---|---|
| mov ax( Register name ),18( data ) | take 18 Into the register AX | AX=18 |
| mov ax( Register name ),bx( Register name ) | take bx The data in is sent to ax in | ax=bx |
| add ax( Register name ),18( data ) | Register ax The value of plus 18 | ax = ax + 18 |
| add ax( Register name ),bx( Register name ) | take ax and bx Add the data in | ax = ax + bx |
4. 16 Bit structure cpu
8086cpu yes 16 Bit structure ,16 Bit structure means :
1. The arithmetic unit can handle at most 16 Bit data
2. The maximum width of the register is 16 position
3. The path between the register and the arithmetic unit is 16 position
5. 8086cpu The way to give a physical address
8086cpu There is... On the outside 20 Bit address bus , The addressing capability reaches 1mb(2^20B = 1MB)
8086cpu The internal is 16 Bit structure , Addressing capability is 64KB(2^16B)
8086cpu Use... Internally 2 individual 16 A bit address is synthesized by an address adder 20 For physical address
The workflow is as follows :

Principle of address adder : Physical address = Segment address *16( Move left 4 position )+ offset
1. A binary shift of data to the left n position , Equivalent to this data 2 Of n Power ,16 A into 20 position (2^16 * 2^4 = 2^20)
2.20 position +16 position = 20 position analogy Ten + hundred The high position is still 100
6. The concept of paragraph

cpu The physical address is formed in this way
Due to the physical address = Segment address *16 + offset
The starting address of the segment = Segment address *16 ( by 16 Multiple )
The offset address is 16 position (64KB), So the maximum length of a segment is 64KB( Left offset or right offset )
7. cs and ip
The segment register stores the segment address ,8086 There is CS DS SS ES 4 Segment registers , With cs For example
cs: Code segment register
ip: Instruction pointer register
8086cpu Will be with M(cs The content of )*16+N(ip The content of ) Is the starting physical address , Read instructions and execute

8086cpu General workflow :
1. Through the address adder cs:ip Turn into 20 Bit address .
2. ip = ip + The length of the read instruction ( action register , data 3 byte , action register register 2 byte )
3. Execution instruction repeat 1
8086cpu Initial value setting during startup or reset cs=FFFFH IP=0000H
8. modify cs and ip Instructions
Programmer pairs cpu Only by modifying the value of the register
mov Instructions : Send instructions mov ax ,123 take 123 The value is placed in ax in , Most registers can be modified by this instruction
jmp Instructions : Format => jmp Segment address : offset jmp Some legal register
Such as : 1. ax = 1000H
2. perform jmp 2000H:0003H here : cs=2000H ip=0003H ( Directly modifying cs ip Value )
3. Re execution jmp ax here ip The value of is 2000H ( Modify with the value of the register ip Value )

Execute the process : Memory value =cs*16 + ip ip = ip + Memory unit ( byte )
1. Initial value cs=2000H IP=0000H, cs*16 + ip = 20000H, perform B8 22 66(mov ax,6622H), ip=ip+3=0003H
2. cs*16 + ip = 20003H, perform EA 03 00 00 10(jmp 1000:3) ip=ip+5=0008H
3. 2 take cs,ip Reset cs=1000H ip=0003H cs*16 + ip = 10003H, perform B8 00 00(mov ax,0000),ip=ip+3=0006H
4. cs*16 + ip = 10006H perform 8B D8(mov bx,ax), ip=ip+2=0008H
5. cs*16 + ip = 10008H perform FF E3(jmp bx) , ip=ip+2=000AH
6. 5 take ip=bx value , 4 take ax Value is assigned to bx,3 take ax Set up 0000 therefore ip by 0000 cpu from 10000H Start reading
9. Code segment
A code segment is a contiguous segment of a defined memory , Used to store code , You can set the cs and ip value , Enable code snippets to execute , If the code segment is 123B0H~123B9H Set up cs=123BH IP=0000H, You can make cpu Execute the code snippet 
边栏推荐
- Linux服务器安装Redis
- Stm32g0 porting FreeRTOS
- 【最全】linux服务器上安装Mysql
- Detailed analysis of message signals occupying multiple bytes and bits
- Install go language development tools
- JS create PDF file
- Calculation and parameter quantity of neural network
- halcon:读取摄像头并二值化
- TC397 QSPI(CPU)
- Network security - detailed explanation of VLAN and tunk methods
猜你喜欢

2021-07-02

Next initializesecuritycontext failed: unknown error (0x80092012) - the revocation function cannot check whether the certificate is revoked.

Network security - packet capture and IP packet header analysis

TC397 QSPI(CPU)

Local unloading traffic of 5g application

Class template case - encapsulation of array classes

Out of class implementation of member function of class template

Swiftui creates a beautiful custom press feedback button

网络安全-抓包和IP包头分析

Calculation and parameter quantity of neural network
随机推荐
Stm32g0 and FreeRTOS learning summary
The most convenient serial port screen chip scheme designed at the charging pile in China
Qtcreator debug code after configuring CDB debugger view variable value display card
Win10踩坑-开机0xc0000225
【已解决】ERROR 1290 (HY000): Unknown error 1290
線程池——C語言
How to use string branches for switch case
记录开发过程中无法使用管理员身份修改系统文件问题
Thread network
The maximum expression in Oracle database message list is 1000 error
Stm32g0 porting FreeRTOS
Can introduction
对占用多字节和位的报文信号解析详解
Network security - single arm routing, DHCP relay and ICMP Protocol
Determine whether the picture is in JPG picture format
Minecraft 1.16.5 module development (50) guide book
QT elementary notes
Swiftui creates a beautiful custom press feedback button
Linux服務器安裝Redis
2022年6月29日--使用C#迈出第一步--使用 C# 中的“if”、“else”和“else if”语句向代码添加决策逻辑