qemu/tests/tcg/openrisc/test_lf_nes.c
<<
>>
Prefs
   1#include <stdio.h>
   2
   3int main(void)
   4{
   5    int a;
   6    float b, c;
   7    int result;
   8
   9    a = 0;
  10    b = 23.1;
  11    c = 23.1;
  12    result = 0x1;
  13    __asm
  14    ("lfnes:\n\t"
  15     "l.addi    %0, %0, 0x1\n\t"
  16     "lf.sfne.s %1, %2\n\t"
  17     "l.bf      lfnes\n\t"
  18     "l.nop\n\t"
  19     : "+r"(a)
  20     : "r"(b), "r"(c)
  21    );
  22    if (a != result) {
  23        printf("lf.sfne.s error");
  24        return -1;
  25    }
  26
  27    b = 12.4;
  28    c = 7.8;
  29    result = 0x3;
  30    __asm
  31    ("l.addi    %0, %0, 0x1\n\t"
  32     "l.addi    %0, %0, 0x1\n\t"
  33     "lf.sfne.s %1, %2\n\t"
  34     "l.bf      1f\n\t"
  35     "l.nop\n\t"
  36     "l.addi    %0, %0, 0x1\n\t"
  37     "l.addi    %0, %0, 0x1\n\t"
  38     "1:\n\t"
  39     : "+r"(a)
  40     : "r"(b), "r"(c)
  41    );
  42    if (a != result) {
  43        printf("lf.sfne.s error\n");
  44        return -1;
  45    }
  46/*    int a;
  47    double b, c;
  48    int result;
  49
  50    a = 0;
  51    b = 124.3;
  52    c = 124.3;
  53    result = 0x1;
  54    __asm
  55    ("lfned:\n\t"
  56     "l.addi    %0, %0, 0x1\n\t"
  57     "lf.sfne.d %1, %2\n\t"
  58     "l.bf      lfned\n\t"
  59     "l.nop\n\t"
  60     : "+r"(a)
  61     : "r"(b), "r"(c)
  62    );
  63    if (a != result) {
  64        printf("lf.sfne.d error\n");
  65        return -1;
  66    }
  67
  68    b = 11.5;
  69    c = 16.7;
  70    result = 0x3;
  71    __asm
  72    ("l.addi    %0, %0, 0x1\n\t"
  73     "l.addi    %0, %0, 0x1\n\t"
  74     "lf.sfne.d %1, %2\n\t"
  75     "l.bf      1f\n\t"
  76     "l.nop\n\t"
  77     "l.addi    r4, r4, 0x1\n\t"
  78     "l.addi    r4, r4, 0x1\n\t"
  79     "1:\n\t"
  80     : "+r"(a)
  81     : "r"(b), "r"(c)
  82    );
  83    if (a != result) {
  84        printf("lf.sfne.d error\n");
  85        return -1;
  86    }*/
  87
  88    return 0;
  89}
  90