struct StringsBase *StringsBase=0L; /*#define RUN*/ #ifdef RUN long StrRvCpy(dest,source) register char *dest,*source; { register char *s=source; if(*s) { do ; while(*source++); source--; source--; do { *dest=*source; dest++; source--; } while (s<=source); } *dest=0; return 1; }; /* StrRvCpy $VER: FEB06 0.2 */ #endif int main() { /* MAIN */ long el=0; char s[256],d[256]; StringsBase=(struct StringsBase *)OpenLibrary("Strings.library",0); strcpy(s,"testStrRv"); StrRvCpy(d,s); printf("%s = %s\n",s,d); strcpy(s,"abc"); StrRvCpy(d,s); printf("%s = %s\n",s,d); strcpy(s,"ab"); StrRvCpy(d,s); printf("%s = %s\n",s,d); strcpy(s,"a"); StrRvCpy(d,s); printf("%s = %s\n",s,d); strcpy(s,""); StrRvCpy(d,s); printf("<%s> = <%s>\n",s,d); if(StringsBase) CloseLibrary(StringsBase); return el; } /* END */ #ifdef COMMENT _StrRvCpy: movem.l a2,-(sp) moveq.l #0,d0 cmp.l #(0),a0 beq strrvcpyquit move.l A1,A2 tst.b (A2) beq strrvcpyend strrvcpyloop: cmp.b #(0),(a1)+ bne strrvcpyloop subq.l #$02,A1 strrvcpywhile: move.b (A1),(A0)+ subq.l #$01,A1 cmp.l A2,A1 bcc strrvcpywhile strrvcpyend: move.b #$00,(A0) moveq.l #1,D0 strrvcpyquit: movem.l (sp)+,A2 RTS testStrRv = vRrtStset abc = cba ab = ba a = a <> = <> #endif