stringss.inc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.9 2000-02-09 16:59:29 peter
  73. * truncated log
  74. Revision 1.8 2000/01/11 22:56:57 pierre
  75. * wrong change for StrPas function corrected
  76. Revision 1.7 2000/01/11 21:12:15 marco
  77. * direct params to internal asm.
  78. Revision 1.6 2000/01/07 16:41:33 daniel
  79. * copyright 2000
  80. }