AVR-gcc patch: reverse order of 16-bit writes

Joerg Wunsch j@ida.interface-business.de
Sun Sep 15 07:34:00 GMT 2002


On the AVR, some IO registers need a specific write order since the
CPU core maintains a `temp' register to guarantee a atomic write
operation to the entire 16-bit register using two 8-bit operations.
When using the memory-mapped IO space (which is now often the
default in AVR-gcc), this currently doesn't work for accessing
16-bit IO registers that have been passed as an `uint16_t *'
pointer down to a function.

While only a few registers actually need this procedure, discussion
in the avr-gcc mailing list has yielded that it's probably a good
idea to generally maintain the write order `high byte first, low
byte second', since for all other 16-bit write operations, it simply
doesn't matter.  The suggested patch fixes this problem (at least
for the situation that some developer was reporting).

-- 
J"org Wunsch					       Unix support engineer
joerg_wunsch@interface-systems.de        http://www.interface-systems.de/~j/
-------------- next part --------------
--- gcc/config/avr/avr.c.orig	Mon Aug 12 15:13:56 2002
+++ gcc/config/avr/avr.c	Thu Aug 29 12:53:14 2002
@@ -2711,8 +2711,8 @@
             }
         }
       else
-        return  *l=2, (AS2 (st ,%0,%A1)    CR_TAB
-                       AS2 (std,%0+1,%B1));
+        return  *l=2, (AS2 (std,%0+1,%B1)  CR_TAB
+                       AS2 (st ,%0,%A1));
     }
   else if (GET_CODE (base) == PLUS)
     {


More information about the Gcc-patches mailing list