注册 登录
编程论坛 汇编论坛

用汇编语言查找字符

harry747747 发布于 2007-06-08 10:22, 1316 次点击
datarea segment
eng 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
其他情况类似!
9 回复
#2
Pants2007-06-08 12:19
楼主又是共享源码的?
#3
harry7477472007-06-21 16:45

是呀。自己编的,不太好,见笑了

#4
爱以走远2007-06-21 18:37
#5
zhulei19782007-06-21 20:00
楼主,怎么显示出来是乱码
只有本站会员才能查看附件,请 登录

#6
菜鸟上路2007-06-21 20:43
是不是加了中文进去呀
#7
I喜欢c2007-06-21 21:59
可能是bug...
#8
zhulei19782007-06-22 12:27
没有加中文,我是这样拷过来的
[CODE]datarea segment
eng 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[/CODE]
#9
harry7477472007-06-22 19:13
回复:(zhulei1978)楼主,怎么显示出来是乱码[upload...

注意用最简版的MASM 5.0进行编译。还有就是指令适用于16位机,如80x86等

#10
zhulei19782007-06-22 19:59
哦,谢谢
1