当前位置:网站首页>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 
边栏推荐
- Realization of dissolve effect in unity and its principle analysis
- 将本地电脑文件复制到虚拟机系统中详细方法
- Develop common dependency Libraries
- SwiftUI打造一款美美哒自定义按压反馈按钮
- [most complete] install MySQL on a Linux server
- Install go language development tools
- Qtcreator debug code after configuring CDB debugger view variable value display card
- 套接字socket编程——UDP
- 01 - embedded learning route and career planning: embedded basic knowledge and development process
- Use of ecostruxure (2) IEC61499 to establish function blocks
猜你喜欢

系统软件开发基础知识

How to use string branches for switch case

Test enumeration types with STM32 platform running RT thread
![[most complete] install MySQL on a Linux server](/img/5d/8d95033fe577c161dfaedd2accc533.png)
[most complete] install MySQL on a Linux server

Merge: extension click the El table table data to expand

B站首个UP主付费观看视频还是来了!价格“劝退”网友

Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)

Win10踩坑-开机0xc0000225

JS widget wave JS implementation of wave progress bar animation style

MAX6675 usage notes
随机推荐
The simulation interface does not declare an exception and throws an exception
Qstring to const char*
Deploying web projects using idea
【已解决】MySQL异常:ERROR 1045 (28000): Unknown error 1045,忘记初始密码
JS null judgment operators | and? Usage of
Idea running run and services
線程池——C語言
Basic knowledge of system software development
Test enumeration types with STM32 platform running RT thread
Swiftui creates a beautiful custom press feedback button
JS widget wave JS implementation of wave progress bar animation style
The class imported by idea import clearly exists, but it is red?
MAX6675 usage notes
[solved] failed! Error: Unknown error 1130
Promise async/await
js创建pdf文件
Network security ARP protocol and defense
grep命令用法
I graduated this year, but I don't know what I want to do
Cubemx completes STM32F103 dual serial port 485 transceiver transmission