用汇编语言查找字符
datarea segmenteng db 'lsfjslsun,sjflsjsunsaf,ljssdkjfdjsun'
disp db 'sun:'
dat db '$'
keyword db 'sun'
datarea ends
code segment
main proc far
assume cs:code,ds:datarea
start:
push ds
sub ax,ax
push ax
mov ax,datarea
mov ds,ax
begin:
mov ax,0
mov dx,disp-eng-2
lea bx,eng
compare:
mov di,bx
lea si,keyword
mov cx,3
repe cmpsb
jnz no
inc ax
no:
inc bx
dec dx
jnz compare
loop1:
mov ch,4
mov cl,4
lea bx,dat
loop2:
rol ax,cl
mov dx,ax
and dx,0fh
add dl,30h
cmp dl,30h
jle store
add dl,07h
store:
mov [bx],dl
inc bx
dec ch
jnz loop2
output:
lea dx,disp
mov ah,09h
int 21h
ret
main endp
code ends
end start
其他情况类似!