strlen.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. Processor specific implementation of strlen
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { in: p in r3 }
  13. { out: result (length) in r3 }
  14. asm
  15. { load the begin of the string in the data cache }
  16. dcbt 0,r3
  17. { empty/invalid string? }
  18. cmpli r3,0
  19. { if yes, do nothing }
  20. beq LStrLenDone
  21. subi r29,r3,1
  22. LStrLenLoop:
  23. lbzu r30,1(r29)
  24. cmpli r30,0
  25. bne LStrLenLoop
  26. sub r3,r29,r3
  27. LStrLenDone:
  28. end ['r3','r4','r29','r30','cr0'];
  29. {
  30. $Log$
  31. Revision 1.1 2001-09-27 15:30:29 jonas
  32. * conversion to compilerproc and to structure used by i386 rtl
  33. * some bugfixes
  34. * powerpc.inc is almost complete (only fillchar/word/dword, get_frame etc
  35. and the class helpers are still needed
  36. - removed unnecessary register saving in set.inc (thanks to compilerproc)
  37. * use registers reserved for parameters as much as possible instead of
  38. those reserved for local vars (since those have to be saved by the
  39. called anyway, while the ones for local vars have to be saved by the
  40. callee)
  41. }