Index: trunk/hal/tsar_mips32/hal_remote.c
===================================================================
--- trunk/hal/tsar_mips32/hal_remote.c	(revision 1)
+++ trunk/hal/tsar_mips32/hal_remote.c	(revision 8)
@@ -32,12 +32,13 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT */   
-                  "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy */   
-                  "sb     %0,     0(%1)        \n"  /* *paddr <= value  */
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15 */   
-                  "sync                        \n"
-                  :
-                  : "r" (data), "r" (ptr), "r" (cxy)
-                  : "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT */   
+        "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy */   
+        "sb     %0,     0(%1)        \n"  /* *paddr <= value  */
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15 */   
+        "sync                        \n"
+        ".set reorder                \n"
+        : : "r" (data), "r" (ptr), "r" (cxy) : "$15" );
 }
 
@@ -50,11 +51,11 @@
 
     asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT */   
-                  "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy */   
-                  "sw     %0,     0(%1)        \n"  /* *paddr <= value  */
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15 */   
-                  "sync                        \n"
-                  :
-                  : "r" (data), "r" (ptr), "r" (cxy)
-                  : "$15" );
+        ".set noreorder              \n"
+        "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy */   
+        "sw     %0,     0(%1)        \n"  /* *paddr <= value  */
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15 */   
+        "sync                        \n"
+        ".set reorder                \n"
+        : : "r" (data), "r" (ptr), "r" (cxy) : "$15" );
 }
 
@@ -69,13 +70,14 @@
     uint32_t data_msb = (uint32_t)(data>>32);
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT  */   
-                  "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy  */   
-                  "sw     %0,     0(%2)        \n"  /* *paddr <= lsb     */
-                  "sw     %1,     4(%2)        \n"  /* *(paddr+4) <= msb */
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15  */   
-                  "sync                        \n"
-                  :
-                  : "r" (data_lsb), "r" (data_msb), "r" (ptr), "r" (cxy)
-                  : "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT  */   
+        "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy  */   
+        "sw     %0,     0(%2)        \n"  /* *paddr <= lsb     */
+        "sw     %1,     4(%2)        \n"  /* *(paddr+4) <= msb */
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15  */   
+        "sync                        \n"
+        ".set reorder                \n"
+        : : "r" (data_lsb), "r" (data_msb), "r" (ptr), "r" (cxy) : "$15" );
 }
 
@@ -94,11 +96,12 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT   */ 
-                  "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy   */   
-                  "lb     %0,     0(%1)        \n"  /* data <= *paddr     */
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15   */   
-                  : "=r" (data)
-                  : "r" (ptr), "r" (cxy)
-                  : "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT   */ 
+        "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy   */   
+        "lb     %0,     0(%1)        \n"  /* data <= *paddr     */
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15   */   
+        ".set reorder                \n"
+        : "=r" (data) : "r" (ptr), "r" (cxy) : "$15" );
 
 	return ( data );
@@ -112,11 +115,12 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT   */ 
-                  "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy   */   
-                  "lw     %0,     0(%1)        \n"  /* data <= *paddr     */
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15   */   
-                  : "=r" (data)
-                  : "r" (ptr), "r" (cxy)
-                  : "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT   */ 
+        "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy   */   
+        "lw     %0,     0(%1)        \n"  /* data <= *paddr     */
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15   */   
+        ".set reorder                \n"
+        : "=r" (data) : "r" (ptr), "r" (cxy) : "$15" );
 
     return ( data );
@@ -131,12 +135,13 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
-                  "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy     */   
-                  "lw     %0,     0(%2)        \n"  /* data_lsb <= *paddr   */
-                  "lw     %1,     4(%2)        \n"  /* data_msb <= *paddr+4 */
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
-                  : "=r" (data_lsb), "=r"(data_msb)
-                  : "r" (ptr), "r" (cxy)
-                  : "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
+        "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy     */   
+        "lw     %0,     0(%2)        \n"  /* data_lsb <= *paddr   */
+        "lw     %1,     4(%2)        \n"  /* data_msb <= *paddr+4 */
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
+        ".set reorder                \n"
+        : "=r" (data_lsb), "=r"(data_msb) : "r" (ptr), "r" (cxy) : "$15" );
 
     return ( (((uint64_t)data_msb)<<32) + (((uint64_t)data_lsb)) );
@@ -157,11 +162,12 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT   */ 
-                  "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy   */   
-                  "ll     %0,     0(%1)        \n"  /* data <= *paddr     */
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15   */   
-                  : "=r" (data)
-                  : "r" (ptr), "r" (cxy)
-                  : "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT   */ 
+        "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy   */   
+        "ll     %0,     0(%1)        \n"  /* data <= *paddr     */
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15   */   
+        ".set reorder                \n"
+        : "=r" (data) : "r" (ptr), "r" (cxy) : "$15" );
 
 	return ( data );
@@ -177,19 +183,21 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT   */ 
-                  "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy   */   
-                  "or     $8,     $0,    %3    \n"  /* $8 <= new          */
-                  "ll     $3,    0(%1)         \n"  /* $3 <= *paddr       */
-                  "bne    $3,     %2,    1f    \n"  /* if (new != old)    */
-                  "li     $7,     0            \n"  /* $7 <= 0            */
-                  "sc     $8,     (%1)         \n"  /* *paddr <= new      */
-                  "or     $7,     $8,    $0    \n"  /* $7 <= new          */
-                  "sync                        \n"
-                  "1:                          \n"
-                  "or     %0,     $7,    $0    \n"  /* isAtomic <= $7     */
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15   */   
-                  : "=&r" (isAtomic)
-                  : "r" (ptr), "r" (old) , "r" (new), "r" (cxy) 
-		          : "$3", "$7", "$8", "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT   */ 
+        "mtc2   %4,     $24          \n"  /* PADDR_EXT <= cxy   */   
+        "or     $8,     $0,    %3    \n"  /* $8 <= new          */
+        "ll     $3,    0(%1)         \n"  /* $3 <= *paddr       */
+        "bne    $3,     %2,    1f    \n"  /* if ($3 != old)     */
+        "li     $7,     0            \n"  /* $7 <= 0            */
+        "sc     $8,     (%1)         \n"  /* *paddr <= new      */
+        "or     $7,     $8,    $0    \n"  /* $7 <= atomic       */
+        "sync                        \n"
+        "1:                          \n"
+        "or     %0,     $7,    $0    \n"  /* isAtomic <= $7     */
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15   */   
+        ".set reorder                \n"
+        : "=&r" (isAtomic) : "r" (ptr), "r" (old) , "r" (new), "r" (cxy) 
+		: "$3", "$7", "$8", "$15" );
 
 	return isAtomic;
@@ -204,16 +212,17 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
-                  "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy     */   
-                  "1:                          \n"
-                  "ll     %0,     (%1)         \n"  /* current <= *paddr    */
-                  "addu   $3,     %0,     %2   \n"  /* $3 <= current + incr */
-                  "sc     $3,     (%1)         \n"  /* *paddr <= $3         */
-                  "beq    $3,     $0,     1b   \n"  /* retry if failure     */
-                  "nop                         \n"
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
-		          : "=&r" (current)
-		          : "r" (ptr), "r" (incr), "r" (cxy)
-		          : "$3", "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
+        "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy     */   
+        "1:                          \n"
+        "ll     %0,     (%1)         \n"  /* current <= *paddr    */
+        "addu   $3,     %0,     %2   \n"  /* $3 <= current + incr */
+        "sc     $3,     (%1)         \n"  /* *paddr <= $3         */
+        "beq    $3,     $0,     1b   \n"  /* retry if failure     */
+        "nop                         \n"
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
+        ".set reorder                \n"
+		: "=&r" (current) : "r" (ptr), "r" (incr), "r" (cxy) : "$3", "$15" );
 
 	return current;
@@ -228,16 +237,17 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
-                  "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy     */   
-                  "1:                          \n"
-                  "ll     %0,     (%1)         \n"  /* current <= *paddr    */
-                  "and    $3,     %0,     %2   \n"  /* $3 <= current & mask */
-                  "sc     $3,     (%1)         \n"  /* *paddr <= $3         */
-                  "beq    $3,     $0,     1b   \n"  /* retry if failure     */
-                  "nop                         \n"
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
-		          : "=&r" (current)
-		          : "r" (ptr), "r" (mask), "r" (cxy)
-		          : "$3", "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
+        "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy     */   
+        "1:                          \n"
+        "ll     %0,     (%1)         \n"  /* current <= *paddr    */
+        "and    $3,     %0,     %2   \n"  /* $3 <= current & mask */
+        "sc     $3,     (%1)         \n"  /* *paddr <= $3         */
+        "beq    $3,     $0,     1b   \n"  /* retry if failure     */
+        "nop                         \n"
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
+        ".set reorder                \n"
+	    : "=&r" (current) : "r" (ptr), "r" (mask), "r" (cxy) : "$3", "$15" );
 
 	return current;
@@ -252,16 +262,17 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
-                  "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy     */   
-                  "1:                          \n"
-                  "ll     %0,     (%1)         \n"  /* current <= *paddr    */
-                  "or     $3,     %0,     %2   \n"  /* $3 <= current | mask */
-                  "sc     $3,     (%1)         \n"  /* *paddr <= $3         */
-                  "beq    $3,     $0,     1b   \n"  /* retry if failure     */
-                  "nop                         \n"
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
-		          : "=&r" (current)
-		          : "r" (ptr), "r" (mask), "r" (cxy)
-		          : "$3", "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
+        "mtc2   %3,     $24          \n"  /* PADDR_EXT <= cxy     */   
+        "1:                          \n"
+        "ll     %0,     (%1)         \n"  /* current <= *paddr    */
+        "or     $3,     %0,     %2   \n"  /* $3 <= current | mask */
+        "sc     $3,     (%1)         \n"  /* *paddr <= $3         */
+        "beq    $3,     $0,     1b   \n"  /* retry if failure     */
+        "nop                         \n"
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
+        ".set reorder                \n"
+	    : "=&r" (current) : "r" (ptr), "r" (mask), "r" (cxy) : "$3", "$15" );
 
 	return current;
@@ -278,17 +289,18 @@
     uint32_t cxy = (uint32_t)GET_CXY( xp );
 
-    asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
-                  "mtc2   %4,     $24          \n"  /* PADDR_EXT <= cxy     */   
-                  "ll     %0,     (%2)         \n"  /* current <= *paddr    */
-                  "addu   $3,     %0,     %3   \n"  /* $3 <= current + incr */
-                  "sc     $3,     (%2)         \n"  /* *paddr <= $3         */
-                  "beq    $3,     $0,     1f   \n"  /* exit if failure      */
-                  "ori    %1,     $0,      1   \n"	/* fail: ret <= 1       */
-                  "and    %1,     $0,     $0   \n"	/* success: ret <= 0    */
-                  "1:                          \n"
-                  "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
-		          : "=&r" (current), "=&r" (error)
-		          : "r" (ptr), "r" (incr), "r" (cxy)
-                  : "$3", "$15" );
+    asm volatile( 
+        ".set noreorder              \n"
+        "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
+        "mtc2   %4,     $24          \n"  /* PADDR_EXT <= cxy     */   
+        "ll     %0,     (%2)         \n"  /* current <= *paddr    */
+        "addu   $3,     %0,     %3   \n"  /* $3 <= current + incr */
+        "sc     $3,     (%2)         \n"  /* *paddr <= $3         */
+        "beq    $3,     $0,     1f   \n"  /* exit if failure      */
+        "ori    %1,     $0,      1   \n"	/* fail: ret <= 1       */
+        "and    %1,     $0,     $0   \n"	/* success: ret <= 0    */
+        "1:                          \n"
+        "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
+        ".set reorder                \n"
+		: "=&r" (current), "=&r" (error) : "r" (ptr), "r" (incr), "r" (cxy) : "$3", "$15" );
 		
     *old = current;
@@ -314,26 +326,28 @@
 	for( i = 0 ; i < wsize ; i++ )          // transfer one word per iteration
 	{
-        asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
-                      "mtc2   %0,     $24          \n"  /* PADDR_EXT <= scxy    */   
-		              "lw 	  $3,     0(%1)		   \n"	/* $3 <= *src           */				
-                      "mtc2   %2,     $24          \n"  /* PADDR_EXT <= dcxy    */	
-                      "sw     $3,     0(%3)        \n"  /* *dst <= $3           */
-                      "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
-		              :
-                      : "r"(scxy), "r" (sptr+(i<<2)), "r"(dcxy), "r" (dptr+(i<<2))
-		              : "$3", "$15" );		
+        asm volatile( 
+            ".set noreorder              \n"
+            "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
+            "mtc2   %0,     $24          \n"  /* PADDR_EXT <= scxy    */   
+		    "lw     $3,     0(%1)	     \n"  /* $3 <= *src           */				
+            "mtc2   %2,     $24          \n"  /* PADDR_EXT <= dcxy    */	
+            "sw     $3,     0(%3)        \n"  /* *dst <= $3           */
+            "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
+            ".set reorder                \n"
+		    : : "r"(scxy), "r" (sptr+(i<<2)), "r"(dcxy), "r" (dptr+(i<<2)) : "$3", "$15" );		
 	}
 
 	for( i = wsize << 2 ; i < size ; i++ )  // transfer one byte per iteration
 	{
-        asm volatile( "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
-                      "mtc2   %0,     $24          \n"  /* PADDR_EXT <= scxy    */   
-		              "lb 	  $3,     0(%1)		   \n"	/* $3 <= *src           */				
-                      "mtc2   %2,     $24          \n"  /* PADDR_EXT <= dcxy    */	
-                      "sb     $3,     0(%3)        \n"  /* *dst <= $3           */
-                      "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
-		              :
-                      : "r"(scxy), "r" (sptr+i), "r"(dcxy), "r" (dptr+i)
-		              : "$3", "$15" );		
+        asm volatile( 
+            ".set noreorder              \n"
+            "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT     */ 
+            "mtc2   %0,     $24          \n"  /* PADDR_EXT <= scxy    */   
+		    "lb 	$3,     0(%1)	     \n"  /* $3 <= *src           */				
+            "mtc2   %2,     $24          \n"  /* PADDR_EXT <= dcxy    */	
+            "sb     $3,     0(%3)        \n"  /* *dst <= $3           */
+            "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15     */   
+            ".set reorder                \n"
+		    : : "r"(scxy), "r" (sptr+i), "r"(dcxy), "r" (dptr+i) : "$3", "$15" );		
 	}
 }
