xref: /kernel/linux/linux-6.6/arch/sh/lib/memset.S (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* $Id: memset.S,v 1.1 2000/04/14 16:49:01 mjd Exp $
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * "memset" implementation of SuperH
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (C) 1999  Niibe Yutaka
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/*
1162306a36Sopenharmony_ci *            void *memset(void *s, int c, size_t n);
1262306a36Sopenharmony_ci */
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#include <linux/linkage.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciENTRY(memset)
1762306a36Sopenharmony_ci	tst	r6,r6
1862306a36Sopenharmony_ci	bt/s	5f		! if n=0, do nothing
1962306a36Sopenharmony_ci	 add	r6,r4
2062306a36Sopenharmony_ci	mov	#12,r0
2162306a36Sopenharmony_ci	cmp/gt	r6,r0
2262306a36Sopenharmony_ci	bt/s	4f		! if it's too small, set a byte at once
2362306a36Sopenharmony_ci	 mov	r4,r0
2462306a36Sopenharmony_ci	and	#3,r0
2562306a36Sopenharmony_ci	cmp/eq	#0,r0
2662306a36Sopenharmony_ci	bt/s	2f		! It's aligned
2762306a36Sopenharmony_ci	 sub	r0,r6
2862306a36Sopenharmony_ci1:
2962306a36Sopenharmony_ci	dt	r0
3062306a36Sopenharmony_ci	bf/s	1b
3162306a36Sopenharmony_ci	 mov.b	r5,@-r4
3262306a36Sopenharmony_ci2:				! make VVVV
3362306a36Sopenharmony_ci	extu.b	r5,r5
3462306a36Sopenharmony_ci	swap.b	r5,r0		!   V0
3562306a36Sopenharmony_ci	or	r0,r5		!   VV
3662306a36Sopenharmony_ci	swap.w	r5,r0		! VV00
3762306a36Sopenharmony_ci	or	r0,r5		! VVVV
3862306a36Sopenharmony_ci	!
3962306a36Sopenharmony_ci	mov	r6,r0
4062306a36Sopenharmony_ci	shlr2	r0
4162306a36Sopenharmony_ci	shlr	r0		! r0 = r6 >> 3
4262306a36Sopenharmony_ci3:
4362306a36Sopenharmony_ci	dt	r0
4462306a36Sopenharmony_ci	mov.l	r5,@-r4		! set 8-byte at once
4562306a36Sopenharmony_ci	bf/s	3b
4662306a36Sopenharmony_ci	 mov.l	r5,@-r4
4762306a36Sopenharmony_ci	!
4862306a36Sopenharmony_ci	mov	#7,r0
4962306a36Sopenharmony_ci	and	r0,r6
5062306a36Sopenharmony_ci	tst	r6,r6
5162306a36Sopenharmony_ci	bt	5f
5262306a36Sopenharmony_ci	! fill bytes
5362306a36Sopenharmony_ci4:
5462306a36Sopenharmony_ci	dt	r6
5562306a36Sopenharmony_ci	bf/s	4b
5662306a36Sopenharmony_ci	 mov.b	r5,@-r4
5762306a36Sopenharmony_ci5:
5862306a36Sopenharmony_ci	rts
5962306a36Sopenharmony_ci	 mov	r4,r0
60