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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [machine/] [sh/] [memset.S] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
!
2
! Fast SH memset
3
!
4
! by Toshiyasu Morita (tm@netcom.com)
5
!
6
! Entry: r4: destination pointer
7
!        r5: fill value
8
!        r6: byte count
9
!
10
! Exit:  r0-r3: trashed
11
!
12
 
13 56 joel
! This assumes that the first four bytes of the address space (0..3) are
14
! reserved - usually by the linker script.  Otherwise, we would had to check
15
! for the case of objects of the size 12..15 at address 0..3 .
16
 
17 39 lampret
#include "asm.h"
18
 
19
ENTRY(memset)
20
        mov     #12,r0  ! Check for small number of bytes
21
        cmp/gt  r6,r0
22 56 joel
        mov     r4,r0
23
        SL(bt, L_store_byte_loop_check0, add r4,r6)
24 39 lampret
 
25 56 joel
        tst     #3,r0   ! Align destination
26
        SL(bt,  L_dup_bytes, extu.b r5,r5)
27 39 lampret
        .balignw 4,0x0009
28
L_align_loop:
29 56 joel
        mov.b   r5,@r0
30
        add     #1,r0
31
        tst     #3,r0
32 39 lampret
        bf      L_align_loop
33
 
34
L_dup_bytes:
35 56 joel
        swap.b  r5,r2   ! Duplicate bytes across longword
36
        or      r2,r5
37
        swap.w  r5,r2
38
        or      r2,r5
39 39 lampret
 
40 56 joel
        add     #-16,r6
41 39 lampret
 
42
        .balignw 4,0x0009
43
L_store_long_loop:
44 56 joel
        mov.l   r5,@r0  ! Store double longs to memory
45
        cmp/hs  r6,r0
46
        mov.l   r5,@(4,r0)
47
        SL(bf, L_store_long_loop, add #8,r0)
48 39 lampret
 
49 56 joel
        add     #16,r6
50
 
51
L_store_byte_loop_check0:
52
        cmp/eq  r6,r0
53 39 lampret
        bt      L_exit
54
        .balignw 4,0x0009
55
L_store_byte_loop:
56 56 joel
        mov.b   r5,@r0  ! Store bytes to memory
57
        add     #1,r0
58
        cmp/eq  r6,r0
59 39 lampret
        bf      L_store_byte_loop
60
 
61
L_exit:
62
        rts
63 56 joel
        mov     r4,r0
64 39 lampret
 

powered by: WebSVN 2.1.0

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