当前位置:网站首页>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 
边栏推荐
- What if I don't know what to do after graduating from university?
- Resolved: initialize specified but the data directory has files in it Aborting
- 网络安全-VLAN和Tunk方法详解
- Idea running run and services
- LabVIEW program code update is slow
- 手机开户股票开户安全吗?开户需要准备什么?
- Keil serial port redirection
- SQL Server2005中SUM函数内嵌套IF语句
- app quits unexpectedly
- Minecraft 1.16.5模组开发(五十) 书籍词典 (Guide Book)
猜你喜欢

vs2019和sql

Record the problem that the system file cannot be modified as an administrator during the development process

nRF52832 GPIO LED

MAX6675 usage notes

線程池——C語言

Keil plug-in Usage Summary

Can introduction

Network security - packet capture and IP packet header analysis

解决:div获取不到键盘事件

FreeRTOS timer group
随机推荐
Out of class implementation of member function of class template
Network security ARP protocol and defense
js创建pdf文件
Record the problem that the system file cannot be modified as an administrator during the development process
Stm32g0 porting FreeRTOS
套接字socket编程——UDP
Qstring to const char*
next InitializeSecurityContext failed: Unknown error (0x80092012) - 吊销功能无法检查证书是否吊销。
神经网络计算量及参数量
The class imported by idea import clearly exists, but it is red?
Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)
Thread pool - C language
Introduction to ecostruxure (1) IEC61499 new scheme
手机开户股票开户安全吗?开户需要准备什么?
Test enumeration types with STM32 platform running RT thread
Installation du serveur linux redis
Win10 step pit - power on 0xc0000225
SQL Server2005中SUM函数内嵌套IF语句
大学刚毕业不知道做什么工作怎么办?
踩坑记录:supervisor 日志返回信息:redis扩展未安装