symbian-qemu-0.9.1-12/qemu-symbian-svp/tests/cris/check_addc.c
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     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_addc(int a, const int b) {
       
     8 	asm ("addc\t%1, %0\n" : "+r" (a) : "r" (b));
       
     9 	return a;
       
    10 }
       
    11 
       
    12 #define verify_addc(a, b, res, n, z, v, c)  \
       
    13 {                                           \
       
    14 	int r;                              \
       
    15 	r = cris_addc((a), (b));            \
       
    16 	cris_tst_cc((n), (z), (v), (c));    \
       
    17 	if (r != (res))                     \
       
    18 		err();                      \
       
    19 }
       
    20 
       
    21 int main(void)
       
    22 {
       
    23 	cris_tst_cc_init();
       
    24 	asm volatile ("clearf cz");
       
    25 	verify_addc(0, 0, 0, 0, 0, 0, 0);
       
    26 
       
    27 	cris_tst_cc_init();
       
    28 	asm volatile ("setf z");
       
    29 	verify_addc(0, 0, 0, 0, 1, 0, 0);
       
    30 
       
    31 	cris_tst_cc_init();
       
    32 	asm volatile ("setf cz");
       
    33 	verify_addc(0, 0, 1, 0, 0, 0, 0);
       
    34 	cris_tst_cc_init();
       
    35 	asm volatile ("clearf c");
       
    36 	verify_addc(-1, 2, 1, 0, 0, 0, 1);
       
    37 
       
    38 	cris_tst_cc_init();
       
    39 	asm volatile ("clearf nzv");
       
    40 	asm volatile ("setf c");
       
    41 	verify_addc(-1, 2, 2, 0, 0, 0, 1);
       
    42 
       
    43 	cris_tst_cc_init();
       
    44 	asm volatile ("setf c");
       
    45 	verify_addc(0xffff, 0xffff, 0x1ffff, 0, 0, 0, 0);
       
    46 
       
    47 	cris_tst_cc_init();
       
    48 	asm volatile ("clearf nzvc");
       
    49 	verify_addc(-1, -1, 0xfffffffe, 1, 0, 0, 1);
       
    50 
       
    51 	cris_tst_cc_init();
       
    52 	asm volatile ("setf c");
       
    53 	verify_addc(0x78134452, 0x5432f789, 0xcc463bdc, 1, 0, 1, 0);
       
    54 
       
    55 	pass();
       
    56 	return 0;
       
    57 }