第一种方法:用循环实现,代码如下:
data segment
STRING DB 'The date is FEB&03'
count equ $-string
data ends
code segment
assume ds:data,cs:code
start:
mov ax,data
mov ds,ax
lea si,string
mov cx,count
next:
cmp byte ptr [si],'&'
jnz next1
mov byte ptr [si],20h
next1:
inc si
loop next
mov ax,4c00h
int 21h
code ends
end start
第二种方法:用串处理指令实现,代码如下:
data segment
STRING DB 'The date is FEB&03'
count equ $-string
data ends
code segment
assume ds:data,es:data,cs:code
start:
mov ax,data
mov ds,ax
mov es,ax
lea di,string
mov cx,count
mov al,'&'
cld
repnz scasb
jnz tj
mov byte ptr [di-1],20h
tj:
mov ax,4c00h
int 21h
code ends
end start