1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 #include <limits.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6
subv(const int a,const int b,const int res,const int carry)7 static void subv(const int a, const int b, const int res, const int carry)
8 {
9 int o = a, c;
10
11 asm volatile("subv %2,%0\n"
12 "movt %1\n"
13 : "+r"(o), "=r"(c) : "r"(b) : );
14
15 if (c != carry || o != res) {
16 printf("SUBV %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 subv(INT_MIN, 1, INT_MAX, 1);
24 subv(INT_MAX, -1, INT_MIN, 1);
25 subv(INT_MAX, 1, INT_MAX - 1, 0);
26 subv(0, 1, -1, 0);
27 subv(-1, -1, 0, 0);
28
29 return 0;
30 }
31