OpenCores
URL https://opencores.org/ocsvn/amber/amber/trunk

Subversion Repositories amber

[/] [amber/] [trunk/] [sw/] [mini-libc/] [libc_asm.S] - Diff between revs 33 and 34

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 33 Rev 34
Line 202... Line 202...
*/
*/
        @ r0 points to destination
        @ r0 points to destination
        @ r1 points to source string which terminates with a 0
        @ r1 points to source string which terminates with a 0
        .globl strcpy
        .globl strcpy
strcpy:
strcpy:
        stmdb   sp!, {r4-r7, lr}
        stmdb   sp!, {r4-r6, lr}
        @ Use r6 to process the destination pointer.
        @ Use r6 to process the destination pointer.
        @ At the end of the function, r0 is returned, so need to preserve it
        @ At the end of the function, r0 is returned, so need to preserve it
        mov     r6, r0
        mov     r6, r0
        @ only if both strings are zero-aligned use the fast 'aligned' algorithm
        @ only if both strings are zero-aligned use the fast 'aligned' algorithm
        orr     r2, r6, r1
        orr     r2, r6, r1
        ands    r2, r2, #3
        tst     r2, #3
        bne     strcpy_slow
        bne     strcpy_slow
 
 
strcpy_fast:
strcpy_fast:
        @ process strings 12 bytes at a time
        @ process strings 12 bytes at a time
        ldmia   r1!, {r2-r5}
        ldmia   r1!, {r2-r5}
 
 
        @ check for a zero byte
        @ check for a zero byte
        @ only need to examine one of the strings because
        @ only need to examine one of the strings because
        @ they are equal up to this point!
        @ they are equal up to this point!
        ands    r7, r2, #0xff
        tst     r2, #0xff
        andnes  r7, r2, #0xff00
        tstne   r2, #0xff00
        andnes  r7, r2, #0xff0000
        tstne   r2, #0xff0000
        andnes  r7, r2, #0xff000000
        tstne   r2, #0xff000000
        strne   r2, [r6], #4
        strne   r2, [r6], #4
        subeq   r1, r1, #4
        subeq   r1, r1, #4
 
 
        andnes  r7, r3, #0xff
        tstne   r3, #0xff
        andnes  r7, r3, #0xff00
        tstne   r3, #0xff00
        andnes  r7, r3, #0xff0000
        tstne   r3, #0xff0000
        andnes  r7, r3, #0xff000000
        tstne   r3, #0xff000000
        strne   r3, [r6], #4
        strne   r3, [r6], #4
        subeq   r1, r1, #4
        subeq   r1, r1, #4
 
 
        andnes  r7, r4, #0xff
        tstne   r4, #0xff
        andnes  r7, r4, #0xff00
        tstne   r4, #0xff00
        andnes  r7, r4, #0xff0000
        tstne   r4, #0xff0000
        andnes  r7, r4, #0xff000000
        tstne   r4, #0xff000000
        strne   r4, [r6], #4
        strne   r4, [r6], #4
        subeq   r1, r1, #4
        subeq   r1, r1, #4
 
 
        andnes  r7, r5, #0xff
        tstne   r5, #0xff
        andnes  r7, r5, #0xff00
        tstne   r5, #0xff00
        andnes  r7, r5, #0xff0000
        tstne   r5, #0xff0000
        andnes  r7, r5, #0xff000000
        tstne   r5, #0xff000000
        strne   r5, [r6], #4
        strne   r5, [r6], #4
        subeq   r1, r1, #4
        subeq   r1, r1, #4
 
 
        @ loop back to look at next 12 bytes
        @ loop back to look at next 12 bytes
        bne     strcpy_fast
        bne     strcpy_fast
 
 
        @ the source string contains a zero character
        @ the source string contains a zero character
 
 
 
 
 
strcpy_aligned_slow:
 
        @ unroll the loop 4 times
 
        ldr     r3, [r1], #4
 
        strb    r3, [r6], #1
 
        ands    r4, r3,   #0xff
 
        ldmeqia sp!, {r4-r6, pc}^
 
 
 
        lsr     r3, r3, #8
 
        strb    r3, [r6], #1
 
        ands    r4, r3,   #0xff
 
        ldmeqia sp!, {r4-r6, pc}^
 
 
 
        lsr     r3, r3, #8
 
        strb    r3, [r6], #1
 
        ands    r4, r3,   #0xff
 
        ldmeqia sp!, {r4-r6, pc}^
 
 
 
        lsr     r3, r3, #8
 
        strb    r3, [r6], #1
 
        ands    r4, r3,   #0xff
 
        ldmeqia sp!, {r4-r6, pc}^
 
 
 
        b       strcpy_aligned_slow
 
 
 
 
strcpy_slow:
strcpy_slow:
        @ unroll the loop 4 times
        @ unroll the loop 4 times
        ldrb    r3, [r1], #1
        ldrb    r3, [r1], #1
        strb    r3, [r6], #1
        strb    r3, [r6], #1
        cmp     r3, #0
        cmp     r3, #0
        ldmeqia sp!, {r4-r7, pc}^
        ldmeqia sp!, {r4-r6, pc}^
 
 
        ldrb    r3, [r1], #1
        ldrb    r3, [r1], #1
        strb    r3, [r6], #1
        strb    r3, [r6], #1
        cmp     r3, #0
        cmp     r3, #0
        ldmeqia sp!, {r4-r7, pc}^
        ldmeqia sp!, {r4-r6, pc}^
 
 
        ldrb    r3, [r1], #1
        ldrb    r3, [r1], #1
        strb    r3, [r6], #1
        strb    r3, [r6], #1
        cmp     r3, #0
        cmp     r3, #0
        ldmeqia sp!, {r4-r7, pc}^
        ldmeqia sp!, {r4-r6, pc}^
 
 
        ldrb    r3, [r1], #1
        ldrb    r3, [r1], #1
        strb    r3, [r6], #1
        strb    r3, [r6], #1
        cmp     r3, #0
        cmp     r3, #0
        ldmeqia sp!, {r4-r7, pc}^
        ldmeqia sp!, {r4-r6, pc}^
 
 
        b       strcpy_slow
        b       strcpy_slow
 
 
 
 
/* int strcmp ( const char * str1, const char * str2 );
/* int strcmp ( const char * str1, const char * str2 );
Line 287... Line 313...
strcmp:
strcmp:
        stmdb   sp!, {r4-r8, lr}
        stmdb   sp!, {r4-r8, lr}
 
 
        @ only if both strings are zero-aligned use the fast 'aligned' algorithm
        @ only if both strings are zero-aligned use the fast 'aligned' algorithm
        orr     r2, r0, r1
        orr     r2, r0, r1
        ands    r2, r2, #3
        tst     r2, #3
        bne     strcmp_slow
        bne     strcmp_slow
 
 
strcmp_fast:
strcmp_fast:
        @ process strings 12 bytes at a time
        @ process strings 12 bytes at a time
        ldmia   r0!, {r2-r4}
        ldmia   r0!, {r2-r4}
Line 304... Line 330...
        bne     3f
        bne     3f
 
 
        @ strings are equal - find a zero byte
        @ strings are equal - find a zero byte
        @ only need to examine one of the strings because
        @ only need to examine one of the strings because
        @ they are equal up to this point!
        @ they are equal up to this point!
        ands    r8, r2, #0xff
        tst     r2, #0xff
        andnes  r8, r2, #0xff00
        tstne   r2, #0xff00
        andnes  r8, r2, #0xff0000
        tstne   r2, #0xff0000
        andnes  r8, r2, #0xff000000
        tstne   r2, #0xff000000
 
 
        andnes  r8, r3, #0xff
        tstne   r3, #0xff
        andnes  r8, r3, #0xff00
        tstne   r3, #0xff00
        andnes  r8, r3, #0xff0000
        tstne   r3, #0xff0000
        andnes  r8, r3, #0xff000000
        tstne   r3, #0xff000000
 
 
        andnes  r8, r4, #0xff
        tstne   r4, #0xff
        andnes  r8, r4, #0xff00
        tstne   r4, #0xff00
        andnes  r8, r4, #0xff0000
        tstne   r4, #0xff0000
        andnes  r8, r4, #0xff000000
        tstne   r4, #0xff000000
 
 
        @ loop back to look at next 12 bytes
        @ loop back to look at next 12 bytes
        bne     strcmp_fast
        bne     strcmp_fast
 
 
        @ the first string contains a zero character
        @ the first string contains a zero character
Line 365... Line 391...
 
 
 
 
 
 
@ Skipping first 4 bytes so just check they
@ Skipping first 4 bytes so just check they
@ don't contain an end of string 0 character
@ don't contain an end of string 0 character
2:      ands    r8, r2, #0xff
2:      tst    r2, #0xff
        andnes  r8, r2, #0xff00
        tstne  r2, #0xff00
        andnes  r8, r2, #0xff0000
        tstne  r2, #0xff0000
        andnes  r8, r2, #0xff000000
        tstne  r2, #0xff000000
        beq     bytes_zero
        beq     bytes_zero
 
 
        @ start looking at 5th byte
        @ start looking at 5th byte
        sub     r0, r0, #8
        sub     r0, r0, #8
        sub     r1, r1, #8
        sub     r1, r1, #8
Line 404... Line 430...
 
 
        bne     strcmp_slow
        bne     strcmp_slow
 
 
@ Skipping first 8 bytes so just check they
@ Skipping first 8 bytes so just check they
@ don't contain an end of string 0 character
@ don't contain an end of string 0 character
3:      ands    r8, r2, #0xff
3:      tst     r2, #0xff
        andnes  r8, r2, #0xff00
        tstne   r2, #0xff00
        andnes  r8, r2, #0xff0000
        tstne   r2, #0xff0000
        andnes  r8, r2, #0xff000000
        tstne   r2, #0xff000000
 
 
        andnes  r8, r3, #0xff
        tstne   r3, #0xff
        andnes  r8, r3, #0xff00
        tstne   r3, #0xff00
        andnes  r8, r3, #0xff0000
        tstne   r3, #0xff0000
        andnes  r8, r3, #0xff000000
        tstne   r3, #0xff000000
        beq     bytes_zero
        beq     bytes_zero
 
 
        sub     r0, r0, #4
        sub     r0, r0, #4
        sub     r1, r1, #4
        sub     r1, r1, #4
        ldrb    r2, [r0], #1
        ldrb    r2, [r0], #1

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.