strings.inc 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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(cputhumb2)}
  22. it eq
  23. {$endif}
  24. {$if defined(cpuarmv3) or defined(cpuarmv4)}
  25. moveq pc, lr
  26. {$else}
  27. bxeq lr
  28. {$endif}
  29. sub r2, r1, #97 // Normalize to zero
  30. cmp r2, #25 // temp >= 0 and temp <=25
  31. {$if defined(cputhumb2)}
  32. itt ls
  33. {$endif}
  34. subls r1, r1, #32 // is lowercase, make uppercase
  35. strlsb r1, [ip] // Store only on change
  36. ldrb r1, [ip, #1]! // Loading here utilizes a load delay slot
  37. b .LByteLoop
  38. end;
  39. {$endif FPC_UNIT_HAS_STRUPPER}
  40. {$ifndef FPC_UNIT_HAS_STRLOWER}
  41. {$define FPC_UNIT_HAS_STRLOWER}
  42. function strlower(p : pchar) : pchar;assembler;nostackframe;
  43. asm
  44. mov ip, r0 // Don't change r0, because thats our return value
  45. ldrb r1, [ip] // First loop does not postindex
  46. .LByteLoop:
  47. cmp r1, #0
  48. {$if defined(cputhumb2)}
  49. it eq
  50. {$endif}
  51. {$if defined(cpuarmv3) or defined(cpuarmv4)}
  52. moveq pc, lr
  53. {$else}
  54. bxeq lr
  55. {$endif}
  56. sub r2, r1, #65 // Normalize to zero
  57. cmp r2, #25 // temp >= 0 and temp <=25
  58. {$if defined(cputhumb2)}
  59. itt ls
  60. {$endif}
  61. addls r1, r1, #32 // Is uppercase, make lowercase
  62. strlsb r1, [ip] // Store only on change
  63. ldrb r1, [ip, #1]! // Loading here utilizes a load delay slot
  64. b .LByteLoop
  65. end;
  66. {$endif FPC_UNIT_HAS_STRLOWER}