1 /* Test _mullong.c from library
10 # include "../../../../../sdccconf.h"
11 # if defined(type_c) && !defined(WORDS_BIGENDIAN)
12 # define _SDCC_NO_ASM_LIB_FUNCS 1
15 # include "../../../../../device/lib/_mullong.c"
16 # define mullong(a,b) mullong_wrapper(a,b)
18 # define mullong(a,b) (a*b)
22 # define _SDCC_NO_ASM_LIB_FUNCS 1
24 # include "../../../../../device/lib/_mullong.c"
25 # define mullong _mullong
28 /* gcc 2.95.2 on usf-cf-x86-linux-1 (debian 2.2) has a bug with
31 #if defined(PORT_HOST) && defined(type_c) && !defined(WORDS_BIGENDIAN)
40 mullong_wrapper (long a, long b)
42 if (sizeof(pack_test) == 4)
43 /* length of struct ok: use SDCC library */
44 return _mullong (a, b);
46 /* buggy gcc: use generic multiplication */
54 ASSERT(mullong ( 0, 0) == 0);
55 ASSERT(mullong ( 0x100, 0x100) == 0x10000);
56 ASSERT(mullong (0x01020304, 3) == 0x0306090c);
57 ASSERT(mullong ( 3, 0x01020304) == 0x0306090c);
58 ASSERT(mullong (0x000000ff, 2) == 0x000001fe);
59 ASSERT(mullong ( 2, 0x000000ff) == 0x000001fe);
60 ASSERT(mullong (0x00007fff, 4) == 0x0001fffc);
61 ASSERT(mullong ( 4, 0x00007fff) == 0x0001fffc);
62 ASSERT(mullong (0x003fffff, 8) == 0x01fffff8);
63 ASSERT(mullong ( 8, 0x003fffff) == 0x01fffff8);
65 ASSERT(mullong ( 0x33, 0x34) == 0x00000a5c);
66 ASSERT(mullong ( 0x34, 0x33) == 0x00000a5c);
67 ASSERT(mullong ( 0x3334, 0x3536) == 0x0aa490f8);
68 ASSERT(mullong ( 0x3536, 0x3334) == 0x0aa490f8);
69 ASSERT(mullong ( 0x333435, 0x363738) == 0x0e98ce98);
70 ASSERT(mullong ( 0x363738, 0x333435) == 0x0e98ce98);
71 ASSERT(mullong (0x33343536, 0x3738393a) == 0x777d143c);
72 ASSERT(mullong (0x3738393a, 0x33343536) == 0x777d143c);
74 ASSERT(mullong ( 0xff, 0xfe) == 0x0000fd02);
75 ASSERT(mullong ( 0xfe, 0xff) == 0x0000fd02);
76 ASSERT(mullong ( 0xfffe, 0xfdfc) == 0xfdfa0408);
77 ASSERT(mullong ( 0xfdfc, 0xfffe) == 0xfdfa0408);
78 ASSERT(mullong ( 0xfffefd, 0xfcfbfa) == 0xfa0d1212);
79 ASSERT(mullong ( 0xfcfbfa, 0xfffefd) == 0xfa0d1212);
80 ASSERT(mullong (0xfffefdfc, 0xfbfaf9f8) == 0x20282820);
81 ASSERT(mullong (0xfbfaf9f8, 0xfffefdfc) == 0x20282820);
83 ASSERT(mullong (0xff000000, 0xff000000) == 0);
84 ASSERT(mullong (0xffff0000, 0xffff0000) == 0);
85 ASSERT(mullong (0xfffffe00, 0xfffffd00) == 0x00060000);
86 ASSERT(mullong (0xfffffd00, 0xfffffe00) == 0x00060000);
87 ASSERT(mullong (0xfffffefd, 0xfffffcfb) == 0x00030e0f);
88 ASSERT(mullong (0xfffffcfb, 0xfffffefd) == 0x00030e0f);
90 ASSERT(mullong (0xffffffff, 0xffffffff) == 1);