/[projet1]/public/pc/tools/osdk/main/Osdk/_final_/lib2/strstr.s
Defence Force logotype

Annotation of /public/pc/tools/osdk/main/Osdk/_final_/lib2/strstr.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1154 - (hide annotations)
Sun Aug 10 18:19:54 2014 UTC (5 years, 7 months ago) by dbug
File size: 1413 byte(s)


1 dbug 1154 ; char *strstr(char *s1,char *s2)
2    
3     _strstr
4     jsr get_2ptr
5     jsr resets2 ; needls is op2
6     lda op1 ; haystack is op1
7     sta strstr1+8
8     sta tmp1
9     lda op1+1
10     sta strstr1+9
11     ldy #0
12    
13     strstr1 ; main loop
14     lda $2211,x ; s2
15     beq success ; finished
16     sta tmp
17     lda $9988,y ; s1
18     beq failure ; finished
19    
20     cmp tmp ; compare *s1,*s2
21     beq strstr2 ; equal?
22     jsr resets2 ; nope... reset s2 pointer
23     jmp strstr3 ; ...and go on to next *s1
24    
25     strstr2 ; inc s2 pointer
26     txa
27     bne strstr2a
28     lda tmp+1
29     bne strstr2a
30    
31     sty tmp2
32     lda strstr1+9
33     sta tmp1+1
34    
35     strstr2a
36     lda #1
37     sta tmp+1
38     inx
39     bne strstr3
40     lda #1
41     sta tmp+1
42     inc strstr1+2
43    
44     strstr3 ; inc s1 pointer
45     iny
46     bne strstr4
47     inc strstr1+9
48    
49     strstr4
50     jmp strstr1
51    
52     resets2
53     lda op2
54     sta strstr1+1
55     lda op2+1
56     sta strstr1+2
57     ldx #0
58     lda #0
59     sta tmp+1
60     rts
61    
62     failure
63     jmp retzero
64    
65     success
66     lda tmp2 ; return sp1+Y
67     clc
68     adc tmp1
69     tax
70     lda tmp1+1
71     adc #0
72     rts
73    

  ViewVC Help
Powered by ViewVC 1.1.26