avr-libc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-commit] [2542] [#9187] [AVR_TINY]: Support 16-bit xtoa functon


From: j
Subject: [avr-libc-commit] [2542] [#9187] [AVR_TINY]: Support 16-bit xtoa functons and more string functions.
Date: Mon, 12 Jun 2017 18:08:59 -0400 (EDT)

Revision: 2542
          http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2542
Author:   joerg_wunsch
Date:     2017-06-12 18:08:58 -0400 (Mon, 12 Jun 2017)
Log Message:
-----------
[#9187] [AVR_TINY]: Support 16-bit xtoa functons and more string functions.

Modified Paths:
--------------
    trunk/avr-libc/ChangeLog
    trunk/avr-libc/NEWS
    trunk/avr-libc/common/asmdef.h
    trunk/avr-libc/common/macros.inc
    trunk/avr-libc/libc/misc/itoa.S
    trunk/avr-libc/libc/misc/itoa_ncheck.S
    trunk/avr-libc/libc/misc/utoa.S
    trunk/avr-libc/libc/misc/utoa_ncheck.S
    trunk/avr-libc/libc/string/memchr.S
    trunk/avr-libc/libc/string/memrchr.S
    trunk/avr-libc/libc/string/strcat.S
    trunk/avr-libc/libc/string/strchr.S
    trunk/avr-libc/libc/string/strchrnul.S
    trunk/avr-libc/libc/string/strlcat.S
    trunk/avr-libc/libc/string/strncat.S
    trunk/avr-libc/libc/string/strpbrk.S
    trunk/avr-libc/libc/string/strrchr.S
    trunk/avr-libc/libc/string/strrev.S
    trunk/avr-libc/libc/string/strstr.S
    trunk/avr-libc/libc/string/strtok_r.S

Modified: trunk/avr-libc/ChangeLog
===================================================================
--- trunk/avr-libc/ChangeLog    2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/ChangeLog    2017-06-12 22:08:58 UTC (rev 2542)
@@ -1,5 +1,38 @@
 2017-06-11  Joerg Wunsch <address@hidden>
 
+       Submitted by Georg-Johann Lay:
+       patch #9187: [AVR_TINY]: Support 16-bit xtoa functons and more string 
functions.
+       * common/asmdef.h (X_sbiw): New asm macro.
+       * common/macros.inc (X_sbiw): New asm macro.
+       * libc/misc/itoa.S: Don't restrict to !AVR_TINY.
+       * libc/misc/itoa_ncheck.S: Same.
+       * libc/misc/utoa.S: Same.
+       * libc/misc/utoa_ncheck.S: Same. And use X_sbiw instead of sbiw.
+       * libc/string/strlcat.S: Same.
+       * libc/string/strncat.S: Same.
+       * libc/string/strrev.S: Same.
+       * libc/string/strrchr.S: Same.
+       * libc/string/memchr.S: Don't restrict to !AVR_TINY.
+       [AVR_TINY]: Use "ld __tmp_reg__,-R" instead of "sbiw R,1".
+       * libc/string/strcat.S: Same.
+       * libc/string/strchr.S: Same.
+       * libc/string/memrchr.S: Don't restrict to !AVR_TINY.
+       (r0): Use __tmp_reg__ instead.
+       (adiw ZL,0): Use X_sbiw ZL,0 for comparison against 0 instead.
+       * libc/string/strchrnul.S: Don't restrict to !AVR_TINY.
+       (r0): Use __tmp_reg__ instead.
+       [AVR_TINY]: Use "ld __tmp_reg__,-R" instead of "sbiw R,1".
+       * libc/string/strpbrk.S: Same.
+       * libc/string/strstr.S: Don't restrict to !AVR_TINY.
+       Use X_sbiw instead of sbiw.
+       (chr2): Define to __tmp_reg__ instead of to r0.
+       * libc/string/strtok_r.S: Don't restrict to !AVR_TINY.
+       Use X_sbiw instead of sbiw.
+       (dch) [AVR_TINY]: Push / pop r18 around function.
+       [AVR_TINY]: Use "ld __tmp_reg__,R+" instead of "adiw R,1".
+
+2017-06-11  Joerg Wunsch <address@hidden>
+
        Submitted by Britton Kerin:
        patch #8650: another small doc fix in atomic.h
        * include/util/atomic.h: Improve documentation.

Modified: trunk/avr-libc/NEWS
===================================================================
--- trunk/avr-libc/NEWS 2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/NEWS 2017-06-12 22:08:58 UTC (rev 2542)
@@ -1,5 +1,13 @@
 *** Changes since avr-libc-2.0.0:
 
+* Improvements and additions:
+
+  - Patch #9187 improved the library coverage for the AVR_TINY
+    architecture (ATtiny10 and relatives).  In particular, many
+    of the functions from <string.h> are now available there.
+
+  - Patch #8729 adds ISR_NOICF and ISR_FLATTEN to <avr/interrupt.h>
+
 * Bugs fixed:
 
   [#36933] Documentation no longer correctly describes how to declare
@@ -23,6 +31,7 @@
   [#8729] [avr/interrupt.h] Add ISR_NOICF, ISR_FLATTEN. Fix namespace of 
identifiers.
   [#8536] Fix a typo within <stdio.h>
   [#8649] small documentation fixes in
+  [#9187] [AVR_TINY]: Support 16-bit xtoa functons and more string functions.
 
 * Other changes:
 

Modified: trunk/avr-libc/common/asmdef.h
===================================================================
--- trunk/avr-libc/common/asmdef.h      2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/common/asmdef.h      2017-06-12 22:08:58 UTC (rev 2542)
@@ -206,6 +206,25 @@
 #endif
 .endm
 
+/* Macro 'X_sbiw' extends SBIW instruction for AVR_TINY chips. */
+.macro X_sbiw  dst,val
+#if !defined (__AVR_TINY__)
+       sbiw    \dst,\val
+#else
+  REGNO        .L__sbiw_dst, \dst
+  .if  .L__sbiw_dst < 0
+    .exitm
+  .endif
+  .if  .L__sbiw_dst % 1
+    .err       ; Invalid register arg in X_sbiw macro.
+    .exitm
+  .endif
+
+       subi    .L__sbiw_dst, \val
+       sbci    .L__sbiw_dst + 1, 0
+#endif /* AVR_TINY */
+.endm
+
 /* Macro 'X_lpm' extends enhanced lpm instruction for classic chips.
    Usage:
        X_lpm   reg, dst

Modified: trunk/avr-libc/common/macros.inc
===================================================================
--- trunk/avr-libc/common/macros.inc    2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/common/macros.inc    2017-06-12 22:08:58 UTC (rev 2542)
@@ -225,6 +225,45 @@
        .endif
 .endm
 
+
+.macro  X_sbiw dst val
+       .L_sbiw_dst = -1
+       .L_sbiw_n = 24
+       .irp  reg,      r24,r26,r28,r30
+               .ifc  \reg,\dst
+                       .L_sbiw_dst = .L_sbiw_n
+               .endif
+               .L_sbiw_n = .L_sbiw_n + 2
+       .endr
+       .L_sbiw_n = 24
+       .irp  reg,      R24,R26,R28,R30
+               .ifc  \reg,\dst
+                       .L_sbiw_dst = .L_sbiw_n
+               .endif
+               .L_sbiw_n = .L_sbiw_n + 2
+       .endr
+       .if   .L_sbiw_dst < 0
+               .L_sbiw_n = 24
+               .rept   4
+                       .if \dst == .L_sbiw_n
+                               .L_sbiw_dst = .L_sbiw_n
+                       .endif
+                       .L_sbiw_n = .L_sbiw_n + 2
+               .endr
+       .endif
+       .if   (.L_sbiw_dst < 0)
+               .err    ; Invalid 'X_sbiw' arg.
+       .endif
+
+#if !defined (__AVR_TINY__)
+       sbiw    \dst, \val
+#else
+       subi    (.L_sbiw_dst), \val
+       sbci    (.L_sbiw_dst)+1, 0
+#endif
+.endm
+
+
 /* Macro 'X_lpm' extends enhanced lpm instruction for classic chips.
    Usage:
        X_lpm   reg, dst

Modified: trunk/avr-libc/libc/misc/itoa.S
===================================================================
--- trunk/avr-libc/libc/misc/itoa.S     2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/libc/misc/itoa.S     2017-06-12 22:08:58 UTC (rev 2542)
@@ -29,7 +29,6 @@
 /* $Id$        */
 
 #if    !defined (__DOXYGEN__)
-#if    !defined (__AVR_TINY__)
 
 #include "asmdef.h"
 
@@ -60,5 +59,4 @@
 
 ENDFUNC
 
-#endif /* !__AVR_TINY__ */
 #endif /* !__DOXYGEN__ */

Modified: trunk/avr-libc/libc/misc/itoa_ncheck.S
===================================================================
--- trunk/avr-libc/libc/misc/itoa_ncheck.S      2017-06-11 15:41:47 UTC (rev 
2541)
+++ trunk/avr-libc/libc/misc/itoa_ncheck.S      2017-06-12 22:08:58 UTC (rev 
2542)
@@ -29,7 +29,6 @@
 /* $Id$        */
 
 #if    !defined (__DOXYGEN__)
-#if    !defined (__AVR_TINY__)
 
 #include "asmdef.h"
 
@@ -60,5 +59,4 @@
 
 ENDFUNC
 
-#endif /* !__AVR_TINY__ */
 #endif /* !__DOXYGEN__ */

Modified: trunk/avr-libc/libc/misc/utoa.S
===================================================================
--- trunk/avr-libc/libc/misc/utoa.S     2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/libc/misc/utoa.S     2017-06-12 22:08:58 UTC (rev 2542)
@@ -29,7 +29,6 @@
 /* $Id$        */
 
 #if    !defined (__DOXYGEN__)
-#if    !defined (__AVR_TINY__)
 
 #include "asmdef.h"
 
@@ -60,5 +59,4 @@
 
 ENDFUNC
 
-#endif /* !__AVR_TINY__ */
 #endif /* !__DOXYGEN__ */

Modified: trunk/avr-libc/libc/misc/utoa_ncheck.S
===================================================================
--- trunk/avr-libc/libc/misc/utoa_ncheck.S      2017-06-11 15:41:47 UTC (rev 
2541)
+++ trunk/avr-libc/libc/misc/utoa_ncheck.S      2017-06-12 22:08:58 UTC (rev 
2542)
@@ -29,7 +29,6 @@
 /* $Id$        */
 
 #if    !defined (__DOXYGEN__)
-#if    !defined (__AVR_TINY__)
 
 #include "asmdef.h"
 
@@ -77,7 +76,7 @@
        st      Z+, digit
 
     ; Iterate until all digits are sucked out of VAL.
-       sbiw    val_lo, 0
+       X_sbiw  val_lo, 0
        brne    1b
 
     ; Store the sign (if any)
@@ -93,5 +92,4 @@
 
 ENDFUNC
 
-#endif /* !__AVR_TINY__ */
 #endif /* !__DOXYGEN__ */

Modified: trunk/avr-libc/libc/string/memchr.S
===================================================================
--- trunk/avr-libc/libc/string/memchr.S 2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/libc/string/memchr.S 2017-06-12 22:08:58 UTC (rev 2542)
@@ -28,8 +28,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "macros.inc"
@@ -56,7 +54,12 @@
        ld      __tmp_reg__, Z+
        cp      __tmp_reg__, val_lo
        brne    .L_memchr_loop
-       sbiw    ZL, 1           ; undo post-increment
+       ; undo post-increment
+#if !defined(__AVR_TINY__)
+       sbiw    ZL, 1
+#else
+       ld      __tmp_reg__, -Z
+#endif /*!__AVR_TINY__*/
        X_movw  ret_lo, ZL
        ret
 .L_memchr_notfound:
@@ -67,5 +70,3 @@
        .size   _U(memchr), .L_memchr_end - _U(memchr)
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/memrchr.S
===================================================================
--- trunk/avr-libc/libc/string/memrchr.S        2017-06-11 15:41:47 UTC (rev 
2541)
+++ trunk/avr-libc/libc/string/memrchr.S        2017-06-12 22:08:58 UTC (rev 
2542)
@@ -28,8 +28,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "asmdef.h"
@@ -44,13 +42,13 @@
 
 ENTRY memrchr
        X_movw  ZL, len_lo
-       adiw    ZL, 0
+       X_sbiw  ZL, 0
        breq    2f                      ; len is 0, return NULL
        add     ZL, src_lo
        adc     ZH, src_hi
 
-1:     ld      r0, -Z
-       cp      r0, val
+1:     ld      __tmp_reg__, -Z
+       cp      __tmp_reg__, val
        breq    2f                      ; val is found
        subi    len_lo, lo8(1)
        sbci    len_hi, hi8(1)
@@ -62,5 +60,3 @@
 ENDFUNC
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/strcat.S
===================================================================
--- trunk/avr-libc/libc/string/strcat.S 2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/libc/string/strcat.S 2017-06-12 22:08:58 UTC (rev 2542)
@@ -28,8 +28,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "macros.inc"
@@ -49,7 +47,12 @@
        ld      __tmp_reg__, X+
        tst     __tmp_reg__
        brne    .L_strcat_skip
-       sbiw    XL, 1           ; undo post-increment
+       ; undo post-increment
+#if !defined(__AVR_TINY__)
+       sbiw    XL, 1
+#else
+       ld      __tmp_reg__, -X
+#endif /* !__AVR_TINY__ */
 .L_strcat_loop:
        ld      __tmp_reg__, Z+
        st      X+, __tmp_reg__
@@ -61,5 +64,3 @@
        .size   _U(strcat), .L_strcat_end - _U(strcat)
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/strchr.S
===================================================================
--- trunk/avr-libc/libc/string/strchr.S 2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/libc/string/strchr.S 2017-06-12 22:08:58 UTC (rev 2542)
@@ -28,8 +28,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "macros.inc"
@@ -57,7 +55,12 @@
        clr     ret_hi
        ret
 .L_strchr_found:
-       sbiw    ZL, 1           ; undo post-increment
+       ; undo post-increment
+#if !defined(__AVR_TINY__)
+       sbiw    ZL, 1
+#else
+       ld      __tmp_reg__, -Z
+#endif /*!__AVR_TINY__*/
        X_movw  ret_lo, ZL
        ret
 .L_strchr_end:
@@ -64,5 +67,3 @@
        .size   _U(strchr), .L_strchr_end - _U(strchr)
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/strchrnul.S
===================================================================
--- trunk/avr-libc/libc/string/strchrnul.S      2017-06-11 15:41:47 UTC (rev 
2541)
+++ trunk/avr-libc/libc/string/strchrnul.S      2017-06-12 22:08:58 UTC (rev 
2542)
@@ -28,8 +28,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "asmdef.h"
@@ -42,16 +40,18 @@
 ENTRY strchrnul
        X_movw  ZL, src_lo
 
-1:     ld      r0, Z+
-       cp      r0, val
-       cpse    r0, __zero_reg__
+1:     ld      __tmp_reg__, Z+
+       cp      __tmp_reg__, val
+       cpse    __tmp_reg__, __zero_reg__
        brne    1b
-
-       sbiw    ZL, 1           ; undo post-increment
+       ; undo post-increment
+#if !defined(__AVR_TINY__)
+       sbiw    ZL, 1
+#else
+       ld      __tmp_reg__, -Z
+#endif /* !__AVR_TINY__ */
        X_movw  ret_lo, ZL
        ret
 ENDFUNC
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/strlcat.S
===================================================================
--- trunk/avr-libc/libc/string/strlcat.S        2017-06-11 15:41:47 UTC (rev 
2541)
+++ trunk/avr-libc/libc/string/strlcat.S        2017-06-12 22:08:58 UTC (rev 
2542)
@@ -35,8 +35,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "asmdef.h"
@@ -84,7 +82,7 @@
        ld      __tmp_reg__, X+
        tst     __tmp_reg__
        brne    1b
-       sbiw    XL, 1
+       X_sbiw  XL, 1
        rjmp    3f
 
   ; copy loop
@@ -114,5 +112,3 @@
 
 ENDFUNC
 #endif /* not __DOXYGEN__ */
-
-#endif /* not __AVR_TINY__ */

Modified: trunk/avr-libc/libc/string/strncat.S
===================================================================
--- trunk/avr-libc/libc/string/strncat.S        2017-06-11 15:41:47 UTC (rev 
2541)
+++ trunk/avr-libc/libc/string/strncat.S        2017-06-12 22:08:58 UTC (rev 
2542)
@@ -28,8 +28,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "macros.inc"
@@ -51,7 +49,7 @@
        ld      __tmp_reg__, X+
        tst     __tmp_reg__
        brne    .L_strncat_skip
-       sbiw    XL, 1           ; undo post-increment (point the the NUL)
+       X_sbiw  XL, 1           ; undo post-increment (point to the NUL)
 .L_strncat_loop:
        subi    len_lo, lo8(1)
        sbci    len_hi, hi8(1)
@@ -70,5 +68,3 @@
        .size   _U(strncat), .L_strncat_end - _U(strncat)
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/strpbrk.S
===================================================================
--- trunk/avr-libc/libc/string/strpbrk.S        2017-06-11 15:41:47 UTC (rev 
2541)
+++ trunk/avr-libc/libc/string/strpbrk.S        2017-06-12 22:08:58 UTC (rev 
2542)
@@ -28,8 +28,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #ifndef        __DOXYGEN__
 
 #include "macros.inc"
@@ -56,13 +54,17 @@
        breq    3f
   ; check an occurance
        X_movw  ZL, acc_lo
-2:     ld      r0, Z+
-       cp      r0, ret_lo
-       cpse    r0, __zero_reg__
+2:     ld      __tmp_reg__, Z+
+       cp      __tmp_reg__, ret_lo
+       cpse    __tmp_reg__, __zero_reg__
        brne    2b
        brne    1b              ; branch if end of accept[] is reached
   ; OK, is found
+#if !defined(__AVR_TINY__)
        sbiw    XL, 1
+#else
+       ld      __tmp_reg__, -X
+#endif /* !__AVR_TINY__ */
        X_movw  ret_lo, XL
 3:     ret
 
@@ -69,5 +71,3 @@
        .size _U(strpbrk), . - _U(strpbrk)
 
 #endif /* !__DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/strrchr.S
===================================================================
--- trunk/avr-libc/libc/string/strrchr.S        2017-06-11 15:41:47 UTC (rev 
2541)
+++ trunk/avr-libc/libc/string/strrchr.S        2017-06-12 22:08:58 UTC (rev 
2542)
@@ -28,8 +28,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "macros.inc"
@@ -57,11 +55,9 @@
 .L_strrchr_noteq:
        tst     __tmp_reg__
        brne    .L_strrchr_loop
-       sbiw    ret_lo, 1       ; undo post-increment
+       X_sbiw  ret_lo, 1       ; undo post-increment
        ret
 .L_strrchr_end:
        .size   _U(strrchr), .L_strrchr_end - _U(strrchr)
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/strrev.S
===================================================================
--- trunk/avr-libc/libc/string/strrev.S 2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/libc/string/strrev.S 2017-06-12 22:08:58 UTC (rev 2542)
@@ -37,8 +37,6 @@
      Created by Reiner Patommel
 */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "macros.inc"
@@ -60,7 +58,7 @@
        ld      ltemp, Z+
        tst     ltemp
        brne    1b
-       sbiw    ZL, 2           ; to last nonzero byte
+       X_sbiw  ZL, 2           ; to last nonzero byte
        rjmp    3f
   ; swap bytes
 2:     ld      ltemp, X
@@ -76,5 +74,3 @@
     .size _U(strrev), . - _U(strrev)
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/strstr.S
===================================================================
--- trunk/avr-libc/libc/string/strstr.S 2017-06-11 15:41:47 UTC (rev 2541)
+++ trunk/avr-libc/libc/string/strstr.S 2017-06-12 22:08:58 UTC (rev 2542)
@@ -37,8 +37,6 @@
      Philip Soeberg <address@hidden>
 */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "macros.inc"
@@ -50,7 +48,7 @@
 
 #define chr1   r20
 #define        beg2   r21      /* begin of s2: s2[0]   */
-#define chr2   r0
+#define chr2   __tmp_reg__
 
 ASSEMBLY_CLIB_SECTION
 .global _U(strstr)
@@ -89,7 +87,7 @@
        ldi     s1_lo, lo8(1)
        ldi     s1_hi, hi8(1)
 .L_match:
-       sbiw    s1_lo, 1        ; restore after post-increment
+       X_sbiw  s1_lo, 1        ; restore after post-increment
 .L_ret:
        ret
 
@@ -96,5 +94,3 @@
 .size _U(strstr), . - _U(strstr)
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */

Modified: trunk/avr-libc/libc/string/strtok_r.S
===================================================================
--- trunk/avr-libc/libc/string/strtok_r.S       2017-06-11 15:41:47 UTC (rev 
2541)
+++ trunk/avr-libc/libc/string/strtok_r.S       2017-06-12 22:08:58 UTC (rev 
2542)
@@ -30,8 +30,6 @@
 
 /* $Id$ */
 
-#if !defined(__AVR_TINY__)
-
 #if !defined(__DOXYGEN__)
 
 #include "asmdef.h"
@@ -87,13 +85,16 @@
 #define dch    r18
 
 ENTRY strtok_r
+#if defined(__AVR_TINY__)
+       push    dch
+#endif /* __AVR_TINY__ */
        X_movw  ZL, lst_lo
        ld      XL, Z+                  ; X = *last
        ld      XH, Z
   ; check str
-       sbiw    str_lo, 0
+       X_sbiw  str_lo, 0
        brne    1f
-       sbiw    XL, 0
+       X_sbiw  XL, 0
        breq    .Lret                   ; end of string
        X_movw  str_lo, XL              ; continue parsing
 
@@ -119,7 +120,11 @@
        cp      dch, __tmp_reg__        ; __tmp_reg__ != 0
        brne    7f
        st      -X, __zero_reg__
+#if !defined(__AVR_TINY__)
        adiw    XL, 1
+#else
+       ld      __tmp_reg__, X+
+#endif /* __AVR_TINY__ */
        rjmp    .Lret
 7:     tst     dch
        brne    6b
@@ -134,10 +139,11 @@
 .Lret: X_movw  ZL, lst_lo              ; *last = X
        st      Z+, XL
        st      Z, XH
+#if defined(__AVR_TINY__)
+       pop     dch
+#endif /* __AVR_TINY__ */
        ret
 
 ENDFUNC
 
 #endif /* not __DOXYGEN__ */
-
-#endif /* !defined(__AVR_TINY__) */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]