1 #include <stdio.h> 2 unsigned int mem[] = { 3 0xaabbccdd, 0x11223344, 0x01823194, 0x01823a08, 4 0x00000000, 0x77ff528c, 0x77deb460, 0x00000001 5 }; 6 7 void printMem(char* s) 8 { 9 int i; 10 printf("%s\n", s); 11 for (i=0; i<7 ; i=i+1) 12 printf("mem[%d]: 0x%x\n", i, mem[i]); 13 } 14 15 int main () 16 { 17 printMem("PRE lwl"); 18 __asm__ volatile("move $a0, %0" "\n\t" 19 "lw $t0, 0($a0)" "\n\t" 20 "lwl $t0, 4($a0)" "\n\t" 21 "sw $t0, 8($a0)" "\n\t" 22 "lw $t1, 0($a0)" "\n\t" 23 "lwl $t1, 5($a0)" "\n\t" 24 "sw $t1, 12($a0)" "\n\t" 25 "lw $t2, 0($a0)" "\n\t" 26 "lwl $t2, 6($a0)" "\n\t" 27 "sw $t2, 16($a0)" "\n\t" 28 "lw $t3, 0($a0)" "\n\t" 29 "lwl $t3, 7($a0)" "\n\t" 30 "sw $t3, 20($a0)" "\n\t" 31 : 32 : "r" (mem) 33 : "a0", "t0", "t1", "t2", "t3", "cc", "memory" 34 ); 35 printMem("POST lwl"); 36 37 mem[0] = 0xaabbccdd; 38 mem[1] = 0x11223344; 39 mem[2] = 0x01823194; 40 mem[3] = 0x01823a08; 41 mem[4] = 0x00000000; 42 mem[5] = 0x77ff528c; 43 mem[6] = 0x77deb460; 44 mem[7] = 0x00000001; 45 46 printMem("PRE lwr"); 47 __asm__ volatile("move $a0, %0" "\n\t" 48 "lw $t0, 0($a0)" "\n\t" 49 "lwr $t0, 4($a0)" "\n\t" 50 "sw $t0, 8($a0)" "\n\t" 51 "lw $t1, 0($a0)" "\n\t" 52 "lwr $t1, 5($a0)" "\n\t" 53 "sw $t1, 12($a0)" "\n\t" 54 "lw $t2, 0($a0)" "\n\t" 55 "lwr $t2, 6($a0)" "\n\t" 56 "sw $t2, 16($a0)" "\n\t" 57 "lw $t3, 0($a0)" "\n\t" 58 "lwr $t3, 7($a0)" "\n\t" 59 "sw $t3, 20($a0)" "\n\t" 60 : 61 : "r" (mem) 62 : "a0", "t0", "t1", "t2", "t3", "cc", "memory" 63 ); 64 printMem("POST lwr"); 65 66 return 0; 67 } 68