memchr.S 479 B

123456789101112131415161718192021222324252627282930
  1. /* $Id: memchr.S,v 1.1 2000/04/14 16:49:01 mjd Exp $
  2. *
  3. * "memchr" implementation of SuperH
  4. *
  5. * Copyright (C) 1999 Niibe Yutaka
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. /*
  10. * void *memchr(const void *s, int c, size_t n);
  11. */
  12. #include <sysdep.h>
  13. ENTRY(memchr)
  14. tst r6,r6
  15. bt/s 2f
  16. exts.b r5,r5
  17. 1: mov.b @r4,r1
  18. cmp/eq r1,r5
  19. bt/s 3f
  20. dt r6
  21. bf/s 1b
  22. add #1,r4
  23. 2: mov #0,r4
  24. 3: rts
  25. mov r4,r0
  26. END(memchr)
  27. libc_hidden_def (memchr)