www.pudn.com > iccavr_lib.rar > cstrstrx.s, change:2003-11-08,size:878b
; char *cstrstrx(char *ramstr, const char *romstr) ; ja 2003-02-21 ; ; uses R0,R1,R16,R17,R18,R19,R26,R27,R30,R31 ; ; note: cstrstrx will not find an empty romstr ; _cstrstrx:: cstrstrx1: movw R30,R18 ; (re)load movw R26,R16 ; pointers cstrstrx2: elpm ; get rom char tst R0 ; end of romstr? breq cstrstrx3 ; yes = found ... adiw R30,1 ; inc rom pointer ld R1,X+ ; get ram char tst R1 ; end of ramstr? breq cstrstrx4 ; yes = not found ... cp R1,R0 ; chars are equal? breq cstrstrx2 ; go next rom char ... subi R16,0xFF ; else sbci R17,0xFF ; inc ram pointer rjmp cstrstrx1 ; go next ram char ... ; cstrstrx3: ; end of romstr: cp R30,R18 ; romstr must not cpc R31,R19 ; be emptfy brne cstrstrx99 ; ... cstrstrx4: ; romstr not found: ldi R16,0 ; ldi R17,0 ; return NULL pointer cstrstrx99: ret ; ;eof;