
		AREA	|ARM$$code|,CODE,READONLY

;		[ :LNOT: :DEF: NDEBUG
;		IMPORT	assert_failed
;		]

		EXPORT	fillmem

; Fill a word-aligned area of memory with a repeated
; word value (usually 0). The area is assumed to be
; >= 64 bytes in length and a /multiple/ of 64 bytes.
;
; entry	a1 -> base of memory to be filled
;	a2 = word value to be repeated throughout memory
;	a3 = size (in bytes), must be multiple of 64

fillmem
;		[ :LNOT: :DEF: NDEBUG
;		TST	a3,#63
;		BLNE	assert_failed
;		CMP	a3,#0
;		BLLE	assert_failed
;		]

;??? is it possible to allocate a line without pulling in any data?
;	YES! it's the way that dcache cleaning works :)
		PLD	[a1]
		PLD	[a1,#32]

fill_lp		SUBS	a3,a3,#64
		MOVLO	pc,lr
		PLD	[a1,#64]
		PLD	[a1,#96]
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		STR	a2,[a1],#4
		B	fill_lp

		END
