qemu/tests/tcg/mips/mips64-dsp/dextr_s_h.c
<<
>>
Prefs
   1#include "io.h"
   2
   3int main(void)
   4{
   5    long long rt, dsp;
   6    long long achi, acli;
   7    long long res, resdsp;
   8
   9    achi = 0x87654321;
  10    acli = 0x12345678;
  11
  12    res = 0xffffffffffff8000;
  13    resdsp = 0x1;
  14
  15    __asm
  16        ("mthi %2, $ac1\n\t"
  17         "mtlo %3, $ac1\n\t"
  18         "dextr_s.h %0, $ac1, 0x8\n\t"
  19         "rddsp %1\n\t"
  20         : "=r"(rt), "=r"(dsp)
  21         : "r"(achi), "r"(acli)
  22        );
  23    dsp = (dsp >> 23) & 0x1;
  24
  25    if ((dsp != resdsp) || (rt != res)) {
  26        printf("1 dextr_s.h error\n");
  27        return -1;
  28    }
  29
  30    achi = 0x77654321;
  31    acli = 0x12345678;
  32
  33    res = 0x7fff;
  34    resdsp = 0x1;
  35
  36    __asm
  37        ("mthi %2, $ac1\n\t"
  38         "mtlo %3, $ac1\n\t"
  39         "dextr_s.h %0, $ac1, 0x8\n\t"
  40         "rddsp %1\n\t"
  41         : "=r"(rt), "=r"(dsp)
  42         : "r"(achi), "r"(acli)
  43        );
  44    dsp = (dsp >> 23) & 0x1;
  45
  46    if ((dsp != resdsp) || (rt != res)) {
  47        printf("2 dextr_s.h error\n");
  48        return -1;
  49    }
  50
  51    achi = 0x00;
  52    acli = 0x78;
  53
  54    res = 0x7;
  55    resdsp = 0x1;
  56
  57    __asm
  58        ("mthi %2, $ac1\n\t"
  59         "mtlo %3, $ac1\n\t"
  60         "dextr_s.h %0, $ac1, 0x4\n\t"
  61         "rddsp %1\n\t"
  62         : "=r"(rt), "=r"(dsp)
  63         : "r"(achi), "r"(acli)
  64        );
  65    dsp = (dsp >> 23) & 0x1;
  66
  67    if ((dsp != resdsp) || (rt != res)) {
  68        printf("3 dextr_s.h error\n");
  69        return -1;
  70    }
  71
  72    return 0;
  73}
  74