1 /** test one byte mul/div/mod operations.
11 #ifndef __SDCC_pdk14 // Lack of memory
12 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
13 {attrL
} signed char cL
;
14 {attrL
} unsigned char ucL
;
15 {attrR
} signed char cR
;
16 {attrR
} unsigned char ucR
;
17 volatile signed char r8
, r8b
;
18 volatile unsigned char ur8
, ur8b
;
19 volatile short r16
, r16b
;
21 cL
= -127; cR
= -5; r16
= cL
* cR
; r16b
= cR
* cL
; ASSERT (r16
== 635); ASSERT (r16b
== 635);
22 cL
= 127; cR
= -5; r16
= cL
* cR
; r16b
= cR
* cL
; ASSERT (r16
== -635); ASSERT (r16b
== -635);
23 cL
= -127; cR
= 5; r16
= cL
* cR
; r16b
= cR
* cL
; ASSERT (r16
== -635); ASSERT (r16b
== -635);
24 cL
= 127; cR
= 5; r16
= cL
* cR
; r16b
= cR
* cL
; ASSERT (r16
== 635); ASSERT (r16b
== 635);
26 cL
= -128; cR
= -1; ur8
= cL
* cR
; ur8b
= cR
* cL
; ASSERT (ur8
== 128); ASSERT (ur8b
== 128);
27 cL
= 128; cR
= -1; r8
= cL
* cR
; r8b
= cR
* cL
; ASSERT ( r8
== -128); ASSERT ( r8b
== -128);
28 cL
= -128; cR
= 1; r8
= cL
* cR
; r8b
= cR
* cL
; ASSERT ( r8
== -128); ASSERT ( r8b
== -128);
29 cL
= 128; cR
= 1; ur8
= cL
* cR
; ur8b
= cR
* cL
; ASSERT (ur8
== 128); ASSERT (ur8b
== 128);
31 ucL
= 128; cR
= -5; r16
= ucL
* cR
; r16b
= cR
* ucL
; ASSERT (r16
== -640); ASSERT (r16b
== -640);
32 ucL
= 128; cR
= 5; r16
= ucL
* cR
; r16b
= cR
* ucL
; ASSERT (r16
== 640); ASSERT (r16b
== 640);
34 ucL
= 127; cR
= -1; r8
= ucL
* cR
; r8b
= cR
* ucL
; ASSERT ( r8
== -127); ASSERT ( r8b
== -127);
35 ucL
= 128; cR
= 1; ur8
= ucL
* cR
; ur8b
= cR
* ucL
; ASSERT (ur8
== 128); ASSERT (ur8b
== 128);
36 ucL
= 128; ucR
= 5; r16
= ucL
* ucR
; r16b
= ucR
* ucL
; ASSERT (r16
== 640); ASSERT (r16b
== 640);
37 ucL
= 128; ucR
= 1; ur8
= ucL
* ucR
; ur8b
= ucR
* ucL
; ASSERT (ur8
== 128); ASSERT (ur8b
== 128);
39 ucL
= 254; cR
= -1; r16
= ucL
* cR
; ASSERT (r16
== -254);
40 cL
= -128; cR
= -1; r16
= cL
* cR
; ASSERT (r16
== 128);
49 #ifndef __SDCC_pdk14 // Lack of memory
50 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
51 {attrL
} signed char cL
;
52 {attrL
} unsigned char ucL
;
53 {attrR
} signed char cR
;
54 {attrR
} unsigned char ucR
;
55 volatile signed char r8
;
56 volatile unsigned char ur8
;
59 cL
= -128; cR
= -2; r8
= cL
/ cR
; ASSERT (r8
== 64);
60 cL
= -128; cR
= -2; r16
= cL
/ cR
; ASSERT (r16
== 64);
62 ucL
= 255; ucR
= 3; r8
= ucL
/ ucR
; ASSERT (r8
== 85);
63 ucL
= 255; ucR
= 255; r8
= ucL
/ ucR
; ASSERT (r8
== 1);
64 ucL
= 3; ucR
= 255; r8
= ucL
/ ucR
; ASSERT (r8
== 0);
66 cL
= 127; cR
= 3; r8
= cL
/ cR
; ASSERT (r8
== 42);
67 cL
= -127; cR
= 3; r8
= cL
/ cR
; ASSERT (r8
== -42);
68 cL
= 127; cR
= -3; r8
= cL
/ cR
; ASSERT (r8
== -42);
69 cL
= -127; cR
= -3; r8
= cL
/ cR
; ASSERT (r8
== 42);
71 ucL
= 127; cR
= 3; r8
= ucL
/ cR
; ASSERT (r8
== 42);
72 ucL
= 255; cR
= 3; r8
= ucL
/ cR
; ASSERT (r8
== 85);
73 ucL
= 127; cR
= -3; r8
= ucL
/ cR
; ASSERT (r8
== -42);
74 ucL
= 255; cR
= -3; r8
= ucL
/ cR
; ASSERT (r8
== -85);
76 cL
= 127; ucR
= 3; r8
= cL
/ ucR
; ASSERT (r8
== 42);
77 cL
= -127; ucR
= 3; r8
= cL
/ ucR
; ASSERT (r8
== -42);
78 cL
= 127; ucR
= 128; r8
= cL
/ ucR
; ASSERT (r8
== 0);
79 cL
= -127; ucR
= 128; r8
= cL
/ ucR
; ASSERT (r8
== 0);
81 cL
= 127; cR
= 1; r8
= cL
/ cR
; ASSERT (r8
== 127);
82 cL
= 127; cR
= 1; r16
= cL
/ cR
; ASSERT (r16
== 127);
84 ucL
= 251; cR
= 1; ur8
= ucL
/ cR
; ASSERT (ur8
== 251);
85 ucL
= 251; cR
= 1; r16
= ucL
/ cR
; ASSERT (r16
== 251);
87 ucL
= 253; cR
= -3; r8
= ucL
/ cR
; ASSERT (r8
== -84);
88 ucL
= 253; cR
= -3; r16
= ucL
/ cR
; ASSERT (r16
== -84);
90 ucL
= 254; cR
= -1; r16
= ucL
/ cR
; ASSERT (r16
== -254);
91 cL
= -128; cR
= -1; r16
= cL
/ cR
; ASSERT (r16
== 128);
99 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
100 {attrL
} signed char cL
;
101 {attrL
} unsigned char ucL
;
102 {attrR
} signed char cR
;
103 {attrR
} unsigned char ucR
;
104 volatile signed char r8
;
105 volatile unsigned char ur8
;
108 ucL
= 128; cR
= 5; r16
= ucL
% cR
; ASSERT (r16
== 3);
109 ucL
= 128; cR
= -5; r16
= ucL
% cR
; ASSERT (r16
== 3);
110 ucL
= 128; ucR
= 5; r16
= ucL
% ucR
; ASSERT (r16
== 3);
112 ucL
= 128; ucR
= 255; ur8
= ucL
% ucR
; ASSERT (ur8
== 128);
113 ucL
= 128; ucR
= 255; r16
= ucL
% ucR
; ASSERT (r16
== 128);
115 ucL
= 128; cR
= 127; r8
= ucL
% cR
; ASSERT (r8
== 1);
117 cL
= 127; cR
= 5; r16
= cL
% cR
; ASSERT (r16
== 2);
119 cL
= 127; cR
= -5; r16
= cL
% cR
; ASSERT (r16
== 2);
121 cL
= 127; ucR
= 5; r16
= cL
% ucR
; ASSERT (r16
== 2);
123 cL
= 127; ucR
= 6; r16
= cL
% ucR
; ASSERT (r16
== 1);
125 cL
= -128; cR
= 5; r16
= cL
% cR
; ASSERT (r16
== -3);
127 cL
= -128; cR
= -5; r16
= cL
% cR
; ASSERT (r16
== -3);
129 cL
= -128; ucR
= 5; r16
= cL
% ucR
; ASSERT (r16
== -3);
136 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
137 {attrL
} signed char cL
;
138 {attrL
} unsigned char ucL
;
139 {attrR
} signed char cR
;
140 {attrR
} unsigned char ucR
;
141 volatile short r16
, r16b
;
143 cL
= 0x00; cR
= 0x80; r16
= cL
| cR
; r16b
= cR
| cL
; ASSERT (r16
== (short) 0xff80); ASSERT (r16b
== (short) 0xff80);
144 ucL
= 0x80; cR
= 0x00; r16
= ucL
| cR
; r16b
= cR
| ucL
; ASSERT (r16
== 0x80); ASSERT (r16b
== 0x80);
145 ucL
= 0x80; ucR
= 0x80; r16
= ucL
| ucR
; r16b
= ucR
| ucL
; ASSERT (r16
== 0x80); ASSERT (r16b
== 0x80);
152 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
153 {attrL
} signed char cL
;
154 {attrL
} unsigned char ucL
;
155 {attrR
} signed char cR
;
156 {attrR
} unsigned char ucR
;
157 volatile short r16
, r16b
;
159 cL
= 0x80; cR
= 0x80; r16
= cL
^ cR
; r16b
= cR
^ cL
; ASSERT (r16
== 0); ASSERT (r16b
== 0);
160 cL
= 0x80; cR
= 0x00; r16
= cL
^ cR
; r16b
= cR
^ cL
; ASSERT (r16
== (short) 0xff80); ASSERT (r16b
== (short) 0xff80);
162 ucL
= 0x80; cR
= 0x80; r16
= ucL
^ cR
; r16b
= cR
^ ucL
; ASSERT (r16
== (short) 0xff00); ASSERT (r16b
== (short) 0xff00);
163 ucL
= 0x80; cR
= 0; r16
= ucL
^ cR
; r16b
= cR
^ ucL
; ASSERT (r16
== 0x80); ASSERT (r16b
== 0x80);
164 ucL
= 0; cR
= 0x80; r16
= ucL
^ cR
; r16b
= cR
^ ucL
; ASSERT (r16
== (short) 0xff80); ASSERT (r16b
== (short) 0xff80);
166 ucL
= 0x80; ucR
= 0x80; r16
= ucL
^ ucR
; r16b
= ucR
^ ucL
; ASSERT (r16
== 0); ASSERT (r16b
== 0);
167 ucL
= 0; ucR
= 0x80; r16
= ucL
^ ucR
; r16b
= ucR
^ ucL
; ASSERT (r16
== 0x80); ASSERT (r16b
== 0x80);
174 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
175 {attrL
} signed char cL
;
176 {attrL
} unsigned char ucL
;
177 {attrR
} signed char cR
;
178 {attrR
} unsigned char ucR
;
179 volatile short r16
, r16b
;
181 cL
= 0x80; cR
= 0x80; r16
= cL
& cR
; r16b
= cR
& cL
; ASSERT (r16
== (short) 0xff80); ASSERT (r16b
== (short) 0xff80);
182 ucL
= 0x80; cR
= 0x80; r16
= ucL
& cR
; r16b
= cR
& ucL
; ASSERT (r16
== 0x80); ASSERT (r16b
== 0x80);
183 ucL
= 0x80; ucR
= 0x80; r16
= ucL
& ucR
; r16b
= ucR
& ucL
; ASSERT (r16
== 0x80); ASSERT (r16b
== 0x80);
188 testComplement (void)
190 {attrR
} signed char c
;
191 {attrR
} unsigned char uc
;
194 c
= 0x00; r16
= ~ c
; ASSERT (r16
== (short) 0xffff); ASSERT (~ c
< 0);
195 uc
= 0x00; r16
= ~uc
; ASSERT (r16
== (short) 0xffff); ASSERT (~uc
< 0);
196 ASSERT (~ (signed char) 0x00 == (short) 0xffff); ASSERT (~ (signed char) 0x00 < 0);
197 ASSERT (~ (unsigned char) 0x00 == (short) 0xffff); ASSERT (~ (unsigned char) 0x00 < 0);
198 c
= 0x80; r16
= ~ c
; ASSERT (r16
== (short) 0x007f); ASSERT (~ c
> 0);
199 uc
= 0x80; r16
= ~uc
; ASSERT (r16
== (short) 0xff7f); ASSERT (~uc
< 0);
200 ASSERT (~ (signed char) 0x80 == (short) 0x007f); ASSERT (~ (signed char) 0x80 > 0);
201 ASSERT (~ (unsigned char) 0x80 == (short) 0xff7f); ASSERT (~ (unsigned char) 0x80 < 0);
212 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
213 {attrL
} signed char c
;
214 {attrR
} unsigned char uc
;
217 uc
= 0x80; /* +128 */
231 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
232 signed char {attrL
} sc
;
233 unsigned char {attrL
} uc
;
234 signed int {attrL
} si
;
235 unsigned int {attrL
} ui
;
236 signed long {attrL
} sl
;
237 unsigned long {attrL
} ul
;
239 ASSERT (-(53l ) < 0);
240 ASSERT (-(53ul) > 0);
247 ASSERT (-(53u ) > 0);
253 ASSERT (-( 250 ) == -250);
255 ASSERT (-uc
== -250);
257 ASSERT (-(-128 ) == 128);
264 testBug1571231 (void)
266 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
267 unsigned char {attrL
} uc
;