qemu/tests/tcg/mips/mips32-dspr2/dpaqx_s_w_ph.c
<<
>>
Prefs
   1#include<stdio.h>
   2#include<assert.h>
   3
   4int main()
   5{
   6    int rs, rt, dsp;
   7    int ach = 5, acl = 5;
   8    int resulth, resultl, resultdsp;
   9
  10    rs     = 0x800000FF;
  11    rt     = 0x00018000;
  12    resulth = 0x05;
  13    resultl = 0x80000202;
  14    resultdsp = 0x01;
  15    __asm
  16        ("mthi  %0, $ac1\n\t"
  17         "mtlo  %1, $ac1\n\t"
  18         "dpaqx_s.w.ph $ac1, %3, %4\n\t"
  19         "mfhi  %0, $ac1\n\t"
  20         "mflo  %1, $ac1\n\t"
  21         "rddsp %2\n\t"
  22         : "+r"(ach), "+r"(acl), "=r"(dsp)
  23         : "r"(rs), "r"(rt)
  24        );
  25    dsp = (dsp >> 17) & 0x01;
  26    assert(dsp == resultdsp);
  27    assert(ach == resulth);
  28    assert(acl == resultl);
  29
  30    ach    = 5;
  31    acl    = 5;
  32    rs     = 0x00FF00FF;
  33    rt     = 0x00010002;
  34    resulth = 0x05;
  35    resultl = 0x05FF;
  36    /***********************************************************
  37     * Because of we set outflag at last time, although this
  38     * time we set nothing, but it is stay the last time value.
  39     **********************************************************/
  40    resultdsp = 0x01;
  41    __asm
  42        ("mthi  %0, $ac1\n\t"
  43         "mtlo  %1, $ac1\n\t"
  44         "dpaqx_s.w.ph $ac1, %3, %4\n\t"
  45         "mfhi  %0, $ac1\n\t"
  46         "mflo  %1, $ac1\n\t"
  47         "rddsp %2\n\t"
  48         : "+r"(ach), "+r"(acl), "=r"(dsp)
  49         : "r"(rs), "r"(rt)
  50        );
  51    dsp = (dsp >> 17) & 0x01;
  52    assert(dsp == resultdsp);
  53    assert(ach == resulth);
  54    assert(acl == resultl);
  55
  56    ach    = 5;
  57    acl    = 5;
  58    rs     = 0x800000FF;
  59    rt     = 0x00028000;
  60    resulth = 0x05;
  61    resultl = 0x80000400;
  62    resultdsp = 0x01;
  63    __asm
  64        ("mthi  %0, $ac1\n\t"
  65         "mtlo  %1, $ac1\n\t"
  66         "dpaqx_s.w.ph $ac1, %3, %4\n\t"
  67         "mfhi  %0, $ac1\n\t"
  68         "mflo  %1, $ac1\n\t"
  69         "rddsp %2\n\t"
  70         : "+r"(ach), "+r"(acl), "=r"(dsp)
  71         : "r"(rs), "r"(rt)
  72        );
  73    dsp = (dsp >> 17) & 0x01;
  74    assert(dsp == resultdsp);
  75    assert(ach == resulth);
  76    assert(acl == resultl);
  77
  78    return 0;
  79}
  80