.TITLE LEN ; ; .IDENT /X01.20/ ; ; ; .ENABL LC ; ; ; Copyright (C) Shell Research Ltd. 1982 ; ; ; The copyright in this computer program and associated user ; instructions contained in this document is the property of ; Shell Research Ltd.. No guarantee is given or may be implied ; as to the adequacy of the program or its suitability for any ; particular purpose and no liability is accepted for any loss ; or damage arising out of its use. ; ; ; ; Version: X01 ; ; ; Original author: R J Carpenter 11-Oct-82 ; ; ; This version: ; ; .PAGE .SBTTL Description ; ; ;++ ; This INTEGER function returns the length of a null terminated ASCII ; string. It is callable from both Fortan and Macro. ; ; FORTRAN call: ilen = LEN(qstrng) ; ; Where: ; ; qstrng is the array to be padded and must be dimensioned at least ; maxlen+1 ; ; ilen is the returned length of the string. ; ; Macro Call: CALL $LEN ; ; On Entry: ; ; R1 contains the string start address. ; ; On Exit: ; ; R0 contains the length of the string (not including the null ; terminator). ; R1 contains the string start address. ; ; ; Errors: ; ; None. ; ;-- ; ; .PAGE .SBTTL CODE ; ; LEN:: MOV 2(R5),R1 ;R1 -> START OF STRING ; $LEN:: ;MACRO ENTRY POINT MOV R1,-(SP) ;SAVE START ADDRESS CLR R0 ;MUST KNOW WHERE WE START FROM 30$: INC R0 ;COUNT OUR CHARACTERS TSTB (R1)+ ;NULL ? BNE 30$ ;TRY AGAIN IF NOT DEC R0 ;STRING LENGTH DOES NOT INCLUDE THE NULL MOV (SP)+,R1 ;RESTORE ORIGINAL R1 RETURN ;RETURN TO CALLER ; ; .END