Selaa lähdekoodia

ARM assembly versions of strupper and strlower

This is about 1/3 faster than the generic code.

git-svn-id: trunk@21648 -
masta 13 vuotta sitten
vanhempi
commit
c5d7ae513a
1 muutettua tiedostoa jossa 47 lisäystä ja 0 poistoa
  1. 47 0
      rtl/arm/strings.inc

+ 47 - 0
rtl/arm/strings.inc

@@ -15,3 +15,50 @@
 
  **********************************************************************}
 
+{$ifndef FPC_UNIT_HAS_STRUPPER}
+{$define FPC_UNIT_HAS_STRUPPER}
+function strupper(p : pchar) : pchar;assembler;nostackframe;
+asm
+        mov     ip, r0   // Don't change r0, because thats our return value
+
+        ldrb    r1, [ip] // First loop does not postindex
+.LByteLoop:
+        cmp     r1, #0
+{$if defined(cpuarmv3) or defined(cpuarmv4)}
+        moveq   pc, lr
+{$else}
+        bxeq    lr
+{$endif}
+
+        sub     r2, r1, #97   // Normalize to zero
+        cmp     r2, #25       // temp >= 0 and temp <=25
+        subls   r1, r1, #32   // is lowercase, make uppercase
+        strlsb  r1, [ip]      // Store only on change
+        ldrb    r1, [ip, #1]! // Loading here utilizes a load delay slot
+        b       .LByteLoop
+end;
+{$endif FPC_UNIT_HAS_STRUPPER}
+
+{$ifndef FPC_UNIT_HAS_STRLOWER}
+{$define FPC_UNIT_HAS_STRLOWER}
+function strlower(p : pchar) : pchar;assembler;nostackframe;
+asm
+        mov     ip, r0   // Don't change r0, because thats our return value
+
+        ldrb    r1, [ip] // First loop does not postindex
+.LByteLoop:
+        cmp     r1, #0
+{$if defined(cpuarmv3) or defined(cpuarmv4)}
+        moveq   pc, lr
+{$else}
+        bxeq    lr
+{$endif}
+
+        sub     r2, r1, #65   // Normalize to zero
+        cmp     r2, #25       // temp >= 0 and temp <=25
+        addls   r1, r1, #32   // Is uppercase, make lowercase
+        strlsb  r1, [ip]      // Store only on change
+        ldrb    r1, [ip, #1]! // Loading here utilizes a load delay slot
+        b       .LByteLoop
+end;
+{$endif FPC_UNIT_HAS_STRLOWER}