mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-22 03:09:24 +02:00
ARM assembly versions of strupper and strlower
This is about 1/3 faster than the generic code. git-svn-id: trunk@21648 -
This commit is contained in:
parent
0f3441a9c2
commit
c5d7ae513a
@ -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}
|
||||||
|
Loading…
Reference in New Issue
Block a user