memchr.S 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * File: arch/blackfin/lib/memchr.S
  3. * Based on:
  4. * Author:
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/linkage.h>
  30. /* void *memchr(const void *s, int c, size_t n);
  31. * R0 = address (s)
  32. * R1 = sought byte (c)
  33. * R2 = count (n)
  34. *
  35. * Returns pointer to located character.
  36. */
  37. .text
  38. .align 2
  39. ENTRY(_memchr)
  40. P0 = R0; /* P0 = address */
  41. P2 = R2; /* P2 = count */
  42. R1 = R1.B(Z);
  43. CC = R2 == 0;
  44. IF CC JUMP .Lfailed;
  45. .Lbytes:
  46. LSETUP (.Lbyte_loop_s, .Lbyte_loop_e) LC0=P2;
  47. .Lbyte_loop_s:
  48. R3 = B[P0++](Z);
  49. CC = R3 == R1;
  50. IF CC JUMP .Lfound;
  51. .Lbyte_loop_e:
  52. NOP;
  53. .Lfailed:
  54. R0=0;
  55. RTS;
  56. .Lfound:
  57. R0 = P0;
  58. R0 += -1;
  59. RTS;
  60. ENDPROC(_memchr)