1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 #include <limits.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6
addv(const int a,const int b,const int res,const int carry)7 static void addv(const int a, const int b, const int res, const int carry)
8 {
9 int o = a, c;
10
11 asm volatile("addv %2,%0\n"
12 "movt %1\n"
13 : "+r"(o), "=r"(c) : "r"(b) : );
14
15 if (c != carry || o != res) {
16 printf("ADDV %d, %d = %d/%d [T = %d/%d]\n", a, b, o, res, c, carry);
17 abort();
18 }
19 }
20
main(void)21 int main(void)
22 {
23 addv(INT_MAX, 1, INT_MIN, 1);
24 addv(INT_MAX - 1, 1, INT_MAX, 0);
25
26 return 0;
27 }
28