/[avr-libc]/avr-libc/libc/string/strrev.S
ViewVC logotype

Diff of /avr-libc/libc/string/strrev.S

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by troth, Tue Sep 30 23:05:19 2003 UTC revision 1.3.4.1 by aesok, Sun Oct 30 19:46:44 2005 UTC
# Line 26  Line 26 
26    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27    POSSIBILITY OF SUCH DAMAGE. */    POSSIBILITY OF SUCH DAMAGE. */
28    
29    /* $Id$ */
30    
31  /*  /*
32     strrev.S     strrev.S
33     Reverse a string     Reverse a string
# Line 56  Line 58 
58      .type   _U(strrev), @function      .type   _U(strrev), @function
59    
60  _U(strrev):  _U(strrev):
61      LOAD_X(str_lo, str_hi)      ; X is start of string          X_movw  XL, str_lo      ; X is start of string
62          LOAD_Z(str_lo, str_hi)  ; Z becomes end of string          X_movw  ZL, str_lo      ; Z becomes end of string
63  .strrev_eos:  .L_strrev_eos:
64          LD    __tmp_reg__, Z+          LD    __tmp_reg__, Z+
65          TST   __tmp_reg__          TST   __tmp_reg__
66          BRNE  .strrev_eos          BRNE  .L_strrev_eos
67          SBIW  ZL, 2                             ; now Z points at end of string          SBIW  ZL, 2                             ; now Z points at end of string
68  .strrev_loop:  .L_strrev_loop:
69          CP    XL, ZL          CP    XL, ZL
70          CPC   XH, ZH                    ; if X >= Z we are done          CPC   XH, ZH                    ; if X >= Z we are done
71          BRSH  .strrev_done          BRSH  .L_strrev_done
72          LD    ltemp, X          ; get left character          LD    ltemp, X          ; get left character
73          LD    rtemp, Z                  ; get right character          LD    rtemp, Z                  ; get right character
74          ST    Z, ltemp          ST    Z, ltemp
75          SBIW  ZL, 1          SBIW  ZL, 1
76          ST    X+, rtemp                 ; swap chars          ST    X+, rtemp                 ; swap chars
77          RJMP  .strrev_loop              ; next pair          RJMP  .L_strrev_loop            ; next pair
78  .strrev_done:  .L_strrev_done:
79      RET      RET
80  .strrev_end:  .L_strrev_end:
81          .size _U(strrev), .strrev_end - _U(strrev)          .size _U(strrev), .L_strrev_end - _U(strrev)
82    
83  #endif /* not DOXYGEN */  #endif /* not DOXYGEN */

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.3.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26