.TITLE slen - return length of asciz string on stack .IDENT /13/ .REM | *+ slen - return length of asciz string on stack File:slen.mac Version: 13 Author: Last Edit: 28-FEB-1985 14:32:45 Last Update: 28-Feb-1985 14:33:07 standard module header *- | .LIBRARY /LB:[1,1]GLMAC.MLB/ .MCALL push,pop,return .SBTTL SLEN - Return length of string .rem | SLEN determines the length of an asciz string. ASCIZ strings are terminated by a null (zero) byte. Length returned does not include the null byte. CALL jsr pc, SLEN INPUT r0 -> input string OUTPUT r0 -> input string length on stack REGS all preserved NOTE: 1. Caller must pop length off of stack on return 2. Input string had better have a null terminator! | SLEN:: mov (sp), -(sp) ; copy return address push ; preserve string address 10$: tstb (r0)+ ; look for null byte bne 10$ ; loop till found dec r0 ; back off from null sub (sp), r0 ; compute length less null byte mov r0, 4(sp) ; return length on stack pop ; restore string address return .end