实验3 编程、编译、连接、跟踪
(1) 将下面的程序保存为t1.asm文件,将其生成可执行文件t1.exe。assume cs:codesg
codesg segment
mov ax,2000H
mov ss,ax
mov sp,0
add sp,10
pop ax
pop bx
push ax
push bx
pop ax
pop bx
mov ax, 4c00h
int 21H
codesg ends
end
解:
1.编程:随便找个文本编辑器将以上代码输入并保存为.asm文件,甚至用系统自带的txt改后缀为.txt也行
2.编译:打开DOSBox,输入
mount c d:\try
c:
masm t1.asm
直接回车三次
3.连接:输入
link t1.obj
直接回车三次
得到t1.exe
(2) 用DEBUG跟踪t1.exe的执行过程,写出每一步执行后,相关寄存器的内容和栈顶内容。
解:
输入
debug t1.exe
-t
AX-Z000 BX=0000 CX=0014 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=081E ES=081E SS=082D CS =082E IP=0003 NU UP EI PL NZ NA PO NC
082E :0003 BEDO MOV SS, AX
-t
AX=2000 BX=0000 CX=0014 DX-0000 SP=0000 BP =0000 SI =0000 DI=0000
DS=031E ES=0B1E SS=2000 CS=082E IP=0008 NU UP EI PL NZ NA PO NC
082E :0003 830404ADD SP ,+04
-t
AX-Z000 BX=0000 CX=0014 DX=0000 SP=0004 BP=0000 SI=0000 DI-0000
DS=081E ES=081E SS=2000 CS-08ZE IP=000B NU UP EI PL NZ NA PO NC
082E:OO0B 58 POP Ax
-t
AX=0000 BX=0000CX=0014 DX=0000 SP =0006 BP=0000 SI=0000 DI=0000
DS=081E ES=031E SS =2000 CS=082E IP=000C NU UP EI PL NZ NA PO NC
082E:000C 5B POP BX
(太长就不全放出了)
(3)PSP的头两个字节是CD20,用DEBUG加载t1.exe,查看PSP的内容。
解:
-u 081e:0
081E:0000 CD20 INT 20//看到这个int 20就应该想到和源程序 int 21的关系
081E:0002 FF9FOOEACALL FAR
081E:0006 FTTT ??? DI
081E:0008 AD LODSW
031E :0009 DE4F03 FIMULWORD PTR
081E:000C A3018A MOV , AX
081E :000F 03A30117ADD SP,
031E :0013 03A30192ADD SP , CBP+DI+9201 ]
081E:0017 0101 ADD .AX
081E:0019 0101 ADD ,AX
081E:001B 0002 ADD ,AL
081E:001D FTTT ??? DI
081E:001F FTTT ??? DI
-d 081e:0 100
0B1E :0000 CD 20 FF9F 00 EA FFFF-ADDE4F03 A3 01 8A 03
081E :0010 A3 01 17 03 A3 01 92 01-01 010100 02FFFFFF
081E :0020 FFFFFFFFFFFFFFFF-FFFFFFFF14083556
031E :0030 A301140018001E08-FFFFFFFF00000000
031E :0040 0500000000000000-00000000000000 09
081E :0950 CD 21 CB 0909090909-09090909090009 09
081E :0060 0009090909090909-0909090909090009
081E :0070 0000000000000000-0009090909090900
081E :0080 00OD7431ZE657865-0D00000000000000
031E :0090 0009090909090909-0909090909090009
081E :00A0 0009090909090909-0909090909090009
081E :OOB00009090909090909-0909090909090009
081E :00CO 0000000000000000-0009090909090900
031E :00D0 0000000000000000-0000000000000000
031E :OOE00009090909090909-0909090909090009
081E :O0FO 0009090909090909-0909090909090009
081E:0100 B8
如果-u 082e:0就可以看到源程序 点个赞
页:
[1]