qemu/tests/tcg/mips/mips64-dsp/dmadd.c
<<
>>
Prefs
   1#include "io.h"
   2
   3int main(void)
   4{
   5    long long rt, rs;
   6    long long achi, acli;
   7    long long acho, aclo;
   8    long long resh, resl;
   9
  10    achi = 0x1;
  11    acli = 0x1;
  12
  13    rs = 0x0000000100000001;
  14    rt = 0x0000000200000002;
  15
  16    resh = 0x1;
  17    resl = 0x5;
  18    __asm
  19       ("mthi %2, $ac1 \t\n"
  20        "mtlo %3, $ac1 \t\n"
  21        "dmadd $ac1, %4, %5\t\n"
  22        "mfhi %0, $ac1 \t\n"
  23        "mflo %1, $ac1 \t\n"
  24        : "=r"(acho), "=r"(aclo)
  25        : "r"(achi), "r"(acli), "r"(rs), "r"(rt)
  26      );
  27    if ((acho != resh) || (aclo != resl)) {
  28        printf("1 dmadd error\n");
  29
  30        return -1;
  31    }
  32
  33    achi = 0x1;
  34    acli = 0x1;
  35
  36    rs = 0xaaaabbbbccccdddd;
  37    rt = 0xaaaabbbbccccdddd;
  38
  39    resh = 0x0000000000000000;
  40    resl = 0xffffffffca860b63;
  41
  42    __asm
  43       ("mthi %2, $ac1 \t\n"
  44        "mtlo %3, $ac1 \t\n"
  45        "dmadd $ac1, %4, %5\t\n"
  46        "mfhi %0, $ac1 \t\n"
  47        "mflo %1, $ac1 \t\n"
  48        : "=r"(acho), "=r"(aclo)
  49        : "r"(achi), "r"(acli), "r"(rs), "r"(rt)
  50      );
  51    if ((acho != resh) || (aclo != resl)) {
  52        printf("2 dmadd error\n");
  53
  54        return -1;
  55    }
  56    return 0;
  57}
  58