-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path查找匹配字符串.asm
100 lines (100 loc) · 2.09 KB
/
查找匹配字符串.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
DATA SEGMENT
INPUTKEYWORD DB 'Enter keyword:$'
INPUTSENTENCE DB 'Enter sentence:$'
MATCHOUTPUT DB 'Match at location:',?,?,' H of the sentence',13,10,'$'
FAILOUTPUT DB 'No match.',13,10,'$'
TEMP DB 13,10,'$'
KEYWORD label byte
MAXK DB 99H
ACTK DB ?
KEYD DB 999H DUP(?)
SENTENCE label byte
MAXS DB 99H
ACTS DB ?
SENTE DB 999H DUP(?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA
MAIN PROC FAR
PUSH DS
XOR AX,AX
PUSH AX
MOV AX,DATA
MOV DS,AX
MOV ES,AX
START:
LEA DX,INPUTKEYWORD
MOV AH,09
INT 21H
LEA DX,KEYWORD
MOV AH,0AH
INT 21H
CMP ACTK,0
JE C
LEA DX,TEMP
MOV AH,09
INT 21H
LEA DX,INPUTSENTENCE
MOV AH,09
INT 21H
LEA DX,SENTENCE
MOV AH,0AH
INT 21H
CMP ACTS,0
JE BREAK
LEA DX,TEMP
MOV AH,09
INT 21H
LEA SI,KEYD
LEA BX,SENTE
MOV DI,BX
CLD
MOV CH,0
MOV CL,ACTS
SUB CL,ACTK
INC CX
COMP:
PUSH CX
PUSH DI
MOV CL,ACTK
REPZ CMPSB
JZ FIND
POP DI
POP CX
INC DI
LEA SI,KEYD
LOOP COMP
LEA DX,FAILOUTPUT
MOV AH,09
INT 21H
JMP BREAK
C:
JMP BREAK
FIND:
POP DI
POP CX
SUB DI,BX
MOV BX,DI
INC BX
MOV AX,BX
MOV BH,16
DIV BH
ADD AL,48
ADD AH,48
CMP AH,58
JAE A
NEXT:
MOV [MATCHOUTPUT+18],AL
MOV [MATCHOUTPUT+19],AH
LEA DX,MATCHOUTPUT
MOV AH,09
INT 21H
JMP START
A:
ADD AH,7
JMP NEXT
BREAK:
RET
MAIN ENDP
CODE ENDS
END MAIN