added :-)
[fw/sdcc] / support / regression / tests / libmullong.c
1 /* Test _mullong.c from library
2
3     type: asm, c
4  */
5 #include <testfwk.h>
6
7 #if defined(PORT_HOST)
8 #  define _mullong(a,b) (a*b)
9 #else
10 #  define type_{type}
11 #  if defined(type_c)
12 #    define _SDCC_NO_ASM_LIB_FUNCS 1
13 #  endif
14 #  include "../../../../../device/lib/_mullong.c"
15 #endif
16
17 void
18 testlibmullong(void)
19 {
20   ASSERT(_mullong (         0,          0) ==          0);
21   ASSERT(_mullong (     0x100,      0x100) ==    0x10000);
22   ASSERT(_mullong (0x01020304,          3) == 0x0306090c);
23   ASSERT(_mullong (         3, 0x01020304) == 0x0306090c);
24   ASSERT(_mullong (0x000000ff,          2) == 0x000001fe);
25   ASSERT(_mullong (         2, 0x000000ff) == 0x000001fe);
26   ASSERT(_mullong (0x00007fff,          4) == 0x0001fffc);
27   ASSERT(_mullong (         4, 0x00007fff) == 0x0001fffc);
28   ASSERT(_mullong (0x003fffff,          8) == 0x01fffff8);
29   ASSERT(_mullong (         8, 0x003fffff) == 0x01fffff8);
30
31   ASSERT(_mullong (      0x33,       0x34) == 0x00000a5c);
32   ASSERT(_mullong (      0x34,       0x33) == 0x00000a5c);
33   ASSERT(_mullong (    0x3334,     0x3536) == 0x0aa490f8);
34   ASSERT(_mullong (    0x3536,     0x3334) == 0x0aa490f8);
35   ASSERT(_mullong (  0x333435,   0x363738) == 0x0e98ce98);
36   ASSERT(_mullong (  0x363738,   0x333435) == 0x0e98ce98);
37   ASSERT(_mullong (0x33343536, 0x3738393a) == 0x777d143c);
38   ASSERT(_mullong (0x3738393a, 0x33343536) == 0x777d143c);
39
40   ASSERT(_mullong (      0xff,       0xfe) == 0x0000fd02);
41   ASSERT(_mullong (      0xfe,       0xff) == 0x0000fd02);
42   ASSERT(_mullong (    0xfffe,     0xfdfc) == 0xfdfa0408);
43   ASSERT(_mullong (    0xfdfc,     0xfffe) == 0xfdfa0408);
44   ASSERT(_mullong (  0xfffefd,   0xfcfbfa) == 0xfa0d1212);
45   ASSERT(_mullong (  0xfcfbfa,   0xfffefd) == 0xfa0d1212);
46   ASSERT(_mullong (0xfffefdfc, 0xfbfaf9f8) == 0x20282820);
47   ASSERT(_mullong (0xfbfaf9f8, 0xfffefdfc) == 0x20282820);
48
49   ASSERT(_mullong (0xff000000, 0xff000000) ==          0);
50   ASSERT(_mullong (0xffff0000, 0xffff0000) ==          0);
51   ASSERT(_mullong (0xfffffe00, 0xfffffd00) == 0x00060000);
52   ASSERT(_mullong (0xfffffd00, 0xfffffe00) == 0x00060000);
53   ASSERT(_mullong (0xfffffefd, 0xfffffcfb) == 0x00030e0f);
54   ASSERT(_mullong (0xfffffcfb, 0xfffffefd) == 0x00030e0f);
55
56   ASSERT(_mullong (0xffffffff, 0xffffffff) ==          1);
57 }