1 /* Test operandOperation() in SDCCicode.c
3 type: char, short, LONG
8 #if defined(__alpha) || defined(__amd64)
14 typedef signed {type} stype;
15 typedef unsigned {type} utype;
19 #if defined(PORT_HOST) || defined(SDCC_z80) || defined(SDCC_gbz80)
24 volatile char is8 = 8;
32 volatile signed char vsc;
33 volatile signed short vss;
34 volatile signed LONG vsl;
35 volatile unsigned char vuc;
36 volatile unsigned short vus;
37 volatile unsigned LONG vul;
49 ASSERT((stype) -3 * (stype) -1 == (stype) 3);
50 ASSERT((stype) -3 * (stype) 1 == (stype) -3);
51 ASSERT((stype) 3 * (stype) -1 == (stype) -3);
53 ASSERT((stype) 1 * (utype) 0xfffffff7 == (utype) 0xfffffff7);
55 ASSERT((unsigned char ) 0xfffffff8 * (unsigned char ) 0xfffffff7 == 0xef48);
56 ASSERT((unsigned short) 0xfffffff8 * (unsigned short) 0xfffffff7 == (sizeof(int) == 2 ? 0x0048 : 0xffef0048));
57 ASSERT((unsigned LONG ) 0xfffffff8 * (unsigned LONG ) 0xfffffff7 == 0x0048);
59 ASSERT((stype ) 0xfffffff8 * (stype ) 0xfffffff7 == 72);
61 ASSERT((signed char ) -1 * (unsigned char ) 0xfffffff7 == (sizeof(int) == 2 ? 0xff09 : 0xffffff09));
62 ASSERT((signed short) -1 * (unsigned short) 0xfffffff7 == (sizeof(int) == 2 ? 9u : 0xffff0009));
63 ASSERT((signed LONG ) -1 * (unsigned LONG ) 0xfffffff7 == 9u);
65 ASSERT((signed char ) -2 * (unsigned char ) 0x8004 == (sizeof(int) == 2 ? 0xfff8 : 0xfffffff8));
66 ASSERT((signed short) -2 * (unsigned short) 0x8004 == (sizeof(int) == 2 ? 0xfff8 : 0xfffefff8));
67 ASSERT((signed LONG ) -2 * (unsigned LONG ) 0x8004 == 0xfffefff8);
69 ASSERT(-1 * 0xfff7 == (sizeof(int) == 2 ? 9 : 0xffff0009)); // 0xfff7 is stored in 'unsigned int'
71 ASSERT(-1 * 65527 == -65527); // 65527 (== 0xfff7) is stored in 'signed LONG'
72 ASSERT(-1 * 33000 == -33000);
74 ASSERT(1 * 10000 * is8 == (sizeof(int) == 2 ? 14464 : 80000)); /* int */
75 ASSERT(1 * 10000l * is8 == 80000); /* LONG */
76 ASSERT(1 * 40000u * is8 == (sizeof(int) == 2 ? 57856u : 320000)); /* unsigned */
77 ASSERT(1 * 40000 * is8 == 320000); /* LONG */
78 ASSERT(1 * 0x4000 * is8 == (sizeof(int) == 2 ? 0 : 0x20000)); /* unsigned */
86 ASSERT(s * (stype) -1 == (stype) 3);
87 ASSERT(s * (stype) 1 == (stype) -3);
89 ASSERT(s * (stype) -1 == (stype) -3);
92 ASSERT(s * (utype) 0xfffffff7 == (utype) 0xfffffff7);
93 uc = (unsigned char ) 0xfffffff8;
94 ASSERT(uc * (unsigned char ) 0xfffffff7 == 0xef48);
95 us = (unsigned short) 0xfffffff8;
96 ASSERT(us * (unsigned short) 0xfffffff7 == (sizeof(int) == 2 ? 0x0048 : 0xffef0048));
97 ul = (unsigned LONG ) 0xfffffff8;
98 ASSERT(ul * (unsigned LONG ) 0xfffffff7 == 0x0048);
99 ul = (unsigned LONG ) 0xfffffff8;
101 ASSERT((stype ) 0xfffffff8 * (stype ) 0xfffffff7 == 72);
103 ASSERT((signed char ) -1 * (unsigned char ) 0xfffffff7 == (sizeof(int) == 2 ? 0xff09 : 0xffffff09));
104 ASSERT((signed short) -1 * (unsigned short) 0xfffffff7 == (sizeof(int) == 2 ? 9u : 0xffff0009));
105 ASSERT((signed LONG ) -1 * (unsigned LONG ) 0xfffffff7 == 9u);
107 ASSERT((signed char ) -2 * (unsigned char ) 0x8004 == (sizeof(int) == 2 ? 0xfff8 : 0xfffffff8));
108 ASSERT((signed short) -2 * (unsigned short) 0x8004 == (sizeof(int) == 2 ? 0xfff8 : 0xfffefff8));
109 ASSERT((signed LONG ) -2 * (unsigned LONG ) 0x8004 == 0xfffefff8);
113 ASSERT((stype) -12 / (stype) -3 == (stype) 4);
114 ASSERT((stype) -12 / (stype) 3 == (stype) -4);
115 ASSERT((stype) 12 / (stype) -3 == (stype) -4);
117 // ASSERT((stype) -12 / (utype) -3 == (stype) 4);
118 // ASSERT((utype) -12 / (stype) -3 == (stype) 4);
119 // ASSERT((utype) -12 / (utype) -3 == (stype) 4);
122 ASSERT(12u / 3 * 10000 == 40000);
128 ASSERT((stype) -14 % (stype) -3 == (stype) -2);
129 ASSERT((stype) -14 % (stype) 3 == (stype) -2);
130 ASSERT((stype) 14 % (stype) -3 == (stype) 2);