qemu/tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c
<<
>>
Prefs
   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  = 0xFF06;
  16    rt  = 0xCB00;
  17    resulth = 0x00;
  18    resultl = 0x7FFFFFFF;
  19
  20    __asm
  21        ("mthi %2, $ac1\n\t"
  22         "mtlo %3, $ac1\n\t"
  23         "maq_sa.w.phr $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  = 0x8000;
  35    rt  = 0x8000;
  36    resulth = 0x00;
  37    resultl = 0x7fffffff;
  38    resdsp = 0x01;
  39
  40    __asm
  41        ("mthi %3, $ac1\n\t"
  42         "mtlo %4, $ac1\n\t"
  43         "maq_sa.w.phr $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) == 0x01);
  53
  54    return 0;
  55}
  56