当前位置:网站首页>Introduction to assembly language (1)
Introduction to assembly language (1)
2022-07-27 19:03:00 【Miracle Fan】
Introduction to assembly language (1)
List of articles
1. Configure the compilation environment
1.1 Software download
1.1.1DOSBOX download
Enter the official website and select the corresponding version to download . Download path :DOSBox, an x86 emulator with DOS

1.1.2 DEBUG、TASM、TLINK download
link :https://pan.baidu.com/s/16Z8IeUGzgaJriKRItQ5oLw
Extraction code :F777
1.2 Environment configuration
take debug、tasm、tlink After downloading, move to the same folder , If it is convenient, you can also set this folder as the program storage folder .

Then set the environment as follows :

open dosbox, It will be as shown in the figure below . Then you can enter instructions on the command line

1.3 Generate exe file
To write .asm file , Or write .txt file , Then change the suffix to .asm
Enter the following command on the above command line , take .asm The documents are compiled as .obj file

Enter the following command again , Will make use of .obj File connection generation .exe file

2. Source program structure
[.586] ; Select instruction set , Choose which CPU To perform
DATA SEGMENT ; Define data segments
…… ; Data definition pseudo instruction sequence
DATA ENDS
STACK SEGMENT ; Define stack segments
…… ; Data definition pseudo instruction sequence
STACK ENDS
CODE SEGMENT ; Define code snippets
ASSUME CS:CODE,SS:STACK,DS:DATA; Segment register description , Code snippets are essential , It is convenient to list all the pictures directly
START:
MOV AX,DATA ; Take the base address of the data segment
MOV DS,AX ; Establish addressability of data segment
……
MOV AH,4CH ; return DOS operating system
INT 21H
CODE ENDS
END START ; When the source program is the main module , Start label is required START
3. Common pseudo instruction statements
3.1 Logical segment definition pseudo instruction
Segment definition statement :
from SEGMENT Statements begin , To ENDS End of sentence .
Segment register description statement :
ASSUME Segment register : Paragraph name
Explain which register is used to address the segments defined in the source program
Set the initial value of the segment register
1. Use SEG The operator finds the segment base address of the logical segment MOV AX,SEG DATA ;DATA Data segment name MOV DS,AX 2. Assign the segment name directly to the segment register MOV AX,DATA MOV ES,AX
3.2 Data definition directives
1. Constant definition pseudo instruction
Don't allocate memory
Assignment pseudo instruction EQU
Use EQU Pseudo instructions define symbolic constants , Its value cannot be changed later , That is equivalent to c Linguistic const
Equal sign pseudo instruction ——=
Its symbolic name can be redefined , The definition statement can be placed in any logical segment
2. Variable definition pseudo instruction
DB/DW/DD Data item
- DB It is to allocate a byte unit for each character from left to right
- DW Assign a word unit for every two characters
- DD Assign every four characters 1 Double word units
$ by When front The earth site meter Count device Of value , Meeting a take When front Inside save The earth site {\color{RED} \mathrm{ Is the value of the current address counter , Will get the current memory address } } by When front The earth site meter Count device Of value , Meeting a take When front Inside save The earth site
3.3 Procedures and macros define pseudo instructions
1. Procedure definition directives
The process of PROC [ attribute ]
……
[RET]
……
RET
The process of ENDP
Pass in the main program CALL call
2. Macro definition directives
Macro name MACRO [ Form parameter table ]
……
ENDM
The label in the macro body should be LOCAL Pseudo instructions are described as local labels , To avoid multiple calls , A definition error occurred ; Hongzhankai ,LOCAL The definition label is defined by ??0000 To ??FFFF To replace .
Main program passed CALL call
2. Macro definition directives
Macro name MACRO [ Form parameter table ]
……
ENDM
The label in the macro body should be LOCAL Pseudo instructions are described as local labels , To avoid multiple calls , A definition error occurred ; Hongzhankai ,LOCAL The definition label is defined by ??0000 To ??FFFF To replace .
边栏推荐
猜你喜欢

Blog Garden beautification tutorial

Redis annotation

MySQL 03 高级查询(一)

MySQL 02 initial experience

Matplotlib (basic usage)

Multifunctional wireless remote control moxibustion instrument chip dltap703sd

v-if,v-else,v-for

「测试新手百科」5 分钟快速上手Pytest 自动化测试框架

Commodity comment information and comment information classification

Unity学习笔记(刚体-物理-碰撞器-触发器)
随机推荐
SSM项目使用过滤器实现登录监听
Hash、Set、List、Zset、BitMap、Scan
瑞吉外卖sql表
Leetcode brushes questions the next day
Collection of software design suggestions of "high cohesion and low coupling"
Kinect for Unity3D——BackgroundRemovalDemo学习
I'm stupid. When completable future is used with openfegin, it even reports an error
Talking about JVM (frequent interview)
贪心法,拟阵和亚模函数(refer)
Some advice for NS2 beginner.
MicaZ+Tinyos学习笔记(1)
Unity学习笔记(刚体-物理-碰撞器-触发器)
LeetCode 刷题 第一天
Nodejs 模板引擎ejs
Here are all the MySQL interview questions you can't expect (the latest version of 2022)
商品评论信息与评论信息分类
MySQL 05 存储过程
Imitation thread deduction
Matplotlib (basic usage)
Join query and subquery