aboutsummaryrefslogtreecommitdiff
path: root/newasm/string.s
blob: d897a98cc8ed4638b907c5db930147df3d6e6755 (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
.syntax unified
.cpu cortex-m0plus
.thumb

.type putstr, %function
.type putstrln, %function
.type cmpstr, %function

.global putstr, putstrln, cmpstr

putstr: LDR     R3, =0x40034000
        MOVS    R2, 0x20
1:      LDR     R1, [R3, 0x18]
        TST     R1, R2
        BNE     1b
        LDRB    R1, [R0]
        TST     R1, R1
        BEQ     2f
        STRB    R1, [R3]
        ADDS    R0, 1
        B       1b
2:      BX      LR

putstrln:
        PUSH    {LR}
        BL      putstr
        LDR     R0, =crlf
        BL      putstr
        POP     {PC}

cmpstr: PUSH    {R4}
        MOVS    R4, 0
1:      LDRB    R2, [R0, R4]
        LDRB    R3, [R1, R4]
        CMP     R2, R3
        BNE     2f
        CMP     R2, 0
        BEQ     2f
        ADDS    R4, 1
        B       1b
2:      POP     {R4}
        BX      LR