strings.inc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2000 by Jonas Maebe, member of the
  4. Free Pascal development team
  5. Processor dependent part of strings.pp, that can be 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. {$ifndef FPC_UNIT_HAS_STRUPPER}
  14. {$define FPC_UNIT_HAS_STRUPPER}
  15. function strupper(p : pchar) : pchar;assembler;nostackframe;
  16. asm
  17. mov ip, r0 // Don't change r0, because thats our return value
  18. ldrb r1, [ip] // First loop does not postindex
  19. .LByteLoop:
  20. cmp r1, #0
  21. {$if defined(cpuarmv3) or defined(cpuarmv4)}
  22. moveq pc, lr
  23. {$else}
  24. bxeq lr
  25. {$endif}
  26. sub r2, r1, #97 // Normalize to zero
  27. cmp r2, #25 // temp >= 0 and temp <=25
  28. subls r1, r1, #32 // is lowercase, make uppercase
  29. strlsb r1, [ip] // Store only on change
  30. ldrb r1, [ip, #1]! // Loading here utilizes a load delay slot
  31. b .LByteLoop
  32. end;
  33. {$endif FPC_UNIT_HAS_STRUPPER}
  34. {$ifndef FPC_UNIT_HAS_STRLOWER}
  35. {$define FPC_UNIT_HAS_STRLOWER}
  36. function strlower(p : pchar) : pchar;assembler;nostackframe;
  37. asm
  38. mov ip, r0 // Don't change r0, because thats our return value
  39. ldrb r1, [ip] // First loop does not postindex
  40. .LByteLoop:
  41. cmp r1, #0
  42. {$if defined(cpuarmv3) or defined(cpuarmv4)}
  43. moveq pc, lr
  44. {$else}
  45. bxeq lr
  46. {$endif}
  47. sub r2, r1, #65 // Normalize to zero
  48. cmp r2, #25 // temp >= 0 and temp <=25
  49. addls r1, r1, #32 // Is uppercase, make lowercase
  50. strlsb r1, [ip] // Store only on change
  51. ldrb r1, [ip, #1]! // Loading here utilizes a load delay slot
  52. b .LByteLoop
  53. end;
  54. {$endif FPC_UNIT_HAS_STRLOWER}