1、将数据段中定义的字符串“HELLO!”传送到附加段中。
data segment
string1 db 'HELLO!'
ChrCoun equ $-string
data ends
extra segment
string2 db ChrCoun dup(?)
extra ends
code segment
assume cs:code,ds:data,es:extra
start:mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
lea si,string1
lea di,string2
mov cx,ChrCoun
cld
rep movsb
mov ah,4ch
int 21h
code ends
end start
2、使用LODSB指令将字符串中的‘HELLO!’中的第1个字符和第3个字符分别存入bl和bh中
data segment
string db 'HELLO!'
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
lea si,string
cld
lodsb
mov bl,al
lodsb
lodsb
mov bh,al
mov ah,4ch
int 21h
code ends
end start
3、在ES段存放10个ASCII码,搜索‘E’,若找到则记下搜索次数及存放地址,并将AH置1,否则AH清零。
extra segment
string db ‘ab12345Ecd’
extra ends
code segment
assume cs:code,ds:data,es:extra
start:mov ax,extra
mov es,ax
lea di,string
mov cx,10
cld
repnz scasb
jcxz not_E
mov cx,di
sub cx,offset string ;搜索次数
dec di ;存放地址
not_E:
xor ah,ah
Exit:
mov ah,4ch
int 21h
code ends
end start
温馨提示:答案为网友推荐,仅供参考