; -- strlen(s) returns the length of null terminated string s ; version 3, using pointer difference to compute length of string STRLEN: ; expects R3 = s, a pointer to a string ; returns R3 the length of s ; uses R4 = s', working copy of s ; R5 = *s', successive values MOVE R4,R3 ; s' = s STRLLP: ; loop { LOADS R5,R4 ; -- get word holding *s' EXTB R5,R5,R4 ; -- get *s' BZS STRLQT ; if (*s' == 0) break ADDSI R4,1 ; s++ BR STRLLP STRLQT: ; } SUB R3,R4,R3 JUMPS R1 ; return s - s'