Statistics
| Branch: | Revision:

root / tests / cris / check_abs.c @ 076d2471

History | View | Annotate | Download (794 Bytes)

1 dd43edf4 ths
#include <stdio.h>
2 dd43edf4 ths
#include <stdlib.h>
3 dd43edf4 ths
#include <stdint.h>
4 dd43edf4 ths
#include "sys.h"
5 dd43edf4 ths
#include "crisutils.h"
6 dd43edf4 ths
7 dd43edf4 ths
extern inline int cris_abs(int n) {
8 dd43edf4 ths
        int r;
9 dd43edf4 ths
        asm ("abs\t%1, %0\n" : "=r" (r) : "r" (n));
10 dd43edf4 ths
        return r;
11 dd43edf4 ths
}
12 dd43edf4 ths
13 dd43edf4 ths
extern inline void
14 dd43edf4 ths
verify_abs(int val, int res,
15 dd43edf4 ths
           const int n, const int z, const int v, const int c)
16 dd43edf4 ths
{
17 dd43edf4 ths
        int r;
18 dd43edf4 ths
19 dd43edf4 ths
        cris_tst_cc_init();
20 dd43edf4 ths
        r = cris_abs(val);
21 dd43edf4 ths
        cris_tst_cc(n, z, v, c);
22 dd43edf4 ths
        if (r != res)
23 dd43edf4 ths
                err();
24 dd43edf4 ths
}
25 dd43edf4 ths
26 dd43edf4 ths
int main(void)
27 dd43edf4 ths
{
28 dd43edf4 ths
        verify_abs(-1, 1, 0, 0, 0, 0);
29 dd43edf4 ths
        verify_abs(0x80000000, 0x80000000, 1, 0, 0, 0);
30 dd43edf4 ths
        verify_abs(0x7fffffff, 0x7fffffff, 0, 0, 0, 0);
31 dd43edf4 ths
        verify_abs(42, 42, 0, 0, 0, 0);
32 dd43edf4 ths
        verify_abs(1, 1, 0, 0, 0, 0);
33 dd43edf4 ths
        verify_abs(0xffff, 0xffff, 0, 0, 0, 0);
34 dd43edf4 ths
        verify_abs(0xffff, 0xffff, 0, 0, 0, 0);
35 dd43edf4 ths
        verify_abs(-31, 0x1f, 0, 0, 0, 0);
36 dd43edf4 ths
        verify_abs(0, 0, 0, 1, 0, 0);
37 dd43edf4 ths
        pass();
38 dd43edf4 ths
        return 0;
39 dd43edf4 ths
}