当前位置:网站首页>Wang Shuang's Assembly Language Chapter 4: The First Program
Wang Shuang's Assembly Language Chapter 4: The First Program
2022-08-04 08:32:00 【Deteriorate_Kr】
文章目录
前言
现在我们将开始编写完整的汇编语言程序,Compile them into executable files with a compiler(如:*.exe文件),在操作系统中运行.
这一章,我们将编写第一个这样的程序.
一、一个源程序从写出到执行的过程
The brief process of an assembly language program from writing to final execution:
编写--〉编译--〉连接--〉执行

第一步:编写汇编源程序
使用文本编辑器(如Edit、记事本等),用汇编语言编写汇编源程序.这一步工作的结果是产生了一个存储源程序的文本文件.
第二步:对源程序进行编译连接


这一步工作的结果:产生了一个可在操作系统中运行的可执行文件.
第三步:执行可执行文件中的程序

二、源程序
下面就是一段简单的汇编语言源程序
1.伪指令

上图中出现了3种伪指令
(1) XXX segment →XXX end




(2) end

(3)assume,Suppose a certain segment of registers is associated with a certain segment in the program

2.program in source program



3.标号

4.程序的结构




5.程序返回


6. 语法错误和逻辑错误


三、编辑源程序

(2)
(3) 将程序保存为 c:\1.asm后,退出edit,结束对源程序的编辑

The file is saved in our mount directory.
四、编译,得到.obj文件

I directly mounted itMASM目录下,直接执行MASM.exe

我的1.asm文件也在MASM目录下



(5) 忽略了交叉引用文件的生成后,屏幕显示如下图


五、连接,得到.exe文件



The picture below is on your computer







番外




连接的作用

六、以简化的方式进行编译和连接,忽略中间文件



在link后面加上被连接的目标文件的路径、文件名,Add a semicolon to the end of the command line,按Enter键后,连接程序就对当前路径下的1.obj进行处理,在当前路径下生成可执行文件1.exe,并在过程中自动忽略中间文件的生成.
七、 1.exe的执行


八、谁将可执行文件中的程序装载进入内存并使它运行?


问题4.1


问题分析4.2


操作系统的外壳

问题4.1和4.2的分析

小结

九、程序执行过程的跟踪





(The shaded area is memory that has already been used)

注意:There is a step called relocation that we didn't cover above,因为这个问题和操作系统的关系较大,我们不作讨论.
总结







边栏推荐
猜你喜欢
![[Computer recording screen] How to use bandicam to record the game setting graphic tutorial](/img/a7/0ac5e2028c5f1b013da56b795143e7.jpg)
[Computer recording screen] How to use bandicam to record the game setting graphic tutorial

inject() can only be used inside setup() or functional components.

Distributed Computing Experiment 4 Random Signal Analysis System
![[NOI Simulation Competition] Paper Tiger Game (Game Theory SG Function, Long Chain Division)](/img/b7/21f82453576b81e64dafbc3975125f.png)
[NOI Simulation Competition] Paper Tiger Game (Game Theory SG Function, Long Chain Division)

8.2学习记录

RT-Thread Studio学习(十二)W25Q128(SPI)的读写

C语言strchr()函数以及strstr()函数的实现

IntelliJ新建一个类或者包的快捷键是什么?

JNI学习1.环境配置与简单函数实现

redis分布式锁的实现
随机推荐
redis分布式锁的实现
并查集介绍和基于并查集解决问题——LeetCode 952 按公因数计算最大组件大小
设计信息录入界面,完成人员基本信息的录入工作,
【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解
电脑系统数据丢失了是什么原因?找回方法有哪些?
[Computer recording screen] How to use bandicam to record the game setting graphic tutorial
Distributed Computing Experiment 1 Load Balancing
金仓数据库KingbaseES客户端编程接口指南-JDBC(7. JDBC事务处理)
解决循环依赖import cycle not allowed的最佳解决办法
How many assertion methods are commonly used in JMeter?
从零开始C语言精讲篇6:结构体
学会 Arthas,让你 3 年经验掌握 5 年功力
【我想要老婆】
金仓数据库KingbaseES客户端编程接口指南-JDBC(10. JDBC 读写分离最佳实践)
华为设备配置VRRP与NQA联动监视上行链路
小程序如何使用订阅消息(PHP代码+小程序js代码)
B站回应HR称“核心用户都是Loser”、求职者是“白嫖党”:已被劝退
powershell和cmd对比
【Attention】Dual Attention(DANet) & Fully Attention(FLA)
sql在字段重复时 对某个字段根据最新时间取数