summaryrefslogtreecommitdiff
path: root/rtl/arm/strings.inc
blob: 8a986818b332d565614c192a8b0efe5f1407df01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2000 by Jonas Maebe, member of the
    Free Pascal development team

    Processor dependent part of strings.pp, that can be shared with
    sysutils unit.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

{$ifndef CPUTHUMB}
{$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(cputhumb2)}
        it eq
{$endif}
{$if not defined(CPUARM_HAS_BX)}
        moveq   pc, lr
{$else}
        bxeq    lr
{$endif}

        sub     r2, r1, #97   // Normalize to zero
        cmp     r2, #25       // temp >= 0 and temp <=25
{$if defined(cputhumb2)}
        itt ls
{$endif}
        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(cputhumb2)}
        it eq
{$endif}
{$if not defined(CPUARM_HAS_BX)}
        moveq   pc, lr
{$else}
        bxeq    lr
{$endif}

        sub     r2, r1, #65   // Normalize to zero
        cmp     r2, #25       // temp >= 0 and temp <=25
{$if defined(cputhumb2)}
        itt ls
{$endif}
        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}
{$endif CPUTHUMB}