qemu/tests/tcg/mips/mips64-dsp/extr_s_h.c
<<
>>
Prefs
   1#include "io.h"
   2
   3int main(void)
   4{
   5    long long rt, ach, acl, dsp;
   6    long long result;
   7
   8    ach = 0x05;
   9    acl = 0xB4CB;
  10    result = 0x00007FFF;
  11    __asm
  12        ("mthi %2, $ac1\n\t"
  13         "mtlo %3, $ac1\n\t"
  14         "extr_s.h %0, $ac1, 0x03\n\t"
  15         "rddsp %1\n\t"
  16         : "=r"(rt), "=r"(dsp)
  17         : "r"(ach), "r"(acl)
  18        );
  19    dsp = (dsp >> 23) & 0x01;
  20    if ((dsp != 1) || (result != rt)) {
  21        printf("extr_s.h wrong\n");
  22
  23        return -1;
  24    }
  25
  26    ach = 0xffffffff;
  27    acl = 0x12344321;
  28    result = 0xffffffffFFFF8000;
  29    __asm
  30        ("mthi %2, $ac1\n\t"
  31         "mtlo %3, $ac1\n\t"
  32         "extr_s.h %0, $ac1, 0x08\n\t"
  33         "rddsp %1\n\t"
  34         : "=r"(rt), "=r"(dsp)
  35         : "r"(ach), "r"(acl)
  36        );
  37    dsp = (dsp >> 23) & 0x01;
  38    if ((dsp != 1) || (result != rt)) {
  39        printf("extr_s.h wrong\n");
  40
  41        return -1;
  42    }
  43
  44    /* Clear dsp */
  45    dsp = 0;
  46    __asm
  47        ("wrdsp %0\n\t"
  48         :
  49         : "r"(dsp)
  50        );
  51
  52    ach = 0x00;
  53    acl = 0x4321;
  54    result = 0x432;
  55    __asm
  56        ("mthi %2, $ac1\n\t"
  57         "mtlo %3, $ac1\n\t"
  58         "extr_s.h %0, $ac1, 0x04\n\t"
  59         "rddsp %1\n\t"
  60         : "=r"(rt), "=r"(dsp)
  61         : "r"(ach), "r"(acl)
  62        );
  63    dsp = (dsp >> 23) & 0x01;
  64    if ((dsp != 0) || (result != rt)) {
  65        printf("extr_s.h wrong\n");
  66
  67        return -1;
  68    }
  69
  70    return 0;
  71}
  72