实验8 分析一个奇怪的程序

assume cs:codesg

codesg segment

        mov ax,4c00h
        int 21h

start:  mov ax,0
    s:  nop
        nop

        mov di,offset s
        mov si,offset s2
        mov ax,cs:[si]
        mov cs:[di],ax

    s0: jmp short s

    s1: mov ax,0
        int 21h
        mov ax,0

    s2: jmp short s1
        nop

codesg ends
end start

我们编译链接运行这个程序,发现程序能够正常返回,所以说

mov ax,4c00h
int 21h

这两条语句一定有执行。

Screen Shot 2018-09-19 at 7.11.57 pm

Screen Shot 2018-09-19 at 7.16.40 pm

注:f6eb 在内存中存储为ebf6ebf6 也就是 jmp short s1 的机器码,eb 代表 jmpf6 是偏移地址的补码表示,转化成十进制为 -10

Screen Shot 2018-09-19 at 7.33.43 pm

注:机器码 ebf6 表示从该处往上跳十个字节。因为该指令(ebf6)长度为两个字节,该指令执行后 IP 寄存器的值为 8+2+(-10)=0

Screen Shot 2018-09-19 at 7.45.20 pm

程序正常结束:

Screen Shot 2018-09-19 at 8.07.58 pm

附:小甲鱼视频讲解

posted @ 2018-09-19 20:16  houhaibushihai  阅读(406)  评论(1编辑  收藏  举报