;本实验是对JMP指令运用的考核,JMP短转移是移动IP位移,而不是移动到JMP所指的标号处
;Name: 实验8
;测试:该程序是否能正确返回
;AX=0000 BX=0000 CX=0023 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
;DS=0BA7 ES=0BA7 SS=0BB7 CS=0BB7 IP=0005 NV UP EI PL NZ NA PO NC
;0BB7:0005 B80000 MOV AX,0000
assume cs:codeseg
codeseg segment
mov ax, 4c00h
int 21h
start:
mov ax, 0 ;程序入口,IP = 0005
s: nop ;IP = 0008 90
nop ;IP = 0009 90
mov di, offset s ;IP = 000A mov di, 0008
mov si, offset s2 ;IP = 000D mov si, 0020
mov ax, cs:[si] ;IP = 0010 将CS:0020内容传给AX
mov cs:[di], ax ;IP = 0013
;这4条指令是将s2处指令(EBF6)传到CS:0008处,正好覆盖了两个NOP字节
;CPU执行到这里,CS:0008 0009的内容为EBF6.继续往下执行
s0:
jmp short s ;IP = 0016 (IP位移) = 0008H - 0018H = -16D(-10H)机器码为EBF0
;跳到CS:0008处执行.由于CS:0008处内容为EBF6,故跳转后就执行EBF6
;EBF6执行后,IP = 000A.但EBF6作用为将IP向前移10个字节,即跳转到mov ax,4c00h处
s1:
mov ax, 0 ;0BB7:0018
int 21h ;IP = 000B INT 21H机器码为 CD21,占2个字节
mov ax, 0 ;IP = 000C
s2:
jmp short s1 ; IP = 0020 (IP位移) = 0018H - 0022H = -10D 机器码为EBF6
nop ; IP = 0022
codeseg ends
end start ;end伪指令通知汇编程序的结束,start标号说明程序从标号start处开始
阅读(5143) | 评论(1) | 转发(0) |