2005-09-26 16:04:21 +10:00
/ *
* String h a n d l i n g f u n c t i o n s f o r P o w e r P C .
*
* Copyright ( C ) 1 9 9 6 P a u l M a c k e r r a s .
*
* 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 i t 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
* as p u b l i s h e d 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 ; either version
* 2 of t h e L i c e n s e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
* /
# include < a s m / p r o c e s s o r . h >
# include < a s m / e r r n o . h >
# include < a s m / p p c _ a s m . h >
2016-01-13 23:33:46 -05:00
# include < a s m / e x p o r t . h >
2005-09-26 16:04:21 +10:00
.text
/ * This c l e a r s o u t a n y u n u s e d p a r t o f t h e d e s t i n a t i o n b u f f e r ,
just a s t h e l i b c v e r s i o n d o e s . - - p a u l u s * /
_ GLOBAL( s t r n c p y )
2010-05-18 08:15:21 +00:00
PPC_ L C M P I 0 ,r5 ,0
2005-09-26 16:04:21 +10:00
beqlr
mtctr r5
addi r6 ,r3 ,- 1
addi r4 ,r4 ,- 1
2016-05-26 08:39:55 +10:00
.balign 16
2005-09-26 16:04:21 +10:00
1 : lbzu r0 ,1 ( r4 )
cmpwi 0 ,r0 ,0
stbu r0 ,1 ( r6 )
bdnzf 2 ,1 b / * d e c c t r , b r a n c h i f c t r ! = 0 & & ! c r0 . e q * /
bnelr / * i f w e d i d n ' t h i t a n u l l c h a r , w e ' r e d o n e * /
mfctr r5
2010-05-18 08:15:21 +00:00
PPC_ L C M P I 0 ,r5 ,0 / * a n y s p a c e l e f t i n d e s t i n a t i o n b u f f e r ? * /
2005-09-26 16:04:21 +10:00
beqlr / * w e k n o w r0 = = 0 h e r e * /
2 : stbu r0 ,1 ( r6 ) / * c l e a r i t o u t i f s o * /
bdnz 2 b
blr
2016-01-13 23:33:46 -05:00
EXPORT_ S Y M B O L ( s t r n c p y )
2005-09-26 16:04:21 +10:00
2008-03-01 03:04:57 +11:00
_ GLOBAL( s t r n c m p )
2010-05-18 08:15:21 +00:00
PPC_ L C M P I 0 ,r5 ,0
beq- 2 f
2008-03-01 03:04:57 +11:00
mtctr r5
addi r5 ,r3 ,- 1
addi r4 ,r4 ,- 1
2016-05-26 08:39:55 +10:00
.balign 16
2008-03-01 03:04:57 +11:00
1 : lbzu r3 ,1 ( r5 )
cmpwi 1 ,r3 ,0
lbzu r0 ,1 ( r4 )
subf. r3 ,r0 ,r3
beqlr 1
bdnzt e q ,1 b
blr
2010-03-17 10:55:51 +00:00
2 : li r3 ,0
blr
2016-01-13 23:33:46 -05:00
EXPORT_ S Y M B O L ( s t r n c m p )
2008-03-01 03:04:57 +11:00
2015-01-21 12:27:38 +11:00
# ifdef C O N F I G _ P P C 3 2
2005-09-26 16:04:21 +10:00
_ GLOBAL( m e m c m p )
2010-05-18 08:15:21 +00:00
PPC_ L C M P I 0 ,r5 ,0
beq- 2 f
2005-09-26 16:04:21 +10:00
mtctr r5
addi r6 ,r3 ,- 1
addi r4 ,r4 ,- 1
1 : lbzu r3 ,1 ( r6 )
lbzu r0 ,1 ( r4 )
subf. r3 ,r0 ,r3
bdnzt 2 ,1 b
blr
2 : li r3 ,0
blr
2016-01-13 23:33:46 -05:00
EXPORT_ S Y M B O L ( m e m c m p )
2015-01-21 12:27:38 +11:00
# endif
2005-09-26 16:04:21 +10:00
_ GLOBAL( m e m c h r )
2010-05-18 08:15:21 +00:00
PPC_ L C M P I 0 ,r5 ,0
beq- 2 f
2005-09-26 16:04:21 +10:00
mtctr r5
addi r3 ,r3 ,- 1
2016-05-26 08:39:55 +10:00
.balign 16
2005-09-26 16:04:21 +10:00
1 : lbzu r0 ,1 ( r3 )
cmpw 0 ,r0 ,r4
bdnzf 2 ,1 b
beqlr
2 : li r3 ,0
blr
2016-01-13 23:33:46 -05:00
EXPORT_ S Y M B O L ( m e m c h r )
2005-09-26 16:04:21 +10:00
2012-05-27 19:54:03 +00:00
# ifdef C O N F I G _ P P C 3 2
2005-09-26 16:04:21 +10:00
_ GLOBAL( _ _ c l e a r _ u s e r )
addi r6 ,r3 ,- 4
li r3 ,0
li r5 ,0
cmplwi 0 ,r4 ,4
blt 7 f
/* clear a single word */
11 : stwu r5 ,4 ( r6 )
beqlr
/* clear word sized chunks */
andi. r0 ,r6 ,3
add r4 ,r0 ,r4
subf r6 ,r0 ,r6
srwi r0 ,r4 ,2
andi. r4 ,r4 ,3
mtctr r0
bdz 7 f
1 : stwu r5 ,4 ( r6 )
bdnz 1 b
/* clear byte sized chunks */
7 : cmpwi 0 ,r4 ,0
beqlr
mtctr r4
addi r6 ,r6 ,3
8 : stbu r5 ,1 ( r6 )
bdnz 8 b
blr
90 : mr r3 ,r4
blr
91 : mfctr r3
slwi r3 ,r3 ,2
add r3 ,r3 ,r4
blr
92 : mfctr r3
blr
2016-10-13 16:42:53 +11:00
EX_ T A B L E ( 1 1 b , 9 0 b )
EX_ T A B L E ( 1 b , 9 1 b )
EX_ T A B L E ( 8 b , 9 2 b )
2016-01-13 23:33:46 -05:00
EXPORT_ S Y M B O L ( _ _ c l e a r _ u s e r )
2012-05-27 19:54:03 +00:00
# endif