struct StringsBase *StringsBase=0L; /*#define RUN*/ #ifdef RUN long StrLen(s) register char *s; { register long l=0; do l++; while(*s++); l--; return l; }; /* strcpy $VER 0.1 */ #endif int main() { /* MAIN */ long el=0; char s[256]; StringsBase=(struct StringsBase *)OpenLibrary("Strings.library",0); StrCpy(s,"StrLen"); printf("<%s> len = %ld\n",s,StrLen(s)); StrCpy(s,""); printf("<%s> len = %ld\n",s,StrLen(s)); if(StringsBase) CloseLibrary(StringsBase); return el; } /* END */ #ifdef COMMENT _StrLen: ; ohne register link a5,#-4 movem.l d3/d4,-(sp) move.l 8(a5),d4 moveq.l #0,d3 L3: addq.l #1,d3 move.l d4,d0 addq.l #1,d4 move.l d0,a0 tst.b (a0) bne L3 subq.l #1,d3 move.l d3,d0 movem.l (sp)+,d3/d4 unlk a5 rts _StrLen: ; mit register link a5,#0 movem.l d3/a2,-(sp) move.l 8(a5),a2 moveq.l #0,d3 L3: addq.l #1,d3 tst.b (a2)+ bne L3 subq.l #1,d3 move.l d3,d0 movem.l (sp)+,d3/a2 unlk a5 rts _StrLen: moveq.l #0,D0 ; hand optimiert fuer library strlenloop: addq.l #$01,D0 cmp.b #(0),(A0)+ bne strlenloop subq.l #$01,D0 rts len = 6 <> len = 0 #endif