/* rawmemchr (str, ch) -- Return pointer to first occurrence of CH in STR.
For Motorola 68000.
- Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1999-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Andreas Schwab <schwab@gnu.org>.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include "asm-syntax.h"
ENTRY(__rawmemchr)
/* Save the callee-saved registers we use. */
movel R(d2),MEM_PREDEC(sp)
+ cfi_adjust_cfa_offset (4)
movel R(d3),MEM_PREDEC(sp)
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (R(d2), 4)
+ cfi_rel_offset (R(d3), 0)
/* Get string pointer and character. */
movel MEM_DISP(sp,12),R(a0)
/* First search for the character one byte at a time until the
pointer is aligned to a longword boundary. */
movel R(a0),R(d1)
+#ifdef __mcoldfire__
+ andl #3,R(d1)
+#else
andw #3,R(d1)
+#endif
beq L(L1)
cmpb MEM(a0),R(d0)
beq L(L9)
addql #1,R(a0)
- movel R(a0),R(d1)
- andw #3,R(d1)
+#ifdef __mcoldfire__
+ subql #3,R(d1)
+#else
+ subqw #3,R(d1)
+#endif
beq L(L1)
cmpb MEM(a0),R(d0)
beq L(L9)
addql #1,R(a0)
- movel R(a0),R(d1)
- andw #3,R(d1)
+#ifdef __mcoldfire__
+ addql #1,R(d1)
+#else
+ addqw #1,R(d1)
+#endif
beq L(L1)
cmpb MEM(a0),R(d0)
beq L(L9)
L(L9:)
movel R(a0),R(d0)
movel MEM_POSTINC(sp),R(d3)
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (R(d3))
movel MEM_POSTINC(sp),R(d2)
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (R(d2))
rts
END(__rawmemchr)