stringss.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 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. function strpas(p : pchar) : string;
  14. begin
  15. {$ifndef NEWATT}
  16. strpas:='';
  17. {$endif}
  18. asm
  19. cld
  20. movl p,%edi
  21. movl $0xff,%ecx
  22. xorl %eax,%eax
  23. movl %edi,%esi
  24. repne
  25. scasb
  26. movl %ecx,%eax
  27. {$ifdef NEWATT}
  28. movl __RESULT,%edi
  29. {$else}
  30. movl 8(%ebp),%edi
  31. {$endif}
  32. notb %al
  33. decl %eax
  34. stosb
  35. cmpl $7,%eax
  36. jl .LStrPas2
  37. movl %edi,%ecx // Align on 32bits
  38. negl %ecx
  39. andl $3,%ecx
  40. subl %ecx,%eax
  41. rep
  42. movsb
  43. movl %eax,%ecx
  44. andl $3,%eax
  45. shrl $2,%ecx
  46. rep
  47. movsl
  48. .LStrPas2:
  49. movl %eax,%ecx
  50. rep
  51. movsb
  52. end ['ECX','EAX','ESI','EDI'];
  53. end;
  54. function strpcopy(d : pchar;const s : string) : pchar;assembler;
  55. asm
  56. pushl %esi // Save ESI
  57. cld
  58. movl d,%edi // load destination address
  59. movl s,%esi // Load Source adress
  60. movl %edi,%ebx // Set return value
  61. lodsb // load length in ECX
  62. movzbl %al,%ecx
  63. rep
  64. movsb
  65. xorb %al,%al // Set #0
  66. stosb
  67. movl %ebx,%eax // return value to EAX
  68. popl %esi
  69. end ['EDI','ESI','EBX','EAX','ECX'];
  70. {
  71. $Log$
  72. Revision 1.6 2000-01-07 16:41:33 daniel
  73. * copyright 2000
  74. Revision 1.5 1999/04/08 11:30:58 peter
  75. * removed warnings
  76. Revision 1.4 1999/03/30 16:58:51 peter
  77. * use assembler and remove all rets
  78. Revision 1.3 1999/03/01 15:41:01 peter
  79. * use external names
  80. * removed all direct assembler modes
  81. Revision 1.2 1999/02/25 10:07:02 michael
  82. + Added header and log
  83. }