cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

test_sfgtu.c (652B)


      1#include <stdio.h>
      2int main(void)
      3{
      4    int a, b, c;
      5    int result;
      6
      7    a = 0;
      8    b = 3;
      9    result = 1;
     10    __asm
     11    ("1:\n\t"
     12     "l.addi %0, %0, 1\n\t"
     13     "l.sfgtu %0, %1\n\t"
     14     "l.bf 1b\n\t"
     15     "l.nop\n\t"
     16     : "+r"(a)
     17     : "r"(b)
     18    );
     19    if (a != result) {
     20        printf("sfgtu error\n");
     21        return -1;
     22    }
     23
     24    a = 0xff;
     25    b = 3;
     26    c = 1;
     27    result = 3;
     28    __asm
     29    ("1:\n\t"
     30     "l.sub    %0, %0, %2\n\t"
     31     "l.sfgtu  %0, %1\n\t"
     32     "l.bf 1b\n\t"
     33     "l.nop\n\t"
     34     : "+r"(a)
     35     : "r"(b), "r"(c)
     36    );
     37    if (a != result) {
     38        printf("sfgtu error\n");
     39        return -1;
     40    }
     41
     42    return 0;
     43}