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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [machine/] [hppa/] [memcmp.S] - Blame information for rev 171

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

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 *  (c) Copyright 1986 HEWLETT-PACKARD COMPANY
3
 *
4
 *  To anyone who acknowledges that this file is provided "AS IS"
5
 *  without any express or implied warranty:
6
 *      permission to use, copy, modify, and distribute this file
7
 *  for any purpose is hereby granted without fee, provided that
8
 *  the above copyright notice and this notice appears in all
9
 *  copies, and that the name of Hewlett-Packard Company not be
10
 *  used in advertising or publicity pertaining to distribution
11
 *  of the software without specific, written prior permission.
12
 *  Hewlett-Packard Company makes no representations about the
13
 *  suitability of this software for any purpose.
14
 */
15
 
16
/* memcmp(s1, s2, n) */
17
/* returns integer: < 0 iff s1 lexicographically less than s2 */
18
/*                  > 0 iff s1 lexicographically greater than s2 */
19
/*                  = 0 iff s1 lexicographically equal to s2 */
20
/*                  = 0 iff s1 lexicographically equal to s2 */
21
/*                  quit after n charachters */
22
#ifndef _NAMESPACE_CLEAN
23
#define NOSECDEF   /* prevents _memcmp from becoming primary entry */
24
#endif
25
 
26
#include "DEFS.h"
27
 
28
#define s1 26
29
#define s2 25
30
#define tmp1 19
31
#define s2word 20
32
#define tmp3 21
33
#define tmp7 22
34
#define s1word 29
35
#define save 1
36
#define tmp6 23
37
#define tmp5 28
38
#define count 24
39
 
40
ENTRY(memcmp)
41
        combt,<,n       r0,count,search /*N <= 0 yields equality */
42
        b       done                    /**/
43
        copy    0,ret0                  /*return 0 (DELAY SLOT) */
44
search: combf,=,n       s1,s2,findout   /*s1 != s2? */
45
        b       done
46
        copy    0,ret0                  /*return 0 (delay slot)          */
47
findout:
48
        comibf,=,n      0,s1,checks1    /*s1 == NULL?    */
49
        ldbs    0(0,s2),ret0            /**/
50
        b       done                    /*quit   */
51
        sub     0,ret0,ret0             /*ret0 <- -*s2 */
52
checks1:
53
        comibf,=,n      0,s2,checkitout /*s2 == NULL?    */
54
        b       done                    /* quit  */
55
        ldbs    0(0,s1),28              /* return *s1 */
56
 
57
checkitout:
58
        extru   s2,31,2,tmp1            /* Extract the low two bits of the s2. */
59
        extru   s1,31,2,tmp5            /* Extract the low two bits of the s1 */
60
        sub,=   tmp5,tmp1,tmp3          /* Are s1 & s2 aligned with each other? */
61
        b       not_aligned             /* It's more complicated (not_aligned) */
62
        dep     0,31,2,s1               /* Compute word address of s1 (DELAY SLOT) */
63
        dep     0,31,2,s2               /* Compute word address of s2 */
64
        ldwm    4(0,s1),s1word          /* get next s1 word  s1+=4 */
65
        combt,= tmp5,r0,skipmask        /* skip masking, if we can */
66
        ldwm    4(0,s2),s2word          /* get next s2 word  s2+=4 (DELAY SLOT) */
67
        add     tmp5,count,count        /* bump count by the number of bytes */
68
                                        /*  we are going to mask */
69
        sh3add  tmp5,r0,save            /* save now has number of bits to mask */
70
        mtctl   save,11
71
        zvdepi  -2,32,save              /* load save with proper mask */
72
        or      save,s1word,s1word      /* mask s1word (s1) */
73
        or      save,s2word,s2word      /* mask s2word (s2) */
74
 
75
 
76
skipmask:
77
        combt,=,n       s1word,s2word,checkN    /* We may be done */
78
 
79
checkbyte:
80
        extru   s1word,7,8,tmp3         /* get first byte (character) */
81
ckbyte2:        extru   s2word,7,8,tmp7         /* get first byte (character) */
82
        combf,= tmp3,tmp7,done          /* quit if first byte is not equal */
83
        sub     tmp3,tmp7,ret0          /* return difference (delay slot) */
84
        addibt,<=,n     -1,count,done   /* have we checked N chars? ret0 == 0 */
85
        extru   s1word,15,8,tmp3        /* get second byte (character) */
86
        extru   s2word,15,8,tmp7        /* get second byte (character)   */
87
        combf,= tmp3,tmp7,done          /* quit if second byte is not equal */
88
        sub     tmp3,tmp7,ret0          /* return difference (delay slot) */
89
        addibt,<=,n     -1,count,done   /* have we checked N chars? */
90
        extru   s1word,23,8,tmp3        /* get third byte (character) */
91
        extru   s2word,23,8,tmp7        /* get third byte (character)    */
92
        combf,= tmp3,tmp7,done          /* done if third byte is not equal */
93
        sub     tmp3,tmp7,ret0          /* return difference (delay slot) */
94
        addibt,<=,n     -1,count,done   /* have we checked N chars? */
95
        extru   s1word,31,8,tmp3        /* get last byte (character) */
96
        extru   s2word,31,8,tmp7        /* get last byte (character)     */
97
        b       done                    /* if we reach this point we know that */
98
        sub     tmp3,tmp7,ret0          /*  the last character in the word is */
99
                                        /*   where the  difference is, so return */
100
                                        /*    the difference and we're outta here */
101
 
102
 
103
checkN:
104
        addibt,<=,n     -4,count,zero   /* have we checked N chars? */
105
        ldwm    4(0,s2),s2word          /* get next s2 word  s2+=4 */
106
        b       skipmask                /* keep checking */
107
        ldwm    4(0,s1),s1word          /* get next s1 word  s1+=4 */
108
 
109
 
110
not_aligned:
111
        dep     r0,31,2,s2              /* Compute word address of s2 */
112
        combt,<,n       r0,tmp3,shifts1 /* Do we shift s1 or s2 */
113
        sh3add  tmp3,r0,tmp3            /* eight bits per byte so mul by 8 */
114
        ldwm    4(0,s1),s1word          /* get first word of s1 */
115
        ldwm    4(0,s2),s2word          /* get first word or s2 */
116
        combt,=,n       r0,tmp5,masks2  /* Do we need to mask beginning of s1 */
117
        add     tmp5,count,count        /* bump count by the number of bytes */
118
                                        /*  we are going to mask */
119
        sh3add  tmp5,r0,save            /* save now has number of bits to mask */
120
        mtctl   save,11
121
        zvdepi  -2,32,save              /* load save with proper mask */
122
        or      save,s1word,s1word      /**/
123
masks2: sh3add  tmp1,r0,save            /* save now has number of bits to mask */
124
        mtctl   save,11
125
        zvdepi  -2,32,save              /* load save with proper mask */
126
        or      save,s2word,s2word      /**/
127
        subi    4,tmp1,tmp1             /* tmp1 now has the number of byte that */
128
                                        /* are valid in s2word before the vshd */
129
        mtctl   tmp3,11                 /* Move shift amount to CR11 */
130
more:   combt,<=,n      count,tmp1,chunk1       /* Can we do the vshd? */
131
        ldwm    4(0,s2),tmp7            /* load second word to enable us to shift */
132
        vshd    s2word,tmp7,s2word      /**/
133
        combf,=,n       s1word,s2word,ckbyte2   /**/
134
        extru   s1word,7,8,tmp3         /* get first byte (DELAY SLOT) */
135
        addibt,<=,n     -4,count,zero   /* have we checked N chars? */
136
        copy    tmp7,s2word             /**/
137
        b       more                    /* keep checking */
138
        ldwm    4(0,s1),s1word          /* get next s1 (DELAY SLOT) */
139
 
140
chunk1:
141
        vshd    s2word,r0,s2word        /* do an arithmetic shift left to position data */
142
        b       ckbyte2                 /**/
143
        extru   s1word,7,8,tmp3         /**/
144
 
145
 
146
shifts1:
147
        sh3add  tmp3,r0,tmp3            /* eight bits per byte so mul by 8 */
148
        sub     r0,tmp3,tmp3            /* Get negative value for left shift */
149
        dep     r0,31,2,s2              /* Compute word address of s2 */
150
        ldwm    4(0,s2),s2word          /* get first word of s2 */
151
        ldwm    4(0,s1),s1word          /* get first word or s1 */
152
        combt,=,n       r0,tmp1,masks1  /*Do we need to mask beginning of s2 */
153
        add     tmp1,count,count        /*bump count by the number of bytes */
154
                                        /* we are going to mask */
155
        sh3add  tmp1,r0,save            /*save now has number of bits to mask */
156
        mtctl   save,11
157
        zvdepi  -2,32,save              /*load save with proper mask */
158
        or      save,s2word,s2word      /**/
159
masks1: sh3add  tmp5,r0,save            /*save now has number of bits to mask */
160
        mtctl   save,11
161
        zvdepi  -2,32,save              /*load save with proper mask */
162
        or      save,s1word,s1word      /**/
163
        subi    4,tmp5,tmp5             /*tmp5 now has the number of byte that */
164
                                        /*are valid in s1word before the vshd */
165
        mtctl   tmp3,11                 /*Move shift amount to CR11 */
166
more1:  combt,<=,n      count,tmp5,chunk2       /*Can we do the vshd? */
167
        ldwm    4(0,s1),tmp7            /*load second word to enable us to shift */
168
        vshd    s1word,tmp7,s1word      /**/
169
        combf,=,n       s2word,s1word,ckbyte2   /**/
170
        extru   s1word,7,8,tmp3         /*get first byte (DELAY SLOT) */
171
        addibt,<=,n     -4,count,zero   /*have we checked N chars? */
172
        copy    tmp7,s1word             /**/
173
        b       more1                   /*keep checking */
174
        ldwm    4(0,s2),s2word          /*get next s2 (DELAY SLOT) */
175
 
176
chunk2:
177
        vshd    s1word,r0,s1word        /**/
178
        b       ckbyte2                 /**/
179
        extru   s1word,7,8,tmp3         /**/
180
 
181
zero:   copy    r0,ret0
182
done:
183
EXIT(memcmp)

powered by: WebSVN 2.1.0

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