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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1009 ivang
!
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
! 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
#include "asm.h"
18
 
19
ENTRY(memset)
20
        mov     #12,r0  ! Check for small number of bytes
21
        cmp/gt  r6,r0
22
        mov     r4,r0
23
        SL(bt, L_store_byte_loop_check0, add r4,r6)
24
 
25
        tst     #3,r0   ! Align destination
26
        SL(bt,  L_dup_bytes, extu.b r5,r5)
27
        .balignw 4,0x0009
28
L_align_loop:
29
        mov.b   r5,@r0
30
        add     #1,r0
31
        tst     #3,r0
32
        bf      L_align_loop
33
 
34
L_dup_bytes:
35
        swap.b  r5,r2   ! Duplicate bytes across longword
36
        or      r2,r5
37
        swap.w  r5,r2
38
        or      r2,r5
39
 
40
        add     #-16,r6
41
 
42
        .balignw 4,0x0009
43
L_store_long_loop:
44
        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
 
49
        add     #16,r6
50
 
51
L_store_byte_loop_check0:
52
        cmp/eq  r6,r0
53
        bt      L_exit
54
        .balignw 4,0x0009
55
L_store_byte_loop:
56
        mov.b   r5,@r0  ! Store bytes to memory
57
        add     #1,r0
58
        cmp/eq  r6,r0
59
        bf      L_store_byte_loop
60
 
61
L_exit:
62
        rts
63
        mov     r4,r0
64
 

powered by: WebSVN 2.1.0

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