annotate lib/alib/ptsearch.as @ 3003:68a167bc476d

level3 makefiles: Order BOOTERS list like in level2
author Tormod Volden <debian.tormod@gmail.com>
date Sun, 26 Oct 2014 13:02:12 +0100
parents 03f26e88b809
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2474
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
1 ***************************************
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
3 * Pattern Search
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
4
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
5 * OTHER MODULES REQUIRED: COMPARE
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
6
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
7 * ENTRY: X=start of memory to search
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
8 * U=end of memory
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
9 * Y=start of pattern
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
10 * D=size of pattern
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
11 * CASEMTCH (a global variable in COMPARE) =0 if A<>a, -1 if A=a
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
12
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
13 * EXIT: X=address of match if found, unchanged if no match
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
14 * CC zero set if match, clear for no-match
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
15 * A,B,U,Y preserved
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
16
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
17
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
18 nam Pattern Search
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
19 ttl Assembler Library Module
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
20
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
21
2782
aaba193af04f Updated code to use lwasm/lwlink
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2474
diff changeset
22 section .data
2474
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
23
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
24 pattend rmb 2 end of pattern in memory
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
25 memend rmb 2 realend-pattern size
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
26 patsize rmb 2 saved <D>
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
27 memstrt rmb 2 saved <X>
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
28 patstrt rmb 2 saved <Y>
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
29 realend rmb 2 saved <U>
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
30
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
31 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
32
2782
aaba193af04f Updated code to use lwasm/lwlink
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2474
diff changeset
33 section .text
aaba193af04f Updated code to use lwasm/lwlink
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2474
diff changeset
34
aaba193af04f Updated code to use lwasm/lwlink
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2474
diff changeset
35 * set up stack frame for variables
aaba193af04f Updated code to use lwasm/lwlink
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2474
diff changeset
36
2474
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
37 PTSEARCH:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
38 pshs d,x,y,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
39 leas -4,s room for temps
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
40 tfr u,d end of memory to check
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
41 subd patsize,s end-pattern size
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
42 std memend,s where we stop looking
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
43 ldd patstrt,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
44 addd patsize,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
45 std pattend,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
46
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
47 * loop here looking for a match of the first characters
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
48
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
49 inmatch
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
50 cmpx memend,s raeched end of memory
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
51 bhs nomatch
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
52 lda ,x+ get char from memory
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
53 ldb ,y compare to pattern
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
54 lbsr COMPARE compare them
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
55 bne inmatch keep looking for inital match
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
56
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
57 * see if rest of pattern matches
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
58
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
59 more
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
60 tfr x,u save pointer
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
61 leay 1,y already matched that one
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
62
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
63 more1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
64 cmpy pattend,s all chars matched, go home happy
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
65 beq match
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
66 lda ,x+
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
67 ldb ,y+
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
68 lbsr COMPARE
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
69 beq more1 keep matching
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
70 tfr u,x match fails, backup and do more
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
71 ldy patstrt,s start of pattern
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
72 bra inmatch
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
73
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
74
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
75 nomatch
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
76 lda #1 clear zero
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
77 bra exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
78
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
79 match
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
80 leau -1,u start of match
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
81 stu memstrt,s where pattern starts
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
82 clra set zero flag=found
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
83
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
84 exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
85 leas 4,s clean stack
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
86 puls d,x,y,u,pc
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
87
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
88 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
89
2782
aaba193af04f Updated code to use lwasm/lwlink
Boisy Pitre <boisy.pitre@nuance.com>
parents: 2474
diff changeset
90