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