strchr-386.s 286 B

1234567891011121314151617181920212223242526272829
  1. TEXT strchr(SB),$0
  2. /*
  3. * look for null
  4. */
  5. MOVL p+0(FP), DI
  6. MOVL $-1, CX
  7. MOVL $0, AX
  8. CLD
  9. REPN; SCASB
  10. /*
  11. * look for real char
  12. */
  13. MOVL DI, CX
  14. MOVL p+0(FP), DI
  15. SUBL DI, CX
  16. MOVBLZX c+4(FP), AX
  17. REPN; SCASB
  18. JEQ found
  19. MOVL $0, AX
  20. RET
  21. found:
  22. MOVL DI, AX
  23. SUBL $1, AX
  24. RET