~ahs3/+junk/cq-qemu

« back to all changes in this revision

Viewing changes to tests/cris/check_addoq.c

  • Committer: Al Stone
  • Date: 2012-02-09 01:17:20 UTC
  • Revision ID: albert.stone@canonical.com-20120209011720-tztl7ik3qayz80p4
first commit to bzr for qemu

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <stdint.h>
 
4
#include "sys.h"
 
5
#include "crisutils.h"
 
6
 
 
7
/* this would be better to do in asm, it's an orgy in GCC inline asm now.  */
 
8
 
 
9
/* ACR will be clobbered.  */
 
10
#define cris_addoq(o, v) \
 
11
        asm volatile ("addoq\t%1, %0, $acr\n" : : "r" (v), "i" (o) : "acr");
 
12
 
 
13
 
 
14
int main(void)
 
15
{
 
16
        int x[3] = {0x55aa77ff, 0xccff2244, 0x88ccee19};
 
17
        int *p, *t = x + 1;
 
18
 
 
19
        cris_tst_cc_init();
 
20
        asm volatile ("setf\tzvnc\n");
 
21
        cris_addoq(0, t);
 
22
        cris_tst_cc(1, 1, 1, 1);
 
23
        asm volatile ("move.d\t$acr, %0\n" : "=r" (p));
 
24
        if (*p != 0xccff2244)
 
25
                err();
 
26
 
 
27
        cris_tst_cc_init();
 
28
        asm volatile ("setf\tzvnc\n");
 
29
        cris_addoq(4, t);
 
30
        cris_tst_cc(0, 0, 0, 0);
 
31
        asm volatile ("move.d\t$acr, %0\n" : "=r" (p));
 
32
        if (*p != 0x88ccee19)
 
33
                err();
 
34
 
 
35
        cris_tst_cc_init();
 
36
        asm volatile ("clearf\tzvnc\n");
 
37
        cris_addoq(-8, t + 1);
 
38
        cris_tst_cc(0, 0, 0, 0);
 
39
        asm volatile ("move.d\t$acr, %0\n" : "=r" (p));
 
40
        if (*p != 0x55aa77ff)
 
41
                err();
 
42
        pass();
 
43
        return 0;
 
44
}