本文为《汇编语言程序设计》1105小节例程。点击链接…进课程主页。
编程:将data段中的第一个字符串复制到它后面的空间中。
data segment
db 'Welcome to masm!'
db 16 dup (0)
data ends
程序:
code segment
start: mov ax,data
mov ds,ax
mov si,0
mov di,16
mov cx,8
s: mov ax,[si]
mov [di],ax
add si,2
add di,2
loop s
mov ax,4c00h
int 21h
code ends
end start
用串传送指令
assume cs:code, ds:data
data segment
db 'Welcome to masm!'
db 16 dup (0)
data ends
code segment
start:
mov ax,data
mov ds,ax
mov si,0
mov es,ax
mov di,16
mov cx ,16
cld
s: movsb
loop s
mov ax,4c00h
int 21h
code ends
end start
另外一个功能相同的程序
assume cs:code, ds:data
data segment
db 'Welcome to masm!'
db 16 dup (0)
data ends
code segment
start:
mov ax,data
mov ds,ax
mov si,0
mov es,ax
mov di,16
cld
mov cx,8
rep movsw
mov ax,4c00h
int 21h
code ends
end start
用rep指令重复串传送
任务:用串传送指令,将F000H段中的最后16个字符复制到data段中。
assume cs:code, ds:data
data segment
db 16 dup (0)
data ends
code segment
start:
mov ax,0f000h
mov ds,ax
mov si,0ffffh
mov ax,data
mov es,ax
mov di,15
mov cx,16
std
rep movsb
mov ax,4c00h
int 21h
code ends
end start