;       Static Name Aliases
;
        TITLE   strend
;       NAME    strend.C

;   strend(s) returns a character pointer to the NUL which ends s.  That
;   is,  strend(s)-s  ==  strlen(s). This is useful for adding things at
;   the end of strings.  It is redundant, because  strchr(s,'\0')  could
;   be used instead, but this is clearer and faster.

        .287
_TEXT   SEGMENT  BYTE PUBLIC 'CODE'
_TEXT   ENDS
_DATA   SEGMENT  WORD PUBLIC 'DATA'
_DATA   ENDS
CONST   SEGMENT  WORD PUBLIC 'CONST'
CONST   ENDS
_BSS    SEGMENT  WORD PUBLIC 'BSS'
_BSS    ENDS
DGROUP  GROUP   CONST,  _BSS,   _DATA
        ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
EXTRN   __chkstk:NEAR
_TEXT      SEGMENT
        PUBLIC  _strend
_strend PROC NEAR
        push    bp
        mov     bp,sp
        push    di

;       s = 4
;       register di = s

        mov     di,[bp+4]       ;s
        xor     al,al
        xor     cx,cx
        dec     cx
        repne   scasb

        mov     ax,di
        dec     ax
        pop     di
        mov     sp,bp
        pop     bp
        ret

_strend ENDP
_TEXT   ENDS
END
