1#include<stdio.h> 2#include<assert.h> 3 4int main() 5{ 6 int rt, rs; 7 int achi, acli; 8 int dsp; 9 int acho, aclo; 10 int resulth, resultl; 11 int resdsp; 12 13 achi = 0x05; 14 acli = 0xB4CB; 15 rs = 0xFF060000; 16 rt = 0xCB000000; 17 resulth = 0x04; 18 resultl = 0x947438CB; 19 20 __asm 21 ("mthi %2, $ac1\n\t" 22 "mtlo %3, $ac1\n\t" 23 "maq_s.w.phl $ac1, %4, %5\n\t" 24 "mfhi %0, $ac1\n\t" 25 "mflo %1, $ac1\n\t" 26 : "=r"(acho), "=r"(aclo) 27 : "r"(achi), "r"(acli), "r"(rs), "r"(rt) 28 ); 29 assert(resulth == acho); 30 assert(resultl == aclo); 31 32 achi = 0x06; 33 acli = 0xB4CB; 34 rs = 0x80000000; 35 rt = 0x80000000; 36 resulth = 0x6; 37 resultl = 0x8000b4ca; 38 resdsp = 1; 39 40 __asm 41 ("mthi %3, $ac1\n\t" 42 "mtlo %4, $ac1\n\t" 43 "maq_s.w.phl $ac1, %5, %6\n\t" 44 "mfhi %0, $ac1\n\t" 45 "mflo %1, $ac1\n\t" 46 "rddsp %2\n\t" 47 : "=r"(acho), "=r"(aclo), "=r"(dsp) 48 : "r"(achi), "r"(acli), "r"(rs), "r"(rt) 49 ); 50 assert(resulth == acho); 51 assert(resultl == aclo); 52 assert(((dsp >> 17) & 0x01) == resdsp); 53 54 return 0; 55} 56