Merge pull request #542 from gameblabla/mdec_fix
[pcsx_rearmed.git] / deps / lightning / check / allocai.tst
1 .data   128
2 idfmt:
3 .c      "received %d\n"
4 failure_message:
5 .c      "numbers don't add up to zero\n"
6 report_message:
7 .c      "failed: got %i instead of %i\n"
8 succeeded_message:
9 .c      "succeeded\n"
10
11 .code
12         jmpi main
13
14 /*
15 static int
16 identity (int arg)
17 {
18   printf ("received %i\n", arg);
19   return arg;
20 }
21  */
22         name identify
23 identify:
24         prolog
25         arg $i
26         getarg %v0 $i
27         prepare
28                 pushargi idfmt
29                 ellipsis
30                 pushargr %v0
31         finishi @printf
32         retr %v0
33         epilog
34
35         name identity_func
36 identity_func:
37         prolog
38         arg $i
39         getarg %r1 $i
40
41         /* Store the argument on the stack.  */
42         allocai $(__WORDSIZE >> 3) $off
43         stxi $off %fp %r1
44
45         /* Store the negative of the argument on the stack.  */
46         allocai $(__WORDSIZE >> 3) $neg
47         negr %r2 %r1
48         stxi $neg %fp %r2
49
50         /* Invoke FUNC.  */
51         prepare
52                 pushargr %r1
53         finishi identify
54
55         /* Ignore the result.  */
56
57         /* Restore the negative and the argument from the stack.  */
58         ldxi %r2 %fp $neg
59         ldxi %v1 %fp $off
60
61         /* Make sure they still add to zero.  */
62         addr %r0 %v1 %r2
63         bnei branch %r0 0
64
65         /* Return it.  */
66         retr %v1
67
68         /* Display a failure message.  */
69 branch:
70         prepare
71                 pushargi failure_message
72                 ellipsis
73         finishi @printf
74
75         /* Leave.  */
76         retr %v1
77         epilog
78
79         name main
80 main:
81         prolog
82         prepare
83                 pushargi 7777
84         finishi identity_func
85         retval %r0
86         beqi succeeded %r0 7777
87         prepare
88                 pushargi report_message
89                 ellipsis
90                 pushargr %r0
91                 pushargi 7777
92         finishi @printf
93         reti 1
94 succeeded:
95         prepare
96                 pushargi succeeded_message
97                 ellipsis
98         finishi @printf
99         reti 0
100         epilog