2005-04-17 02:20:36 +04:00
/ *
* linux/ a r c h / a r m / l i b / m e m s e t . S
*
* Copyright ( C ) 1 9 9 5 - 2 0 0 0 R u s s e l l K i n g
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e v e r s i o n 2 a s
* published b y t h e F r e e S o f t w a r e F o u n d a t i o n .
*
* ASM o p t i m i s e d s t r i n g f u n c t i o n s
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a s s e m b l e r . h >
.text
.align 5
.word 0
1 : subs r2 , r2 , #4 @ 1 do we have enough
blt 5 f @ 1 bytes to align with?
cmp r3 , #2 @ 1
strltb r1 , [ r0 ] , #1 @ 1
strleb r1 , [ r0 ] , #1 @ 1
strb r1 , [ r0 ] , #1 @ 1
add r2 , r2 , r3 @ 1 (r2 = r2 - (4 - r3))
/ *
* The p o i n t e r i s n o w a l i g n e d a n d t h e l e n g t h i s a d j u s t e d . T r y d o i n g t h e
* memzero a g a i n .
* /
ENTRY( m e m s e t )
ands r3 , r0 , #3 @ 1 unaligned?
bne 1 b @ 1
/ *
* we k n o w t h a t t h e p o i n t e r i n r0 i s a l i g n e d t o a w o r d b o u n d a r y .
* /
orr r1 , r1 , r1 , l s l #8
orr r1 , r1 , r1 , l s l #16
mov r3 , r1
cmp r2 , #16
blt 4 f
/ *
* We n e e d a n e x t r a r e g i s t e r f o r t h i s l o o p - s a v e t h e r e t u r n a d d r e s s a n d
* use t h e L R
* /
str l r , [ s p , #- 4 ] !
mov i p , r1
mov l r , r1
2 : subs r2 , r2 , #64
stmgeia r0 ! , { r1 , r3 , i p , l r } @ 64 bytes at a time.
stmgeia r0 ! , { r1 , r3 , i p , l r }
stmgeia r0 ! , { r1 , r3 , i p , l r }
stmgeia r0 ! , { r1 , r3 , i p , l r }
bgt 2 b
2006-06-25 14:23:45 +04:00
ldmeqfd s p ! , { p c } @ Now <64 bytes to go.
2005-04-17 02:20:36 +04:00
/ *
* No n e e d t o c o r r e c t t h e c o u n t ; we're only testing bits from now on
* /
tst r2 , #32
stmneia r0 ! , { r1 , r3 , i p , l r }
stmneia r0 ! , { r1 , r3 , i p , l r }
tst r2 , #16
stmneia r0 ! , { r1 , r3 , i p , l r }
ldr l r , [ s p ] , #4
4 : tst r2 , #8
stmneia r0 ! , { r1 , r3 }
tst r2 , #4
strne r1 , [ r0 ] , #4
/ *
* When w e g e t h e r e , w e ' v e g o t l e s s t h a n 4 b y t e s t o z e r o . W e
* may h a v e a n u n a l i g n e d p o i n t e r a s w e l l .
* /
5 : tst r2 , #2
strneb r1 , [ r0 ] , #1
strneb r1 , [ r0 ] , #1
tst r2 , #1
strneb r1 , [ r0 ] , #1
2006-06-25 14:17:23 +04:00
mov p c , l r