qemu/tests/tcg/mips/mips64-dsp/mthlip.c
<<
>>
Prefs
   1#include "io.h"
   2
   3int main(void)
   4{
   5    long long rs, ach, acl, dsp;
   6    long long result, resulth, resultl;
   7
   8    dsp = 0x07;
   9    ach = 0x05;
  10    acl = 0xB4CB;
  11    rs  = 0x00FFBBAA;
  12    resulth = 0xB4CB;
  13    resultl = 0x00FFBBAA;
  14    result  = 0x27;
  15
  16    __asm
  17        ("wrdsp %0, 0x01\n\t"
  18         "mthi %1, $ac1\n\t"
  19         "mtlo %2, $ac1\n\t"
  20         "mthlip %3, $ac1\n\t"
  21         "mfhi %1, $ac1\n\t"
  22         "mflo %2, $ac1\n\t"
  23         "rddsp %0\n\t"
  24         : "+r"(dsp), "+r"(ach), "+r"(acl)
  25         : "r"(rs)
  26        );
  27    dsp = dsp & 0x3F;
  28    if ((dsp != result) || (ach != resulth) || (acl != resultl)) {
  29        printf("mthlip wrong\n");
  30
  31        return -1;
  32    }
  33
  34    dsp = 0x3f;
  35    ach = 0x05;
  36    acl = 0xB4CB;
  37    rs  = 0x00FFBBAA;
  38    resulth = 0xB4CB;
  39    resultl = 0x00FFBBAA;
  40    result  = 0x3f;
  41
  42    __asm
  43        ("wrdsp %0, 0x01\n\t"
  44         "mthi %1, $ac1\n\t"
  45         "mtlo %2, $ac1\n\t"
  46         "mthlip %3, $ac1\n\t"
  47         "mfhi %1, $ac1\n\t"
  48         "mflo %2, $ac1\n\t"
  49         "rddsp %0\n\t"
  50         : "+r"(dsp), "+r"(ach), "+r"(acl)
  51         : "r"(rs)
  52        );
  53    dsp = dsp & 0x3F;
  54    if ((dsp != result) || (ach != resulth) || (acl != resultl)) {
  55        printf("mthlip wrong\n");
  56
  57        return -1;
  58    }
  59
  60    return 0;
  61}
  62