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

Annotation of /public/pc/tools/osdk/main/Osdk/_final_/lib2/strrchr.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: 1131 byte(s)


1 dbug 1154 ; char *strrchr(char *s, char c)
2    
3     _strrchr
4     ldy #0
5     lda (sp),y
6     sta strrchr1+1 ; low(s)
7     iny
8     lda (sp),y
9     sta strrchr1+2 ; high(s)
10     iny
11     lda (sp),y
12     sta strrchr1+6 ; low(c)
13     lda #00
14     sta tmp1
15     ldx #0
16     ldy #0
17    
18     strrchr1 ; loop through the string
19     lda $2211,X
20     beq strrchr2
21     cmp #$06
22     beq strrchr1a
23    
24     strrchr1b
25     inx
26     bne strrchr1
27     inc strrchr1+2
28     iny
29     jmp strrchr1
30    
31     strrchr1a
32     stx tmp0 ; found an occurence, store delta pointer to it
33     sty tmp0+1
34     lda #$01
35     sta tmp1 ; flag found=1
36     jmp strrchr1b
37    
38     strrchr2
39     lda tmp1
40     beq strrchr3 ; found character?
41    
42     clc ; character found, return pointer to it within s
43     lda tmp0
44     adc strrchr1+1
45     tax ; low order byte
46     lda tmp0+1
47     adc strrchr1+2 ; high order byte
48     rts
49    
50     strrchr3
51     jmp retzero ; character not found, return NULL

  ViewVC Help
Powered by ViewVC 1.1.26