strings.inc 2.3 KB

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