当前位置:网站首页>Wang Shuang assembly language detailed learning notes 3: registers (memory access)
Wang Shuang assembly language detailed learning notes 3: registers (memory access)
2022-07-28 04:38:00 【Deteriorate_ Kr】
List of articles
- Preface
- 3.1 Storage of words in memory
- 3.2 DS and [address]
- 3.3 The transmission of words
- 3.4 mov、add、sub Instructions
- 1.mov、add、sub Instructions will affect the contents of registers
- 2. and cmp It's a comparison command ,cmp The function of is equivalent to the subtraction instruction , Just don't save the results .cmp After the command is executed , Will affect flag register . Other related instructions know the comparison result by identifying these affected flag register bits .
- 3.5 Data segment
- 3.1~3.5 Summary
- Detection point 3.1
- 3.6 Stack
- 3.7 CPU Stack mechanism provided
- 3.8 The problem of stack top out of bounds
- 3.9 push、pop Instructions
- problem 3.7
- problem 3.8
- problem 3.9
- problem 3.10
- Overview of stack
- 3.10 Stack segment
- problem 3.11
- problem 3.12
- Summary of paragraph
- Detection point 3.2
Preface
In the 2 In the chapter , We mainly come from CPU From the perspective of how to execute instructions 8086CPU Logical structure of 、 The way to form a physical address 、 Related registers and some instructions .
In this chapter , Let's continue to learn a few registers from the perspective of accessing memory .
3.1 Storage of words in memory
1.CPU in , use 16 Bit register to store a word .
2. high 8 Bits hold the high byte , low 8 Bits hold the lower bytes .
3. When stored in memory , Since the memory unit is a byte unit ( A unit holds a byte ), A word is stored in two consecutive memory units , The low order byte of this word is stored in the low address unit , The high byte is stored in the high address unit .
For example 0 The address begins to store 20000(4E20H)
In the diagram above :
1. We use it 0、1 Two memory cells hold data 20000(4E20H).
2.0、1 Two memory units are used to store a word , These two units can be regarded as a starting address 0 Word unit of ( A memory unit for one word , from 0、1 Two byte units make up ).
3. For this word unit ,0 Unit No. is a low address unit ,1 Unit number is a high address unit , Then the font data 4E20H The lower bits of are stored in 0 Unit 2 , The high bits are stored in 1 Unit 2 .
4. In the same way 2、3 The number unit is regarded as a word unit , It starts at 2. Store data in this word unit 18(0012H), It's in 2 Unit number contains the lower byte 12H, stay 3 Unit number contains the high byte 00H.
3.1.1 Word unit
Word unit , That is to store a font data (16 position ) The memory unit of , It consists of two memory units with consecutive addresses . The high byte of font data in a high address memory unit , The low byte of font data in a low address memory unit .
In the future study , We will start at N The word unit of is abbreviated as N Address word unit . For example, a word unit consists of 2、3 Two memory units , Then the starting address of this word unit is 2, We can say this is 2 Address word unit .
3.1.2 Problem analysis



3.1.3 Summary
Conclusion :
Any unit of memory with two consecutive addresses ,N Unit number one and N+1 Unit No , Think of them as two memory units , It can also be regarded as an address N The high byte unit and the low byte unit in the word unit of .
3.2 DS and [address]
1.
2.
mov al,[0] explain You can also use mov The instruction sends the contents of a memory unit into a register . From which memory unit to which register ? Must be specified in the instruction . Registers are indicated by register people , The address of the memory unit is used to indicate . obviously , here mov The format of the instruction should be :mov Register name , Memory unit address .
“[…]” Represents a memory unit ,“[…]” Medium 0 Represents the offset address of the memory unit . We know , Only offset address can't locate a memory unit , So what is the segment address of the memory unit ? Instruction execution ,8086CPU Pick up automatically ds The data in is the segment address of the memory unit .

3.2.1 Problem analysis


3.3 The transmission of words

3.3.1 Problem analysis 1

After single step tracking , give the result as follows
↓
3.3.2 Problem analysis 2


3.4 mov、add、sub Instructions
1.mov、add、sub Instructions will affect the contents of registers
2. and cmp It's a comparison command ,cmp The function of is equivalent to the subtraction instruction , Just don't save the results .cmp After the command is executed , Will affect flag register . Other related instructions know the comparison result by identifying these affected flag register bits .


1.

Pictured above , use A Command at a preset address 073F:0100 It's about , In the form of a compilation mov ax,ds Write instructions , Reuse T Command execution , You can see the result of execution , Segment register ds The value in is sent to the register ax in . Through verification, we know ,“mov register , Segment register ” Is the correct instruction .
2.


The experimental results on your computer are shown in the figure below
↓


3.



10000H All the data in are 0,DS It should also be for 0,0 The data at the address is shown in the figure above .


The answer is that they cannot operate on segment registers .
3.5 Data segment



3.5.1 Problem analysis

3.1~3.5 Summary
- When a word is stored in memory , To use two consecutive address memory units to store , The low order byte of a word is stored in a low address unit , The upper byte is stored in the higher address unit .
- use mov Instruction to access memory cells , Can be in mov Only the address given in the instruction unit is offset , here , The segment address defaults to DS In the register .
- [address] Represents an offset address of address The memory unit of .
- When transferring font data between memory and register , High address units and high 8 Bit register 、 Low address units and low 8 Bit registers correspond to .
- mov、add、sub Is an instruction with two operands .jmp Is an instruction that has an operation object .
- You can speculate on your own , stay Debug New format of experimental instructions in .
Detection point 3.1
Be careful ,8086CPU All of the registers are 16 position , If you exceed it, you should round off the high position .
3.6 Stack


3.7 CPU Stack mechanism provided
Today's CPU All have stack design ,8086CPU No exception .8086CPU Provides instructions to access memory space by stack . It means , Based on 8086CPU When programming , You can use a piece of memory as a stack .



3.7.1 Two questions




It can be seen that ,8086CPU in , When entering the stack , The top of the stack grows from high address to low address .
Problem analysis 3.6

The answer is as follows :



pop The execution of instructions
pop ax The process of implementation and push ax Just the opposite


Be careful

3.8 The problem of stack top out of bounds

The following two figures describe the execution push、pop After the instruction , When the top of the stack exceeds the stack space .







3.8.1 Conclusion

3.9 push、pop Instructions




problem 3.7


problem 3.8


problem 3.9


problem 3.10



Conclusion



Overview of stack


3.10 Stack segment



problem 3.11



problem 3.12


Summary of paragraph









Detection point 3.2
边栏推荐
- Work fishing clock simulator wechat applet source code
- [Sylar] framework Chapter 22 auxiliary module
- Explain initialization list
- [Sylar] framework chapter -chapter21- environment variable module
- 低代码是开发的未来吗?浅谈低代码平台
- mysql分区表改造
- [Sylar] framework Chapter 8 timer module
- Go grpc: a solution of connection reset by peer
- Information system project manager (2022) - key content: Strategic Management (17)
- Important SQL server functions - date functions
猜你喜欢

Information system project manager (2022) - key content: Project Procurement Management (12)

上班摸鱼打卡模拟器微信小程序源码

低代码是开发的未来吗?浅谈低代码平台

Reading of the paper "attentional encoder network for targeted sentimental classification"

Seamless support for hugging face community, colossal AI low-cost and easy acceleration of large model

Ma Yi, Shen Xiangyang, Cao Ying's latest AI overview is hot! It took 3 months to build, netizens: required papers

Reading of seq2path: generating sentimental tuples as paths of a tree

Practice and thinking of AI standardization engine in pink client

23 openwrt switch VLAN configuration

Jupyter Notebook安装代码提示功能
随机推荐
10 more advanced open source command line tools
登录之后右上角改变 进入登录状态
NAT基本原理与私有IP
How to upgrade a pair of 12.2 RAC(primary) and a pair of 12.2 RAC(dataguard) to 19c
Nat fundamentals and private IP
【YOLOv5实战5】基于YOLOv5的交通标志识别系统-YOLOv5整合PyQt5
There are so many ways to view the web source code! Do you know?
What is the account opening process of qiniu business school? Is it safe?
【sylar】框架篇-Chapter8-定时器模块
If mongoose exists, it will be updated; if it does not exist, it will be added
[Sylar] framework -chapter12 bytearray module
21 openwrt kernel module changed to.Ko automatic loading
could only be written to 0 of the 1 minReplication nodes. There are 0 datanode(s) running and 0 node
Campus stray cat information recording and sharing applet source code
空间复杂度计算超全整理!!(一起手撕复杂度计算
关系数据库事务中的对象锁定
Important SQL server functions - string utilities
Information system project manager (2022) - key content: Information System Security Management (20)
Attempt method in laravel user authentication
Cmake usage base summary




