1: /*
   2:  * Copyright (c) 1987 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifdef LIBC_SCCS
   8:         <@(#)index.s	1.2 (2.11BSD) 1996/1/12\0>
   9:         .even
  10: #endif LIBC_SCCS
  11: 
  12: /*
  13:  * Find the first occurence of c in the string cp.
  14:  * Return pointer to match or null pointer.
  15:  *
  16:  * char *
  17:  * index(cp, c)
  18:  *	char *cp, c;
  19:  */
  20: #include "DEFS.h"
  21: 
  22:         .globl  _strchr
  23: _strchr = _index ^ .
  24: 
  25: ENTRY(index)
  26:         mov     2(sp),r0        / r0 = cp
  27:         mov     4(sp),r1        / r1 = c
  28:         beq     3f              / check for special case of c == '\0'
  29: 1:
  30:         cmpb    (r0),r1         / look for c ...
  31:         beq     2f
  32:         tstb    (r0)+           / but don't pass end of string ...
  33:         bne     1b
  34:         clr     r0              / fell off the end of the string - return 0
  35: 2:
  36:         rts     pc              / return pointer
  37: 3:
  38:         tstb    (r0)+           / just find end of string
  39:         bne     3b
  40:         dec     r0              / back up to '\0'
  41:         rts     pc              /   and return pointer

Defined functions

_index defined in line 25; used 538 times
_strchr declared in line 22; defined in line 23; used 60 times
Last modified: 1996-01-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3929
Valid CSS Valid XHTML 1.0 Strict