; -- strlen(s) returns the length of null terminated string s ; version 1, using array indexing to each s[i] STRLEN: ; expects R3 = s, a pointer to a string ; returns R3 = i, the length of s ; uses R4 = address of s[i] ; R5 = s[i], successive values ; R6 = i, during the code LIS R6,0 ; i = 0 STRLLP: ; loop { ADD R4,R3,R6 ; -- compute address of s[i] LOADS R5,R4 ; -- get word holding s[i] EXTB R5,R5,R4 ; -- get s[i] BZS STRLQT ; if (s[i] == 0) break ADDSI R6,1 ; i = i + 1 BR STRLLP STRLQT: ; } MOVE R3,R6 ; -- move return value into place JUMPS R1 ; return i