Assembly Experiment3

AIMS & PREPARATIONS of THIS EXPERIMENT:

1st point of this experiment:

realize the programme t1.asm in DOSBox (code as follow)

STEPS&SCREENSHOTS of THIS EXPERIMENT:

( 1 ). COMPILE, LINK, RUN and DEBUG the PROGRAM t1.exe

(I used the computer which installed Win7 in lab for the experment, the disks are not virtual)

1.Creating a txt file (23.txt) in d:\epr

2.Copy the code given above (t1.asm) into the file 23.txt

3.Compile the programto get the object file

compile under the Microsoft assembly compiler masm5.0

by using the original way showed in the book

I saved the compiled file (.OBJ file) at the folder epr in disk D (d:\epr\)

after the compilation finished, a new file 23.OBJ (Object File) appered in the folder epr

4.Link the object file (to get the run file)

link the object file by running the link.exe in masm folder

I also saved the run file (23.exe) in d:\epr\

after the linkage, the file 23.EXE appered in the folder epr in disk D

5.Run the exe file

we get the result: 36

6.Debug the run file 23.exe

① Using the command r to observe the numerical value saved in register cx and ds

we can easily view that a assosiation exists between the value in cx and dx : (cs)=(ds)+10H

② Checking the first two bytes of PSP,

because the PSP occupies  256bytes (100H) before the address of the program in the internal memory, and we can find the address of the first statement (MOV AH,02) is 15d9:0000, which is also the address of the program, so we set the address to 15c9:0000 (15d90H-100H=15c90H)

by using the command d, we can get the first two bytes of PSP, which is CD and 20 indeed

③ Disassembling the 23.exe by using the command u, observe the source code of 23.exe

④ Debug the program step by step, using the command t and r

r for command int to view the result

the program ends after (15D9:0014    INT 21)

at the 1st (15D9:0007    INT 21) the program gets a result---3

at the 2nd (15D9:0010    INT 21) the program gets a result---6

( 2 ). COMPILE, LINK and RUN the NEW PROGRAM

In this case, I use the DOXBox0.74-2 for Win10 to realize the compilation

1.Creating a txt file (23.txt) in d:\epr

2.Using masm.exe and link.exe to compile and link the 233.txt

after the compilation and linkage, 233.OBJ and 233.EXE appears in the folder E

then run the 233.exe in the dosbox

we find that nothing appears on the screen

then we use the command cls to clear the screen, and run the 233.exe again

now we can get the result of 233.exe ------- number 36, which color is red

3.Change the number in the file 233.txt, after compilation and linkage, check the chage of its result.

compared with the original 233.txt showed before,

we changed the hex number in line 6 and line 8

mov [bx], 0433h ==> mov [bx], 0432h

mov [bx], 0436h ==> mov [bx], 0439h

the new exe file also can‘t directly been showed on the screen

by using the command cls, and run the program again, number 29, which color is also red, appers on the top of the screen

4.Change the number in the file 233.txt again, after compilation and linkage, check the chage of its result.

in this case we change the following statement:

(compared with the original file, changes also impled at line 6 and line 8)

mov [bx], 0433h ==> mov [bx], 0333h

mov [bx], 0436h ==> mov [bx], 0336h

same way of compilation&linkage

as well as same invisible result

and same way to uncover it

now we can see number 36 appears on the screen, but, its color is cyan

SUMMARY & REVIEW of THIS EXPERIMENT :

In thisexperiment, I grasped the method of compiling, linking and running of the assembly program. Especially creating a txt file with statement in it, and turn the unexecutable file to executable file by using the tool masm.exe and link.exe: masm.exe to change the txt file to object file (.OBJ file) while link.exe to change the object file to executable file (.EXE file).

Hoever, there still confusions remained in this experiment:

First, why using statement ( mov bx, 0       mov [bx], 0433h) instead of (mov [0], 0433h) ?

one explanation to question1 is using the statement ( mov bx, 0      mov [bx], 0433h)  can

have a positive influence on the circulation later

Second, why the result of some exe file cannot been showed on the screen immediately after execute. Instead, we need to clear the screen and run the file again to get the answer.

one realiable explanation to question 2 is that bugs exists while running the program in

doxbox in some platforms which I think includes Windows 10

Third, why the answer we get after clearing the screen and running the executable file again showed on the top of the screen? Does it belong to the execution command we typed before clearing the screen or after clearing the screen?

I assume that the answer belongs to the command after clearing screen, but why the result

appers on the top of the window still bothers me

原文地址:https://www.cnblogs.com/mrorangerabbit/p/9977477.html

时间: 2024-11-02 01:19:14

Assembly Experiment3的相关文章

Linux C中内联汇编的语法格式及使用方法(Inline Assembly in Linux C)

在阅读Linux内核源码或对代码做性能优化时,经常会有在C语言中嵌入一段汇编代码的需求,这种嵌入汇编在CS术语上叫做inline assembly.本文的笔记试图说明Inline Assembly的基本语法规则和用法(建议英文阅读能力较强的同学直接阅读本文参考资料中推荐的技术文章 ^_^). 注意:由于gcc采用AT&T风格的汇编语法(与Intel Syntax相对应,二者的区别参见这里),因此,本文涉及到的汇编代码均以AT&T Syntax为准. 1. 基本语法规则 内联汇编(或称嵌入汇

question --> maven assembly plugin 修改文件默认权限

使用maven assembly plugin插件添加执行脚本时,发现默认权限为644,还需要手动添加执行权限.这很麻烦,于是查看文档 官方文档 http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_fileSet fileMode String Similar to a UNIX permission, sets the file mode of the files included. THIS IS

为什么.Net平台不支持程序集卸载(Assembly.Unload)?

我们知道在.net平台中反射提供了在运行时动态的获得程序或程序集中每一个类型(包括类.结构.委托.接口和枚举等)的成员和成员的信息,从而使得我们开发人员在运行时能够利用这些信息构造和使用对象.我们知道反射中可以通过System.Reflection.Assembly命名空间下的 Assembly.Load 动态的加载程序集信息,获取我们想要的一切信息.那么当我们动态加载完程序集并对其使用完之后,我们想卸载掉它,不想在内存中留下垃圾信息,这时我们发现Assembly并没有提供Assembly.Un

.NET 程序集Assembly使用

概述 一直以来,我们都在用C#编写程序,编写程序的时候,我们用到继承.多态.接口以及泛型,我们也都明白子类可以继承抽象类,并能够重写父类的抽象方法,可是大家是否想过,如下几个问题: 1.凡树必有根和叶,类的继承也如此,如何通过程序集查找所有继承父类的之类的程序集名称? 2.如果程序B被其他程序调用,如何通过程序集查询调用B的所有程序? 3.如何查询当前项目通过添加引用了哪些程序集? 带上上面的三个问题,我们来学习下.NET 程序集 Assembly. 查询继承父类的程序集合BaseType .N

[转] ASP.NET WEB API程序在VS启动或发布到IIS后启动后发生 - Could not load file or assembly 'System.Web.Http.WebHost’异常,无法正常访问

Just do Copy Local = true in the properties for the assembly(System.Web.Http.WebHost) and then do a redeploy, it should work fine. http://stackoverflow.com/questions/20323107/could-not-load-file-or-assembly-system-web-http-webhost-after-published-to-

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 问题描述: 再windows server 2008 r2 环境下搭建.net网站 ,运行是IIS7.0提示以上问题 解决方案: 这里需要注册一下ASP.NET 4.

强名称程序集(strong name assembly)——为程序集赋予强名称

引言: 在以前的项目开发中,在程序集中见到过一个后缀为*.snk的文件,当时看这个文件的图标,感觉可能是企业内部保护版权啥的一种方式. 一,强程序集解决了哪些问题? 1,唯一标识一个程序集 2,放置程序集被仿冒和被篡改. 3,可以部署到全局程序集缓存(GAC:GlobalAssembly Cache)中:在将强名称程序集不熟在GAC当中以后,强名称程序集也可以称为共享程序集(shared assembly) 二,强名称与GAC 强名称: 定义了一个规则,不单单以文件名来区分程序集,这个规则就是强

反射 学习笔记(一) 基本概念(元数据 程序集 Assembly Type)

一.元数据 可以理解为描述信息(类.类中的成员.成员的参数及返回值). 二.程序集 我们所写的所有代码都会通过编译器编译到程序集(.exe或.dll)文件中 ,并在运行时以[Assembly对象]方式加载到内存中运行 运行时 程序集(.exe或.dll)加载到内存中就是Assembly对象 类(class.Interface)加载到内存中就是Type对象 类的成员(方法.字段.属性.事件)加载到内存中分别是 MethodInfo.PropertyInfo.FieldInfo.EventInfo对

Could not load file or assembly 'System.Core, Version=2.0.5.0 和autofac冲突的问题

在部署到iis的时候会出现这个状况.   这个软件(NDP40-KB2468871-v2-x64) 解决:下载安装这个补丁 http://support.microsoft.com/kb/2468871 http://www.microsoft.com/zh-cn/download/confirmation.aspx?id=3556 http://download.microsoft.com/download/2/B/F/2BF4D7D1-E781-4EE0-9E4F-FDD44A2F8934/