bcmp.S 490 B

123456789101112131415161718192021222324252627282930313233
  1. /* $OpenBSD: bcmp.S,v 1.3 2014/11/29 18:51:23 tedu Exp $ */
  2. /*
  3. * Written by J.T. Conklin <jtc@netbsd.org>.
  4. * Public domain.
  5. */
  6. #include <machine/asm.h>
  7. ENTRY(bcmp)
  8. pushl %edi
  9. pushl %esi
  10. movl 12(%esp),%edi
  11. movl 16(%esp),%esi
  12. xorl %eax,%eax /* clear return value */
  13. movl 20(%esp),%ecx /* compare by words */
  14. shrl $2,%ecx
  15. repe
  16. cmpsl
  17. jne L1
  18. movl 20(%esp),%ecx /* compare remainder by bytes */
  19. andl $3,%ecx
  20. repe
  21. cmpsb
  22. je L2
  23. L1: incl %eax
  24. L2: popl %esi
  25. popl %edi
  26. ret