stringss.inc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1998 by the Free Pascal development team
  5. Processor dependent part of strings.pp, not shared with
  6. sysutils unit.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {$ASMMODE DIRECT}
  14. function strpas(p : pchar) : string;
  15. begin
  16. asm
  17. cld
  18. movl 12(%ebp),%edi
  19. movl $0xff,%ecx
  20. xorl %eax,%eax
  21. movl %edi,%esi
  22. repne
  23. scasb
  24. movl %ecx,%eax
  25. movl 8(%ebp),%edi
  26. notb %al
  27. decl %eax
  28. stosb
  29. cmpl $7,%eax
  30. jl .LStrPas2
  31. movl %edi,%ecx // Align on 32bits
  32. negl %ecx
  33. andl $3,%ecx
  34. subl %ecx,%eax
  35. rep
  36. movsb
  37. movl %eax,%ecx
  38. andl $3,%eax
  39. shrl $2,%ecx
  40. rep
  41. movsl
  42. .LStrPas2:
  43. movl %eax,%ecx
  44. rep
  45. movsb
  46. end ['ECX','EAX','ESI','EDI'];
  47. end;
  48. {$ASMMODE ATT}
  49. function strpcopy(d : pchar;const s : string) : pchar;
  50. begin
  51. asm
  52. pushl %esi // Save ESI
  53. cld
  54. movl 8(%ebp),%edi // load destination address
  55. movl 12(%ebp),%esi // Load Source adress
  56. movl %edi,%ebx // Set return value
  57. lodsb // load length in ECX
  58. movzbl %al,%ecx
  59. rep
  60. movsb
  61. xorb %al,%al // Set #0
  62. stosb
  63. movl %ebx,%eax // return value to EAX
  64. popl %esi
  65. leave // ... and ready
  66. ret $8
  67. end ['EDI','ESI','EBX','EAX','ECX'];
  68. end;
  69. {
  70. $Log$
  71. Revision 1.2 1999-02-25 10:07:02 michael
  72. + Added header and log
  73. }