assume cs:codesg
codesg segment
mov ax,4c00h ;ip=0
int 21h ;ip=3
start: mov ax,0 ;ip=5 ;程序入口
s: nop ;ip=8 ;经过运行以下代码,此处机器码 90 变成 EBF6
nop ;ip=9
mov di,offset s ;ip=10 di=8H
mov si,offset s2;ip=13 si=20H
mov ax,cs:[si] ;ip=16 ax = cs:20 传送了指令[jmp short s1]的机器码EBF6 到AX
mov cs:[di],ax ;ip=19 cs:8 = ax copy了数据 EBF6 而不是指令
s0: jmp short s ;ip=22 跳转到cs:8执行 jmp short s1
s1: mov ax,0 ;ip=24
int 21h ;ip=27
mov ax,0 ;ip=29
s2: jmp short s1 ;ip=32d=20H 机器码 EBF6 ;12-22 = -10 补码 11110110B 246D F6H
nop ;ip=34
codesg ends
end start
可以正确返回,运行结果:
执行ip=16 → ax = [jmp short s1] ip=19→cs:8 = [jmp short s1] ip=22→跳转到cs:8执行
(机器码跟原来的 EBF6 ,F6H=-10B) 向后移动10个字节 ip=0 → mov ax,4c00h int 21h |