汇编程序:植入程序的程序(二)

【任务】用串传送指令,将beg_copy到end_copy的代码复制到0:200H处

assume cs:codeseg
codeseg segment
start:
     ...
beg_copy:
    mov ax, 0
    add ax, ax
    wait
end_copy: nop

codeseg ends
end start

【说明】此任务在植入程序的程序中已经给出一种解决方案,本文的方案更为简单

【参考解答】

assume cs:codeseg
codeseg segment
start:
    mov ax, cs
    mov ds, ax
    mov si, offset beg_copy

    mov ax, 0
    mov es, ax
    mov di, 200H

    mov cx, offset end_copy - offset beg_copy
    cld
    rep movsb

    mov ax, 4c00h
    int 21h

beg_copy:
    mov ax, 0
    add ax, ax
    wait
end_copy: nop

codeseg ends
end start
上一篇:汇编程序:计算分段函数


下一篇:1.2 - C#语言习惯 - 用运行时常量readonly而不是编译期常量const