1 #include <stdio.h> 2 3 int main(void) 4 { 5 int a, b, c; 6 int result; 7 8 b = 0x120; 9 c = 0x4; 10 result = 0x48; 11 __asm 12 ("l.div %0, %1, %2\n\t" 13 : "=r"(a) 14 : "r"(b), "r"(c) 15 ); 16 if (a != result) { 17 printf("div error\n"); 18 return -1; 19 } 20 21 result = 0x4; 22 __asm 23 ("l.div %0, %1, %0\n\t" 24 : "+r"(a) 25 : "r"(b) 26 ); 27 if (a != result) { 28 printf("div error\n"); 29 return -1; 30 } 31 32 b = 0xffffffff; 33 c = 0x80000000; 34 result = 0; 35 __asm 36 ("l.div %0, %1, %2\n\t" 37 : "=r"(a) 38 : "r"(b), "r"(c) 39 ); 40 if (a != result) { 41 printf("div error\n"); 42 return -1; 43 } 44 45 b = 0x80000000; 46 c = 0xffffffff; 47 __asm 48 ("l.div %0, %1, %2\n\t" 49 : "=r"(a) 50 : "r"(b), "r"(c) 51 ); 52 53 return 0; 54 } 55