/****************************************************************************/
/*	Copyright (c) 2009, Bendor Research Pty. Ltd. All rights reserved.		*/
/*	This software is released under the GNU General Public License, version	*/
/*	3, with the exemptions that 1) the header files installed by this 	 	*/
/*	package can be included in closed-source code and 2) the libraries		*/
/*	built by this package can be statically linked into a closed-source 	*/
/*	binary. See the file LICENSE for the details.							*/
/*	This software is provided "AS IS", without any warranty or guarantee.	*/
/*	By using this software you acknowledge that neither Bendor Research nor	*/
/*	any of its personnel or affiliates can be held liable for any damages,	*/
/*	including, but not limited to, loss of business, loss of money, loss of */
/*	life, loss of reputation, arising out of this software being faulty or	*/
/*	not performing as advertised, even if Bendor Research was aware of such	*/
/*	faults in the software. You use this software at your own risk, any and */
/*	all liabilities that arise out of your using this software are strictly	*/
/*	yours.																	*/
/****************************************************************************/

#include <arm_func.h>

	afunc	memset_fast
	stmdb	sp!,{r0,r4-r7}
	and		r1,r1,#0xff
	orr		r1,r1,r1,lsl #8
	orr		r1,r1,r1,lsl #16
	mov		r3,r1
	mov		r4,r1
	mov		r5,r1
	mov		r6,r1
	mov		r7,r1
	mov		r12,r1
	tst		r2,r2
0:
	beq		done
	tst		r0,#3
	beq		1f
	strb	r1,[r0],#1
	subs	r2,r2,#1
	b		0b
1:
	subs	r2,r2,#28
	bmi		1f
0:
	stmia	r0!,{r1,r3-r7,r12}
	subs	r2,r2,#28
	bpl		0b
1:
	adds	r2,r2,#24
	bmi		1f
0:
	str		r1,[r0],#4
	subs	r2,r2,#4
	bpl		0b
1:
	add		r2,r2,#4
0:
	subs	r2,r2,#1
	strplb	r1,[r0],#1
	bpl		0b
done:
	ldmia	sp!,{r0,r4-r7}
	bx		lr

