永发信息网

汇编 设计查找匹配字符串SEARCH的程序。

答案:2  悬赏:10  手机版
解决时间 2021-11-23 22:59
  • 提问者网友:酱爆肉
  • 2021-11-23 17:21
汇编 设计查找匹配字符串SEARCH的程序。
最佳答案
  • 五星知识达人网友:青尢
  • 2021-11-23 17:58
可以用的 望采纳

DATA SEGMENT
STRKEY DB 'enter keyword:$'
STRSEN DB 'enter sentence:$'
STRAT DB 'match at location:$'
STROF DB ' of the sentence',0DH,0AH,'$'
STRNO DB 'no match',0DH,0AH,'$'
CRLF DB 0DH,0AH,'$'
BUFKEY DB 20
DB 20 DUP (?)
BUFSEN DB 100
DB 100 DUP (?)
BUFCMP DB 20
DB 20 DUP (?)
DATA ENDS

STACK SEGMENT STACK
DB 200 DUP(?)
STACK ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:
MOV AX,DATA
MOV DS,AX
MOV ES,AX

MOV AH,09H
LEA DX,STRKEY
INT 21H

MOV AH,0AH
LEA DX,BUFKEY
INT 21H

MOV AH,09H
LEA DX,CRLF
INT 21H

LEA SI,BUFKEY+2
LOOP1:
MOV AH,09H
LEA DX,STRSEN
INT 21H

MOV AH,0AH
LEA DX,BUFSEN
INT 21H

MOV AH,09H
LEA DX,CRLF
INT 21H

MOV CL,BUFSEN+1
SUB CL,BUFKEY+1
JC NOMATCH

INC CL
LEA BX,BUFSEN+2
LOOP2:
PUSH CX
MOV CL,BUFKEY+1
MOV CH,0
PUSH SI
MOV SI,BX
MOV DI,OFFSET BUFCMP
REP MOVSB
POP SI
POP CX

PUSH CX
MOV CL,BUFKEY+1
MOV CH,0
PUSH SI
LEA SI,BUFCMP
LEA DI,BUFKEY+2
REPZ CMPSB
POP SI
POP CX
JZ MATCHAT

INC BX
DEC CL
JNZ LOOP2

JMP NOMATCH
MATCHAT:
MOV AH,09H
LEA DX,STRAT
INT 21H

SUB BX,OFFSET BUFSEN+2
INC BX

PUSH CX

MOV CL,4
MOV CH,4
NEXT:
ROL BX,CL
MOV AL,BL
AND AL,0FH
ADD AL,30H
CMP AL,3AH
JL OUTP
ADD AL,07H
OUTP:
MOV DL,AL
CMP DL,'0'
JZ ZJMP
MOV AH,02H
INT 21H
ZJMP:
DEC CH
CMP CH,0
JA NEXT
MOV DL,'H'
MOV AH,02H
INT 21H

POP CX

MOV AH,09H
LEA DX,STROF
INT 21H

JMP LOOP1
NOMATCH:
MOV AH,09H
LEA DX,STRNO
INT 21H

JMP LOOP1
EXIT:
MOV AH,4CH
INT 21H
CODE ENDS
END START
全部回答
  • 1楼网友:骨子里都是戏
  • 2021-11-23 19:26

去百度找一下吧..最好是找一些相关的实例教程.!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯