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

Subversion Repositories amber

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

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

Rev 31 Rev 33
Line 110... Line 110...
        .globl __aeabi_idiv
        .globl __aeabi_idiv
__aeabi_idiv:
__aeabi_idiv:
_div:
_div:
        stmdb   sp!, {r4, lr}
        stmdb   sp!, {r4, lr}
 
 
 
        @ set r4 to 1 if one of the two inputs is negative
 
        and     r2, r0, #0x80000000
 
        and     r3, r1, #0x80000000
 
        eor     r4, r2, r3
 
 
 
        @ Invert negative numbers
 
        tst     r0, #0x80000000
 
        mvnne   r0, r0
 
        addne   r0, r0, #1
 
 
 
        tst     r1, #0x80000000
 
        mvnne   r1, r1
 
        addne   r1, r1, #1
 
 
        @ divide r1 by r2, also use registers r0 and r4
        @ divide r1 by r2, also use registers r0 and r4
        mov     r2, r1
        mov     r2, r1
        mov     r1, r0
        mov     r1, r0
 
 
        cmp      r2, #0
        cmp      r2, #0
Line 172... Line 186...
        movcc     r2,r2,lsr #1    @ and if bit 0 of r3 was zero, also
        movcc     r2,r2,lsr #1    @ and if bit 0 of r3 was zero, also
                                  @ shift r2 right
                                  @ shift r2 right
        bcc       2b              @ If carry not clear, r3 has shifted
        bcc       2b              @ If carry not clear, r3 has shifted
                                  @ back to where it started, and we
                                  @ back to where it started, and we
                                  @ can end
                                  @ can end
 
 
 
        @ if one of the inputs is negetive then return a negative result
 
        tst     r4, #0x80000000
 
        mvnne   r0, r0
 
        addne   r0, r0, #1
3:      ldmia   sp!, {r4, pc}^
3:      ldmia   sp!, {r4, pc}^
 
 
 
 
/* strcpy: String copy function
/* strcpy: String copy function
    char * strcpy ( char * destination, const char * source );
    char * strcpy ( char * destination, const char * source );
Line 184... Line 203...
        @ 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-r7, lr}
 
        @ Use r6 to process the destination pointer.
 
        @ At the end of the function, r0 is returned, so need to preserve it
        mov     r6, r0
        mov     r6, r0
        @ get relative alignment of strings
 
        and     r2, r6, #3
 
        and     r3, r1, #3
 
        @ only if both strings are zero-aligned use the fast 'aligned' algorithm
        @ only if both strings are zero-aligned use the fast 'aligned' algorithm
        orrs    r2, r3
        orr     r2, r6, r1
 
        ands    r2, 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}
Line 447... Line 466...
        add     r0, r0, #0x10000
        add     r0, r0, #0x10000
        str     r0, [r1]
        str     r0, [r1]
        mov     pc, lr
        mov     pc, lr
 
 
 
 
        .globl times
 
times:
 
@ TODO
 
        mov     r0, #0
 
        mov     pc, lr
 
 
 
 
 
/* strncpy: String copy function */
/* strncpy: String copy function */
        @ r0 points to destination
        @ r0 points to destination
        @ r1 points to source string
        @ r1 points to source string
        @ r2 is the number of bytes to copy
        @ r2 is the number of bytes to copy
        .globl strncpy
        .globl strncpy
strncpy:
strncpy:
        stmdb   sp!, {r4, lr}
        stmdb   sp!, {r4, lr}
        cmp     r2, #0
        cmp     r2, #0
        beq     2f
        beq     2f
        mov     r4, #0
        add     r4, r0, r2    @ set r4 to the address of the last byte copied
1:      ldrb    r3, [r1], #1
1:      ldrb    r3, [r1], #1
        strb    r3, [r0], #1
        strb    r3, [r0], #1
        add     r4,  r4,  #1
 
        cmp     r2,  r4
        cmp     r2,  r4
        beq     2f
        bne     1b
        b       1b
 
2:      ldmia   sp!, {r4, pc}^
2:      ldmia   sp!, {r4, pc}^
 
 
 
 
/* strncpy: String compare function */
/* strncpy: String compare function */
        @ return the difference if the strings don't match
        @ return the difference if the strings don't match

powered by: WebSVN 2.1.0

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