2005-09-26 10:04:21 +04: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 p c _ a s m . h >
2016-01-14 07:33:46 +03:00
# include < a s m / e x p o r t . h >
2018-05-18 16:01:16 +03:00
# include < a s m / c a c h e . h >
2005-09-26 10:04:21 +04: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 12:15:21 +04:00
PPC_ L C M P I 0 ,r5 ,0
2005-09-26 10:04:21 +04:00
beqlr
mtctr r5
addi r6 ,r3 ,- 1
addi r4 ,r4 ,- 1
2018-05-18 16:01:16 +03:00
.balign IFETCH_ALIGN_BYTES
2005-09-26 10:04:21 +04: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 12:15:21 +04: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 10:04:21 +04: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-14 07:33:46 +03:00
EXPORT_ S Y M B O L ( s t r n c p y )
2005-09-26 10:04:21 +04:00
2008-02-29 19:04:57 +03:00
_ GLOBAL( s t r n c m p )
2010-05-18 12:15:21 +04:00
PPC_ L C M P I 0 ,r5 ,0
beq- 2 f
2008-02-29 19:04:57 +03:00
mtctr r5
addi r5 ,r3 ,- 1
addi r4 ,r4 ,- 1
2018-05-18 16:01:16 +03:00
.balign IFETCH_ALIGN_BYTES
2008-02-29 19:04:57 +03: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 13:55:51 +03:00
2 : li r3 ,0
blr
2016-01-14 07:33:46 +03:00
EXPORT_ S Y M B O L ( s t r n c m p )
2008-02-29 19:04:57 +03:00
2005-09-26 10:04:21 +04:00
_ GLOBAL( m e m c h r )
2010-05-18 12:15:21 +04:00
PPC_ L C M P I 0 ,r5 ,0
beq- 2 f
2005-09-26 10:04:21 +04:00
mtctr r5
addi r3 ,r3 ,- 1
2018-05-18 16:01:16 +03:00
.balign IFETCH_ALIGN_BYTES
2005-09-26 10:04:21 +04:00
1 : lbzu r0 ,1 ( r3 )
cmpw 0 ,r0 ,r4
bdnzf 2 ,1 b
beqlr
2 : li r3 ,0
blr
2016-01-14 07:33:46 +03:00
EXPORT_ S Y M B O L ( m e m c h r )