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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [machine/] [h8300/] [memset.S] - Blame information for rev 842

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
#include "setarch.h"
2
 
3
#include "defines.h"
4
 
5
#if defined (__H8300SX__)
6
 
7
        .global _memset
8
_memset:
9
        ; Use er3 is a temporary since er0 must remain unchanged on exit.
10
        mov.l   er0,er3
11
 
12
        ; Fill er1 with the byte to copy.
13
        mov.b   r1l,r1h
14
        mov.w   r1,e1
15
 
16
        ; Account for any excess bytes and words that will be copied after
17
        ; the main loop.  r2 >= 0 if there is a longword to copy.
18
        sub     #4,LEN(r2)
19
        blo     longs_done
20
 
21
        ; Copy one byte if doing so will make er3 word-aligned.
22
        ; This isn't needed for correctness but it makes the main loop
23
        ; slightly faster.
24
        bld     #0,r3l
25
        bcc     word_aligned
26
        mov.b   r1l,@er3+
27
        sub     #1,LEN(r2)
28
        blo     longs_done
29
 
30
word_aligned:
31
        ; Likewise one word for longword alignment.
32
        bld     #1,r3l
33
        bcc     long_copy
34
        mov.w   r1,@er3+
35
        sub     #2,LEN(r2)
36
        blo     longs_done
37
 
38
long_copy:
39
        ; Copy longwords.
40
        mov.l   er1,@er3+
41
        sub     #4,LEN(r2)
42
        bhs     long_copy
43
 
44
longs_done:
45
        ; At this point, we need to copy r2 & 3 bytes.  Copy a word
46
        ; if necessary.
47
        bld     #1,r2l
48
        bcc     words_done
49
        mov.w   r1,@er3+
50
 
51
words_done:
52
        ; Copy a byte.
53
        bld     #0,r2l
54
        bcc     bytes_done
55
        mov.b   r1l,@er3+
56
 
57
bytes_done:
58
        rts
59
 
60
#else
61
 
62
; A0P pointer to cursor
63
; A1P thing to copy
64
        .global _memset
65
 
66
_memset:
67
 
68
;       MOVP    @(2/4,r7),A2P   ; dst
69
;       MOVP    @(4/8,r7),A1    ; src thing
70
;       MOVP    @(6/12,r7),A3P  ; len
71
 
72
        MOVP    A2P,A2P
73
        beq     quit
74
 
75
        ; A3 points to the end of the area
76
        MOVP    A0P,A3P
77
        ADDP    A2P,A3P
78
 
79
        ; see if we can do it in words
80
        ; by oring in the start of the buffer to the end address
81
 
82
        or      A0L,A2L
83
        btst    #0,A2L
84
        bne     byteloop
85
 
86
        ; we can do it a word at a time
87
 
88
        mov.b   A1L,A1H
89
 
90
wordloop:
91
        mov.w   A1,@-A3P
92
        CMPP    A3P,A0P
93
        bne     wordloop
94
quit:   rts
95
 
96
byteloop:
97
        mov.b   A1L,@-A3P
98
        CMPP    A3P,A0P
99
        bne     byteloop
100
        rts
101
 
102
#endif

powered by: WebSVN 2.1.0

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