1#include <stdio.h> 2 3int main(void) 4{ 5 int a; 6 int p[50]; 7 int result; 8 9 result = 0x23; 10 __asm 11 ("l.ori r8, r0, 0x123\n\t" 12 "l.sb 0x4 + %1, r8\n\t" 13 "\n\t" 14 "l.lbz %0, 0x4 + %1\n\t" 15 : "=r"(a), "+m"(*p) 16 ); 17 if (a != result) { 18 printf("lbz error, %x\n", a); 19 return -1; 20 } 21 22 result = 0x23; 23 __asm 24 ("l.lbs %0, 0x4 + %1\n\t" 25 : "=r"(a) 26 : "m"(*p) 27 ); 28 if (a != result) { 29 printf("lbs error\n"); 30 return -1; 31 } 32 33 result = 0x1111; 34 __asm 35 ("l.ori r8, r0, 0x1111\n\t" 36 "l.sh 0x20 + %1, r8\n\t" 37 "\n\t" 38 "l.lhs %0, 0x20 + %1\n\t" 39 : "=r"(a), "=m"(*p) 40 ); 41 if (a != result) { 42 printf("lhs error, %x\n", a); 43 return -1; 44 } 45 46 result = 0x1111; 47 __asm 48 ("l.lhz %0, 0x20 + %1\n\t" 49 : "=r"(a) 50 : "m"(*p) 51 ); 52 if (a != result) { 53 printf("lhz error\n"); 54 return -1; 55 } 56 57 result = 0x1111233; 58 __asm 59 ("l.ori r8, r0, 0x1233\n\t" 60 "l.movhi r1, 0x111\n\t" 61 "l.or r8, r8, r1\n\t" 62 "l.sw 0x123 + %1, r8\n\t" 63 "\n\t" 64 "l.lws %0, 0x123 + %1\n\t" 65 : "=r"(a), "+m"(*p) 66 ); 67 if (a != result) { 68 printf("lws error, %x\n", a); 69 return -1; 70 } 71 72 result = 0x1111233; 73 __asm 74 ("l.lwz %0, 0x123 + %1\n\t" 75 : "=r"(a) 76 : "m"(*p) 77 ); 78 if (a != result) { 79 printf("lwz error\n"); 80 return -1; 81 } 82 83 return 0; 84} 85