1 |
51 |
ameziti |
diff -NaurbB sdcc-src-3.1.0/Makefile.common.in sdcc-src-3.1.0-pblaze/Makefile.common.in
|
2 |
|
|
--- sdcc-src-3.1.0/Makefile.common.in 2011-10-20 11:10:56.000000000 +0200
|
3 |
|
|
+++ sdcc-src-3.1.0-pblaze/Makefile.common.in 2011-12-04 13:58:18.197756400 +0100
|
4 |
|
|
@@ -51,6 +51,7 @@
|
5 |
|
|
OPT_DISABLE_Z180 = @OPT_DISABLE_Z180@
|
6 |
|
|
OPT_DISABLE_R2K = @OPT_DISABLE_R2K@
|
7 |
|
|
OPT_DISABLE_GBZ80 = @OPT_DISABLE_GBZ80@
|
8 |
|
|
+OPT_DISABLE_PBLAZE = @OPT_DISABLE_PBLAZE@
|
9 |
|
|
|
10 |
|
|
OPT_DISABLE_UCSIM = @OPT_DISABLE_UCSIM@
|
11 |
|
|
OPT_DISABLE_DEVICE_LIB= @OPT_DISABLE_DEVICE_LIB@
|
12 |
|
|
diff -NaurbB sdcc-src-3.1.0/configure sdcc-src-3.1.0-pblaze/configure
|
13 |
|
|
--- sdcc-src-3.1.0/configure 2011-10-25 20:43:54.000000000 +0200
|
14 |
|
|
+++ sdcc-src-3.1.0-pblaze/configure 2011-12-05 22:37:52.945707300 +0100
|
15 |
|
|
@@ -620,6 +620,7 @@
|
16 |
|
|
OPT_DISABLE_Z180
|
17 |
|
|
OPT_DISABLE_Z80
|
18 |
|
|
OPT_DISABLE_MCS51
|
19 |
|
|
+OPT_DISABLE_PBLAZE
|
20 |
|
|
non_free_lib_dir_suffix
|
21 |
|
|
lib_dir_suffix
|
22 |
|
|
non_free_include_dir_suffix
|
23 |
|
|
@@ -716,6 +717,7 @@
|
24 |
|
|
enable_hc08_port
|
25 |
|
|
enable_avr_port
|
26 |
|
|
enable_xa51_port
|
27 |
|
|
+enable_pblaze_port
|
28 |
|
|
enable_ucsim
|
29 |
|
|
enable_device_lib
|
30 |
|
|
enable_packihx
|
31 |
|
|
@@ -1373,6 +1375,7 @@
|
32 |
|
|
--disable-pic14-port Excludes the PIC14 port
|
33 |
|
|
--disable-pic16-port Excludes the PIC16 port
|
34 |
|
|
--disable-hc08-port Excludes the HC08 port
|
35 |
|
|
+ --disable-pblaze-port Excludes the PBLAZE port
|
36 |
|
|
--enable-avr-port Includes the AVR port (disabled by default)
|
37 |
|
|
--enable-xa51-port Includes the XA51 port (disabled by default)
|
38 |
|
|
--disable-ucsim Disables configuring and building of ucsim
|
39 |
|
|
@@ -6580,6 +6583,32 @@
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
+ # Check whether --enable-pblaze-port was given.
|
44 |
|
|
+if test "${enable_pblaze_port+set}" = set; then :
|
45 |
|
|
+ enableval=$enable_pblaze_port;
|
46 |
|
|
+fi
|
47 |
|
|
+
|
48 |
|
|
+
|
49 |
|
|
+ if test "$enable_pblaze_port" = "no"; then
|
50 |
|
|
+ OPT_DISABLE_PBLAZE=1
|
51 |
|
|
+ else
|
52 |
|
|
+ enable_pblaze_port="yes"
|
53 |
|
|
+ OPT_DISABLE_PBLAZE=0
|
54 |
|
|
+ fi
|
55 |
|
|
+
|
56 |
|
|
+
|
57 |
|
|
+cat >>confdefs.h <<_ACEOF
|
58 |
|
|
+#define OPT_DISABLE_PBLAZE $OPT_DISABLE_PBLAZE
|
59 |
|
|
+_ACEOF
|
60 |
|
|
+
|
61 |
|
|
+
|
62 |
|
|
+
|
63 |
|
|
+ echo pblaze >>ports.all
|
64 |
|
|
+ if test $OPT_DISABLE_PBLAZE = 0; then
|
65 |
|
|
+ echo pblaze >>ports.build
|
66 |
|
|
+ fi
|
67 |
|
|
+
|
68 |
|
|
+
|
69 |
|
|
# Check whether --enable-ucsim was given.
|
70 |
|
|
if test "${enable_ucsim+set}" = set; then :
|
71 |
|
|
enableval=$enable_ucsim;
|
72 |
|
|
@@ -7068,6 +7097,10 @@
|
73 |
|
|
|
74 |
|
|
fi
|
75 |
|
|
|
76 |
|
|
+if test $OPT_DISABLE_PBLAZE = 0; then
|
77 |
|
|
+ ac_config_files="$ac_config_files src/pblaze/Makefile"
|
78 |
|
|
+fi
|
79 |
|
|
+
|
80 |
|
|
if test $OPT_DISABLE_Z80 = 0 || test $OPT_DISABLE_Z180 = 0; then
|
81 |
|
|
ac_config_files="$ac_config_files sdas/asz80/Makefile"
|
82 |
|
|
|
83 |
|
|
@@ -7797,6 +7830,7 @@
|
84 |
|
|
"src/hc08/Makefile") CONFIG_FILES="$CONFIG_FILES src/hc08/Makefile" ;;
|
85 |
|
|
"sdas/as6808/Makefile") CONFIG_FILES="$CONFIG_FILES sdas/as6808/Makefile" ;;
|
86 |
|
|
"device/lib/hc08/Makefile") CONFIG_FILES="$CONFIG_FILES device/lib/hc08/Makefile" ;;
|
87 |
|
|
+ "src/pblaze/Makefile") CONFIG_FILES="$CONFIG_FILES src/pblaze/Makefile" ;;
|
88 |
|
|
"src/mcs51/Makefile") CONFIG_FILES="$CONFIG_FILES src/mcs51/Makefile" ;;
|
89 |
|
|
"sdas/as8051/Makefile") CONFIG_FILES="$CONFIG_FILES sdas/as8051/Makefile" ;;
|
90 |
|
|
"device/lib/mcs51/Makefile") CONFIG_FILES="$CONFIG_FILES device/lib/mcs51/Makefile" ;;
|
91 |
|
|
@@ -8805,6 +8839,7 @@
|
92 |
|
|
z80 ${enable_z80_port}
|
93 |
|
|
z180 ${enable_z180_port}
|
94 |
|
|
r2k ${enable_r2k_port}
|
95 |
|
|
+ pblaze ${enable_pblaze_port}
|
96 |
|
|
|
97 |
|
|
Disable packihx: ${OPT_DISABLE_PACKIHX}
|
98 |
|
|
Disable ucsim: ${OPT_DISABLE_UCSIM}
|
99 |
|
|
@@ -8865,6 +8900,7 @@
|
100 |
|
|
z80 ${enable_z80_port}
|
101 |
|
|
z180 ${enable_z180_port}
|
102 |
|
|
r2k ${enable_r2k_port}
|
103 |
|
|
+ pblaze ${enable_pblaze_port}
|
104 |
|
|
|
105 |
|
|
Disable packihx: ${OPT_DISABLE_PACKIHX}
|
106 |
|
|
Disable ucsim: ${OPT_DISABLE_UCSIM}
|
107 |
|
|
diff -NaurbB sdcc-src-3.1.0/configure.in sdcc-src-3.1.0-pblaze/configure.in
|
108 |
|
|
--- sdcc-src-3.1.0/configure.in 2011-10-25 20:43:54.000000000 +0200
|
109 |
|
|
+++ sdcc-src-3.1.0-pblaze/configure.in 2011-12-04 14:42:23.262045400 +0100
|
110 |
|
|
@@ -815,6 +815,7 @@
|
111 |
|
|
AC_DO_PORT(pic14, pic14, PIC14, [Excludes the PIC14 port])
|
112 |
|
|
AC_DO_PORT(pic16, pic16, PIC16, [Excludes the PIC16 port])
|
113 |
|
|
AC_DO_PORT(hc08, hc08, HC08, [Excludes the HC08 port])
|
114 |
|
|
+AC_DO_PORT(pblaze, pblaze, PBLAZE, [Excludes the PBLAZE port])
|
115 |
|
|
|
116 |
|
|
# Unsupported targets
|
117 |
|
|
AC_DO_PORT_ENABLER(avr, avr, AVR, [Includes the AVR port (disabled by default)])
|
118 |
|
|
@@ -906,6 +907,10 @@
|
119 |
|
|
AC_CONFIG_FILES([src/z80/Makefile])
|
120 |
|
|
fi
|
121 |
|
|
|
122 |
|
|
+if test $OPT_DISABLE_PBLAZE = 0; then
|
123 |
|
|
+ AC_CONFIG_FILES([src/pblaze/Makefile])
|
124 |
|
|
+fi
|
125 |
|
|
+
|
126 |
|
|
if test $OPT_DISABLE_Z80 = 0 || test $OPT_DISABLE_Z180 = 0; then
|
127 |
|
|
AC_CONFIG_FILES([sdas/asz80/Makefile])
|
128 |
|
|
test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/z80/Makefile
|
129 |
|
|
@@ -991,6 +996,7 @@
|
130 |
|
|
z80 ${enable_z80_port}
|
131 |
|
|
z180 ${enable_z180_port}
|
132 |
|
|
r2k ${enable_r2k_port}
|
133 |
|
|
+ pblaze ${enable_pblaze_port}
|
134 |
|
|
|
135 |
|
|
Disable packihx: ${OPT_DISABLE_PACKIHX}
|
136 |
|
|
Disable ucsim: ${OPT_DISABLE_UCSIM}
|
137 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/asm.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/asm.c
|
138 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/asm.c 1970-01-01 01:00:00.000000000 +0100
|
139 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/asm.c 2011-08-23 15:57:26.000000000 +0200
|
140 |
|
|
@@ -0,0 +1,17 @@
|
141 |
|
|
+// test of inserted asm code into C code
|
142 |
|
|
+int i;
|
143 |
|
|
+
|
144 |
|
|
+/*
|
145 |
|
|
+asm
|
146 |
|
|
+ENABLE_INTERRUPT;
|
147 |
|
|
+endasm
|
148 |
|
|
+*/
|
149 |
|
|
+
|
150 |
|
|
+int main(void)
|
151 |
|
|
+{
|
152 |
|
|
+__asm
|
153 |
|
|
+INPUT s0
|
154 |
|
|
+__endasm;
|
155 |
|
|
+i = 10;
|
156 |
|
|
+return i;
|
157 |
|
|
+}
|
158 |
|
|
\ No newline at end of file
|
159 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/build.bat sdcc-src-3.1.0-pblaze/device/examples/pblaze/build.bat
|
160 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/build.bat 1970-01-01 01:00:00.000000000 +0100
|
161 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/build.bat 2011-12-06 08:43:41.526003500 +0100
|
162 |
|
|
@@ -0,0 +1,8 @@
|
163 |
|
|
+@REM Compile-only (no assembling and linking)
|
164 |
|
|
+..\..\..\bin\sdcc.exe %1 -mpblaze -S -I"..\..\..\device\include\pblaze"
|
165 |
|
|
+
|
166 |
|
|
+@REM Compile and assemble only (no linking)
|
167 |
|
|
+@REM ..\..\bin\sdcc.exe %1 -mpblaze -c -I"..\..\device\include\pblaze"
|
168 |
|
|
+
|
169 |
|
|
+@REM Compile, assemble and link
|
170 |
|
|
+@REM ..\..\bin\sdcc.exe %1 -mpblaze -I"..\..\device\include\pblaze"
|
171 |
|
|
\ No newline at end of file
|
172 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/demo.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/demo.c
|
173 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/demo.c 1970-01-01 01:00:00.000000000 +0100
|
174 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/demo.c 2011-08-23 15:57:26.000000000 +0200
|
175 |
|
|
@@ -0,0 +1,42 @@
|
176 |
|
|
+//#include <stdio.h>
|
177 |
|
|
+
|
178 |
|
|
+void __port_write(char port, char arg) { }
|
179 |
|
|
+char __port_read(char port) { }
|
180 |
|
|
+void __nop() { }
|
181 |
|
|
+
|
182 |
|
|
+#define LCD_wr(arg) __port_write(0x01, (arg))
|
183 |
|
|
+#define LCD_rd() __port_read(0x01)
|
184 |
|
|
+#define LCD_busy() (LCD_rd() & 0x80) == 0x80
|
185 |
|
|
+
|
186 |
|
|
+void delay_ms(int ms)
|
187 |
|
|
+{
|
188 |
|
|
+ int i;
|
189 |
|
|
+ for (;;) {
|
190 |
|
|
+ for (i=0; i < 10000; i++) __nop();
|
191 |
|
|
+ }
|
192 |
|
|
+}
|
193 |
|
|
+
|
194 |
|
|
+void LCD_init()
|
195 |
|
|
+{
|
196 |
|
|
+ LCD_wr(0x42);
|
197 |
|
|
+ while (LCD_rd()) { __nop();}
|
198 |
|
|
+ LCD_wr(0x43);
|
199 |
|
|
+ delay_ms(10);
|
200 |
|
|
+ LCD_wr(0x44);
|
201 |
|
|
+ LCD_wr(0x45);
|
202 |
|
|
+}
|
203 |
|
|
+
|
204 |
|
|
+void LCD_write(char ch)
|
205 |
|
|
+{
|
206 |
|
|
+ LCD_wr(0x46);
|
207 |
|
|
+ LCD_wr(0x47);
|
208 |
|
|
+}
|
209 |
|
|
+
|
210 |
|
|
+int main(void) {
|
211 |
|
|
+ char ch = 0x31;
|
212 |
|
|
+ LCD_init();
|
213 |
|
|
+ while (1) {
|
214 |
|
|
+ LCD_write(ch);
|
215 |
|
|
+ delay_ms(1000);
|
216 |
|
|
+ }
|
217 |
|
|
+}
|
218 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test10.kcpsm.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test10.kcpsm.psm
|
219 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test10.kcpsm.psm 1970-01-01 01:00:00.000000000 +0100
|
220 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test10.kcpsm.psm 2011-08-23 15:57:26.000000000 +0200
|
221 |
|
|
@@ -0,0 +1,213 @@
|
222 |
|
|
+;--------------------------------------------------------
|
223 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
224 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
225 |
|
|
+; This file was generated Fri Apr 22 14:06:05 2011
|
226 |
|
|
+;--------------------------------------------------------
|
227 |
|
|
+;--------------------------------------------------------
|
228 |
|
|
+; global & static initialisations
|
229 |
|
|
+;--------------------------------------------------------
|
230 |
|
|
+ CONSTANT _numbers_19, 00
|
231 |
|
|
+ CONSTANT _numbers_18, 01
|
232 |
|
|
+ CONSTANT _numbers_17, 02
|
233 |
|
|
+ CONSTANT _numbers_16, 03
|
234 |
|
|
+ CONSTANT _numbers_15, 04
|
235 |
|
|
+ CONSTANT _numbers_14, 05
|
236 |
|
|
+ CONSTANT _numbers_13, 06
|
237 |
|
|
+ CONSTANT _numbers_12, 07
|
238 |
|
|
+ CONSTANT _numbers_11, 08
|
239 |
|
|
+ CONSTANT _numbers_10, 09
|
240 |
|
|
+ CONSTANT _numbers_9, 0a
|
241 |
|
|
+ CONSTANT _numbers_8, 0b
|
242 |
|
|
+ CONSTANT _numbers_7, 0c
|
243 |
|
|
+ CONSTANT _numbers_6, 0d
|
244 |
|
|
+ CONSTANT _numbers_5, 0e
|
245 |
|
|
+ CONSTANT _numbers_4, 0f
|
246 |
|
|
+ CONSTANT _numbers_3, 10
|
247 |
|
|
+ CONSTANT _numbers_2, 11
|
248 |
|
|
+ CONSTANT _numbers_1, 12
|
249 |
|
|
+ CONSTANT _numbers_0, 13
|
250 |
|
|
+
|
251 |
|
|
+;------------------------------------------------------------
|
252 |
|
|
+;Allocation info for local variables in function 'main'
|
253 |
|
|
+;------------------------------------------------------------
|
254 |
|
|
+;------------------------------------------------------------
|
255 |
|
|
+ ; test10.c:5: volatile short numbers[ARRAY_SIZE] = {9,8,7,6,5,4,3,2,1,0};
|
256 |
|
|
+ LOAD s0, _numbers_19
|
257 |
|
|
+ LOAD s1, 00
|
258 |
|
|
+ STORE s1, (s0)
|
259 |
|
|
+ ADD s0, 01
|
260 |
|
|
+ LOAD s1, 09
|
261 |
|
|
+ STORE s1, (s0)
|
262 |
|
|
+ LOAD s0, _numbers_19
|
263 |
|
|
+ ADD s0, 02
|
264 |
|
|
+ LOAD s1, 00
|
265 |
|
|
+ STORE s1, (s0)
|
266 |
|
|
+ ADD s0, 01
|
267 |
|
|
+ LOAD s1, 08
|
268 |
|
|
+ STORE s1, (s0)
|
269 |
|
|
+ LOAD s0, _numbers_19
|
270 |
|
|
+ ADD s0, 04
|
271 |
|
|
+ LOAD s1, 00
|
272 |
|
|
+ STORE s1, (s0)
|
273 |
|
|
+ ADD s0, 01
|
274 |
|
|
+ LOAD s1, 07
|
275 |
|
|
+ STORE s1, (s0)
|
276 |
|
|
+ LOAD s0, _numbers_19
|
277 |
|
|
+ ADD s0, 06
|
278 |
|
|
+ LOAD s1, 00
|
279 |
|
|
+ STORE s1, (s0)
|
280 |
|
|
+ ADD s0, 01
|
281 |
|
|
+ LOAD s1, 06
|
282 |
|
|
+ STORE s1, (s0)
|
283 |
|
|
+ LOAD s0, _numbers_19
|
284 |
|
|
+ ADD s0, 08
|
285 |
|
|
+ LOAD s1, 00
|
286 |
|
|
+ STORE s1, (s0)
|
287 |
|
|
+ ADD s0, 01
|
288 |
|
|
+ LOAD s1, 05
|
289 |
|
|
+ STORE s1, (s0)
|
290 |
|
|
+ LOAD s0, _numbers_19
|
291 |
|
|
+ ADD s0, 0a
|
292 |
|
|
+ LOAD s1, 00
|
293 |
|
|
+ STORE s1, (s0)
|
294 |
|
|
+ ADD s0, 01
|
295 |
|
|
+ LOAD s1, 04
|
296 |
|
|
+ STORE s1, (s0)
|
297 |
|
|
+ LOAD s0, _numbers_19
|
298 |
|
|
+ ADD s0, 0c
|
299 |
|
|
+ LOAD s1, 00
|
300 |
|
|
+ STORE s1, (s0)
|
301 |
|
|
+ ADD s0, 01
|
302 |
|
|
+ LOAD s1, 03
|
303 |
|
|
+ STORE s1, (s0)
|
304 |
|
|
+ LOAD s0, _numbers_19
|
305 |
|
|
+ ADD s0, 0e
|
306 |
|
|
+ LOAD s1, 00
|
307 |
|
|
+ STORE s1, (s0)
|
308 |
|
|
+ ADD s0, 01
|
309 |
|
|
+ LOAD s1, 02
|
310 |
|
|
+ STORE s1, (s0)
|
311 |
|
|
+ LOAD s0, _numbers_19
|
312 |
|
|
+ ADD s0, 10
|
313 |
|
|
+ LOAD s1, 00
|
314 |
|
|
+ STORE s1, (s0)
|
315 |
|
|
+ ADD s0, 01
|
316 |
|
|
+ LOAD s1, 01
|
317 |
|
|
+ STORE s1, (s0)
|
318 |
|
|
+ LOAD s0, _numbers_19
|
319 |
|
|
+ ADD s0, 12
|
320 |
|
|
+ LOAD s1, 00
|
321 |
|
|
+ STORE s1, (s0)
|
322 |
|
|
+ ADD s0, 01
|
323 |
|
|
+ LOAD s1, 00
|
324 |
|
|
+ STORE s1, (s0)
|
325 |
|
|
+ LOAD sF, 3f
|
326 |
|
|
+ JUMP __sdcc_program_startup
|
327 |
|
|
+;--------------------------------------------------------
|
328 |
|
|
+; Home
|
329 |
|
|
+;--------------------------------------------------------
|
330 |
|
|
+__sdcc_program_startup:
|
331 |
|
|
+ CALL _main
|
332 |
|
|
+; return from main will lock up
|
333 |
|
|
+__sdcc_loop:
|
334 |
|
|
+ JUMP __sdcc_loop
|
335 |
|
|
+;--------------------------------------------------------
|
336 |
|
|
+; code
|
337 |
|
|
+;--------------------------------------------------------
|
338 |
|
|
+;------------------------------------------------------------
|
339 |
|
|
+;Allocation info for local variables in function 'main'
|
340 |
|
|
+;------------------------------------------------------------
|
341 |
|
|
+;------------------------------------------------------------
|
342 |
|
|
+_main:
|
343 |
|
|
+ ; test10.c:7: void main()
|
344 |
|
|
+ ; test10.c:11: for (i = (ARRAY_SIZE - 1); i > 0; i--)
|
345 |
|
|
+ LOAD s0, 09
|
346 |
|
|
+ LOAD s1, 00
|
347 |
|
|
+_L00107:
|
348 |
|
|
+ LOAD s2, 00
|
349 |
|
|
+ COMPARE s2, s1
|
350 |
|
|
+ JUMP C, _LC00101
|
351 |
|
|
+ LOAD s2, 00
|
352 |
|
|
+ COMPARE s2, s0
|
353 |
|
|
+ JUMP C, _LC00101
|
354 |
|
|
+ JUMP _L00119
|
355 |
|
|
+_LC00101:
|
356 |
|
|
+ ; test10.c:13: for (j = 1; j <= i; j++)
|
357 |
|
|
+_L00116:
|
358 |
|
|
+ LOAD s2, 01
|
359 |
|
|
+ LOAD s3, 00
|
360 |
|
|
+_L00103:
|
361 |
|
|
+ COMPARE s1, s3
|
362 |
|
|
+ JUMP C, _L00118
|
363 |
|
|
+ COMPARE s0, s2
|
364 |
|
|
+ JUMP C, _L00118
|
365 |
|
|
+ ; test10.c:15: if (numbers[j-1] > numbers[j])
|
366 |
|
|
+ LOAD s4, _numbers_19
|
367 |
|
|
+ LOAD s5, s2
|
368 |
|
|
+ SUB s5, 01
|
369 |
|
|
+ SL0 s5
|
370 |
|
|
+ ADD s4, s5
|
371 |
|
|
+ FETCH s6, (s4)
|
372 |
|
|
+ ADD s4, 01
|
373 |
|
|
+ FETCH s7, (s4)
|
374 |
|
|
+ LOAD s4, _numbers_19
|
375 |
|
|
+ LOAD s8, s2
|
376 |
|
|
+ LOAD s9, s3
|
377 |
|
|
+ SL0 s8
|
378 |
|
|
+ SLA s9
|
379 |
|
|
+ ADD s4, s8
|
380 |
|
|
+ FETCH sA, (s4)
|
381 |
|
|
+ ADD s4, 01
|
382 |
|
|
+ STORE s8, 14
|
383 |
|
|
+ FETCH s8, (s4)
|
384 |
|
|
+ COMPARE sA, s6
|
385 |
|
|
+ JUMP C, _LC00102
|
386 |
|
|
+ COMPARE s8, s7
|
387 |
|
|
+ JUMP C, _LC00102
|
388 |
|
|
+ JUMP _L00105
|
389 |
|
|
+_LC00102:
|
390 |
|
|
+ ; test10.c:17: temp = numbers[j-1];
|
391 |
|
|
+ LOAD s4, _numbers_19
|
392 |
|
|
+ ADD s4, s5
|
393 |
|
|
+ FETCH s6, (s4)
|
394 |
|
|
+ ADD s4, 01
|
395 |
|
|
+ FETCH s7, (s4)
|
396 |
|
|
+ LOAD s4, s7
|
397 |
|
|
+ LOAD s8, s6
|
398 |
|
|
+ ; test10.c:18: numbers[j-1] = numbers[j];
|
399 |
|
|
+ LOAD s6, _numbers_19
|
400 |
|
|
+ ADD s6, s5
|
401 |
|
|
+ LOAD s5, _numbers_19
|
402 |
|
|
+ FETCH s7, 14
|
403 |
|
|
+ ADD s5, s7
|
404 |
|
|
+ FETCH sA, (s5)
|
405 |
|
|
+ ADD s5, 01
|
406 |
|
|
+ STORE s4, 14
|
407 |
|
|
+ FETCH s4, (s5)
|
408 |
|
|
+ STORE sA, (s6)
|
409 |
|
|
+ ADD s6, 01
|
410 |
|
|
+ STORE s4, (s6)
|
411 |
|
|
+ ; test10.c:19: numbers[j] = temp;
|
412 |
|
|
+ LOAD s4, _numbers_19
|
413 |
|
|
+ ADD s4, s7
|
414 |
|
|
+ STORE s8, (s4)
|
415 |
|
|
+ ADD s4, 01
|
416 |
|
|
+ FETCH s5, 14
|
417 |
|
|
+ STORE s5, (s4)
|
418 |
|
|
+_L00105:
|
419 |
|
|
+ ; test10.c:13: for (j = 1; j <= i; j++)
|
420 |
|
|
+ ADD s2, 01
|
421 |
|
|
+ ADDCY s3, 00
|
422 |
|
|
+ JUMP _L00103
|
423 |
|
|
+_L00118:
|
424 |
|
|
+_L00109:
|
425 |
|
|
+ ; test10.c:11: for (i = (ARRAY_SIZE - 1); i > 0; i--)
|
426 |
|
|
+ SUB s0, 01
|
427 |
|
|
+ SUBCY s1, 00
|
428 |
|
|
+ JUMP _L00107
|
429 |
|
|
+_L00119:
|
430 |
|
|
+_L00111:
|
431 |
|
|
+ RETURN
|
432 |
|
|
+;--------------------------------------------------------
|
433 |
|
|
+; interrupt vector
|
434 |
|
|
+;--------------------------------------------------------
|
435 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test10.pblazeide.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test10.pblazeide.psm
|
436 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test10.pblazeide.psm 1970-01-01 01:00:00.000000000 +0100
|
437 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test10.pblazeide.psm 2011-08-23 15:57:26.000000000 +0200
|
438 |
|
|
@@ -0,0 +1,213 @@
|
439 |
|
|
+;--------------------------------------------------------
|
440 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
441 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
442 |
|
|
+; This file was generated Fri Apr 22 14:08:53 2011
|
443 |
|
|
+;--------------------------------------------------------
|
444 |
|
|
+;--------------------------------------------------------
|
445 |
|
|
+; global & static initialisations
|
446 |
|
|
+;--------------------------------------------------------
|
447 |
|
|
+ _numbers_19 EQU $00
|
448 |
|
|
+ _numbers_18 EQU $01
|
449 |
|
|
+ _numbers_17 EQU $02
|
450 |
|
|
+ _numbers_16 EQU $03
|
451 |
|
|
+ _numbers_15 EQU $04
|
452 |
|
|
+ _numbers_14 EQU $05
|
453 |
|
|
+ _numbers_13 EQU $06
|
454 |
|
|
+ _numbers_12 EQU $07
|
455 |
|
|
+ _numbers_11 EQU $08
|
456 |
|
|
+ _numbers_10 EQU $09
|
457 |
|
|
+ _numbers_9 EQU $0a
|
458 |
|
|
+ _numbers_8 EQU $0b
|
459 |
|
|
+ _numbers_7 EQU $0c
|
460 |
|
|
+ _numbers_6 EQU $0d
|
461 |
|
|
+ _numbers_5 EQU $0e
|
462 |
|
|
+ _numbers_4 EQU $0f
|
463 |
|
|
+ _numbers_3 EQU $10
|
464 |
|
|
+ _numbers_2 EQU $11
|
465 |
|
|
+ _numbers_1 EQU $12
|
466 |
|
|
+ _numbers_0 EQU $13
|
467 |
|
|
+
|
468 |
|
|
+;------------------------------------------------------------
|
469 |
|
|
+;Allocation info for local variables in function 'main'
|
470 |
|
|
+;------------------------------------------------------------
|
471 |
|
|
+;------------------------------------------------------------
|
472 |
|
|
+ ; test10.c:5: volatile short numbers[ARRAY_SIZE] = {9,8,7,6,5,4,3,2,1,0};
|
473 |
|
|
+ LOAD s0, _numbers_19
|
474 |
|
|
+ LOAD s1, $00
|
475 |
|
|
+ STORE s1, (s0)
|
476 |
|
|
+ ADD s0, $01
|
477 |
|
|
+ LOAD s1, $09
|
478 |
|
|
+ STORE s1, (s0)
|
479 |
|
|
+ LOAD s0, _numbers_19
|
480 |
|
|
+ ADD s0, $02
|
481 |
|
|
+ LOAD s1, $00
|
482 |
|
|
+ STORE s1, (s0)
|
483 |
|
|
+ ADD s0, $01
|
484 |
|
|
+ LOAD s1, $08
|
485 |
|
|
+ STORE s1, (s0)
|
486 |
|
|
+ LOAD s0, _numbers_19
|
487 |
|
|
+ ADD s0, $04
|
488 |
|
|
+ LOAD s1, $00
|
489 |
|
|
+ STORE s1, (s0)
|
490 |
|
|
+ ADD s0, $01
|
491 |
|
|
+ LOAD s1, $07
|
492 |
|
|
+ STORE s1, (s0)
|
493 |
|
|
+ LOAD s0, _numbers_19
|
494 |
|
|
+ ADD s0, $06
|
495 |
|
|
+ LOAD s1, $00
|
496 |
|
|
+ STORE s1, (s0)
|
497 |
|
|
+ ADD s0, $01
|
498 |
|
|
+ LOAD s1, $06
|
499 |
|
|
+ STORE s1, (s0)
|
500 |
|
|
+ LOAD s0, _numbers_19
|
501 |
|
|
+ ADD s0, $08
|
502 |
|
|
+ LOAD s1, $00
|
503 |
|
|
+ STORE s1, (s0)
|
504 |
|
|
+ ADD s0, $01
|
505 |
|
|
+ LOAD s1, $05
|
506 |
|
|
+ STORE s1, (s0)
|
507 |
|
|
+ LOAD s0, _numbers_19
|
508 |
|
|
+ ADD s0, $0a
|
509 |
|
|
+ LOAD s1, $00
|
510 |
|
|
+ STORE s1, (s0)
|
511 |
|
|
+ ADD s0, $01
|
512 |
|
|
+ LOAD s1, $04
|
513 |
|
|
+ STORE s1, (s0)
|
514 |
|
|
+ LOAD s0, _numbers_19
|
515 |
|
|
+ ADD s0, $0c
|
516 |
|
|
+ LOAD s1, $00
|
517 |
|
|
+ STORE s1, (s0)
|
518 |
|
|
+ ADD s0, $01
|
519 |
|
|
+ LOAD s1, $03
|
520 |
|
|
+ STORE s1, (s0)
|
521 |
|
|
+ LOAD s0, _numbers_19
|
522 |
|
|
+ ADD s0, $0e
|
523 |
|
|
+ LOAD s1, $00
|
524 |
|
|
+ STORE s1, (s0)
|
525 |
|
|
+ ADD s0, $01
|
526 |
|
|
+ LOAD s1, $02
|
527 |
|
|
+ STORE s1, (s0)
|
528 |
|
|
+ LOAD s0, _numbers_19
|
529 |
|
|
+ ADD s0, $10
|
530 |
|
|
+ LOAD s1, $00
|
531 |
|
|
+ STORE s1, (s0)
|
532 |
|
|
+ ADD s0, $01
|
533 |
|
|
+ LOAD s1, $01
|
534 |
|
|
+ STORE s1, (s0)
|
535 |
|
|
+ LOAD s0, _numbers_19
|
536 |
|
|
+ ADD s0, $12
|
537 |
|
|
+ LOAD s1, $00
|
538 |
|
|
+ STORE s1, (s0)
|
539 |
|
|
+ ADD s0, $01
|
540 |
|
|
+ LOAD s1, $00
|
541 |
|
|
+ STORE s1, (s0)
|
542 |
|
|
+ LOAD sF, $3f
|
543 |
|
|
+ JUMP __sdcc_program_startup
|
544 |
|
|
+;--------------------------------------------------------
|
545 |
|
|
+; Home
|
546 |
|
|
+;--------------------------------------------------------
|
547 |
|
|
+__sdcc_program_startup:
|
548 |
|
|
+ CALL _main
|
549 |
|
|
+; return from main will lock up
|
550 |
|
|
+__sdcc_loop:
|
551 |
|
|
+ JUMP __sdcc_loop
|
552 |
|
|
+;--------------------------------------------------------
|
553 |
|
|
+; code
|
554 |
|
|
+;--------------------------------------------------------
|
555 |
|
|
+;------------------------------------------------------------
|
556 |
|
|
+;Allocation info for local variables in function 'main'
|
557 |
|
|
+;------------------------------------------------------------
|
558 |
|
|
+;------------------------------------------------------------
|
559 |
|
|
+_main:
|
560 |
|
|
+ ; test10.c:7: void main()
|
561 |
|
|
+ ; test10.c:11: for (i = (ARRAY_SIZE - 1); i > 0; i--)
|
562 |
|
|
+ LOAD s0, $09
|
563 |
|
|
+ LOAD s1, $00
|
564 |
|
|
+_L00107:
|
565 |
|
|
+ LOAD s2, $00
|
566 |
|
|
+ COMP s2, s1
|
567 |
|
|
+ JUMP C, _LC00101
|
568 |
|
|
+ LOAD s2, $00
|
569 |
|
|
+ COMP s2, s0
|
570 |
|
|
+ JUMP C, _LC00101
|
571 |
|
|
+ JUMP _L00119
|
572 |
|
|
+_LC00101:
|
573 |
|
|
+ ; test10.c:13: for (j = 1; j <= i; j++)
|
574 |
|
|
+_L00116:
|
575 |
|
|
+ LOAD s2, $01
|
576 |
|
|
+ LOAD s3, $00
|
577 |
|
|
+_L00103:
|
578 |
|
|
+ COMP s1, s3
|
579 |
|
|
+ JUMP C, _L00118
|
580 |
|
|
+ COMP s0, s2
|
581 |
|
|
+ JUMP C, _L00118
|
582 |
|
|
+ ; test10.c:15: if (numbers[j-1] > numbers[j])
|
583 |
|
|
+ LOAD s4, _numbers_19
|
584 |
|
|
+ LOAD s5, s2
|
585 |
|
|
+ SUB s5, $01
|
586 |
|
|
+ SL0 s5
|
587 |
|
|
+ ADD s4, s5
|
588 |
|
|
+ FETCH s6, (s4)
|
589 |
|
|
+ ADD s4, $01
|
590 |
|
|
+ FETCH s7, (s4)
|
591 |
|
|
+ LOAD s4, _numbers_19
|
592 |
|
|
+ LOAD s8, s2
|
593 |
|
|
+ LOAD s9, s3
|
594 |
|
|
+ SL0 s8
|
595 |
|
|
+ SLA s9
|
596 |
|
|
+ ADD s4, s8
|
597 |
|
|
+ FETCH sA, (s4)
|
598 |
|
|
+ ADD s4, $01
|
599 |
|
|
+ STORE s8, 14
|
600 |
|
|
+ FETCH s8, (s4)
|
601 |
|
|
+ COMP sA, s6
|
602 |
|
|
+ JUMP C, _LC00102
|
603 |
|
|
+ COMP s8, s7
|
604 |
|
|
+ JUMP C, _LC00102
|
605 |
|
|
+ JUMP _L00105
|
606 |
|
|
+_LC00102:
|
607 |
|
|
+ ; test10.c:17: temp = numbers[j-1];
|
608 |
|
|
+ LOAD s4, _numbers_19
|
609 |
|
|
+ ADD s4, s5
|
610 |
|
|
+ FETCH s6, (s4)
|
611 |
|
|
+ ADD s4, $01
|
612 |
|
|
+ FETCH s7, (s4)
|
613 |
|
|
+ LOAD s4, s7
|
614 |
|
|
+ LOAD s8, s6
|
615 |
|
|
+ ; test10.c:18: numbers[j-1] = numbers[j];
|
616 |
|
|
+ LOAD s6, _numbers_19
|
617 |
|
|
+ ADD s6, s5
|
618 |
|
|
+ LOAD s5, _numbers_19
|
619 |
|
|
+ FETCH s7, 14
|
620 |
|
|
+ ADD s5, s7
|
621 |
|
|
+ FETCH sA, (s5)
|
622 |
|
|
+ ADD s5, $01
|
623 |
|
|
+ STORE s4, 14
|
624 |
|
|
+ FETCH s4, (s5)
|
625 |
|
|
+ STORE sA, (s6)
|
626 |
|
|
+ ADD s6, $01
|
627 |
|
|
+ STORE s4, (s6)
|
628 |
|
|
+ ; test10.c:19: numbers[j] = temp;
|
629 |
|
|
+ LOAD s4, _numbers_19
|
630 |
|
|
+ ADD s4, s7
|
631 |
|
|
+ STORE s8, (s4)
|
632 |
|
|
+ ADD s4, $01
|
633 |
|
|
+ FETCH s5, 14
|
634 |
|
|
+ STORE s5, (s4)
|
635 |
|
|
+_L00105:
|
636 |
|
|
+ ; test10.c:13: for (j = 1; j <= i; j++)
|
637 |
|
|
+ ADD s2, $01
|
638 |
|
|
+ ADDC s3, $00
|
639 |
|
|
+ JUMP _L00103
|
640 |
|
|
+_L00118:
|
641 |
|
|
+_L00109:
|
642 |
|
|
+ ; test10.c:11: for (i = (ARRAY_SIZE - 1); i > 0; i--)
|
643 |
|
|
+ SUB s0, $01
|
644 |
|
|
+ SUBC s1, $00
|
645 |
|
|
+ JUMP _L00107
|
646 |
|
|
+_L00119:
|
647 |
|
|
+_L00111:
|
648 |
|
|
+ RET
|
649 |
|
|
+;--------------------------------------------------------
|
650 |
|
|
+; interrupt vector
|
651 |
|
|
+;--------------------------------------------------------
|
652 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test6.kcpsm.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test6.kcpsm.psm
|
653 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test6.kcpsm.psm 1970-01-01 01:00:00.000000000 +0100
|
654 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test6.kcpsm.psm 2011-08-23 15:57:26.000000000 +0200
|
655 |
|
|
@@ -0,0 +1,74 @@
|
656 |
|
|
+;--------------------------------------------------------
|
657 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
658 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
659 |
|
|
+; This file was generated Fri Apr 22 14:21:55 2011
|
660 |
|
|
+;--------------------------------------------------------
|
661 |
|
|
+;--------------------------------------------------------
|
662 |
|
|
+; global & static initialisations
|
663 |
|
|
+;--------------------------------------------------------
|
664 |
|
|
+ CONSTANT _val_0, 00
|
665 |
|
|
+ CONSTANT _c_0, 01
|
666 |
|
|
+
|
667 |
|
|
+;------------------------------------------------------------
|
668 |
|
|
+;Allocation info for local variables in function 'main'
|
669 |
|
|
+;------------------------------------------------------------
|
670 |
|
|
+;------------------------------------------------------------
|
671 |
|
|
+ ; test6.c:3: char __xdata val = 0;
|
672 |
|
|
+ LOAD s0, 00
|
673 |
|
|
+ STORE s0, _val_0
|
674 |
|
|
+ LOAD sF, 3f
|
675 |
|
|
+ JUMP __sdcc_program_startup
|
676 |
|
|
+;--------------------------------------------------------
|
677 |
|
|
+; Home
|
678 |
|
|
+;--------------------------------------------------------
|
679 |
|
|
+__sdcc_program_startup:
|
680 |
|
|
+ CALL _main
|
681 |
|
|
+; return from main will lock up
|
682 |
|
|
+__sdcc_loop:
|
683 |
|
|
+ JUMP __sdcc_loop
|
684 |
|
|
+;--------------------------------------------------------
|
685 |
|
|
+; code
|
686 |
|
|
+;--------------------------------------------------------
|
687 |
|
|
+;------------------------------------------------------------
|
688 |
|
|
+;Allocation info for local variables in function 'main'
|
689 |
|
|
+;------------------------------------------------------------
|
690 |
|
|
+;------------------------------------------------------------
|
691 |
|
|
+ ; test6.c:6: void interruptHandler() __interrupt
|
692 |
|
|
+interruptHandler:
|
693 |
|
|
+ ; test6.c:8: val++;
|
694 |
|
|
+ STORE s0, (sF)
|
695 |
|
|
+ SUB sF, 01
|
696 |
|
|
+ STORE s1, (sF)
|
697 |
|
|
+ SUB sF, 01
|
698 |
|
|
+ FETCH s1, _val_0
|
699 |
|
|
+ LOAD s0, s1
|
700 |
|
|
+ ADD s0, 01
|
701 |
|
|
+ ADD sF, 01
|
702 |
|
|
+ FETCH s1, (sF)
|
703 |
|
|
+ ADD sF, 01
|
704 |
|
|
+ FETCH s0, (sF)
|
705 |
|
|
+ STORE s0, _val_0
|
706 |
|
|
+ RETURNI ENABLE
|
707 |
|
|
+;------------------------------------------------------------
|
708 |
|
|
+;Allocation info for local variables in function 'main'
|
709 |
|
|
+;------------------------------------------------------------
|
710 |
|
|
+;------------------------------------------------------------
|
711 |
|
|
+_main:
|
712 |
|
|
+ ; test6.c:11: void main()
|
713 |
|
|
+ ; test6.c:13: c = 0;
|
714 |
|
|
+ LOAD s0, 00
|
715 |
|
|
+ ; test6.c:16: __endasm;
|
716 |
|
|
+ EINT
|
717 |
|
|
+_L00106:
|
718 |
|
|
+_L00102:
|
719 |
|
|
+ ; test6.c:20: c += 4;
|
720 |
|
|
+ ADD s0, 04
|
721 |
|
|
+ JUMP _L00102
|
722 |
|
|
+_L00104:
|
723 |
|
|
+ STORE s0, _c_0
|
724 |
|
|
+ RETURN
|
725 |
|
|
+;--------------------------------------------------------
|
726 |
|
|
+; interrupt vector
|
727 |
|
|
+;--------------------------------------------------------
|
728 |
|
|
+ ADDRESS 3ff
|
729 |
|
|
+ JUMP interruptHandler
|
730 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test6.pblazeide.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test6.pblazeide.psm
|
731 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test6.pblazeide.psm 1970-01-01 01:00:00.000000000 +0100
|
732 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test6.pblazeide.psm 2011-08-23 15:57:26.000000000 +0200
|
733 |
|
|
@@ -0,0 +1,74 @@
|
734 |
|
|
+;--------------------------------------------------------
|
735 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
736 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
737 |
|
|
+; This file was generated Fri Apr 22 14:22:57 2011
|
738 |
|
|
+;--------------------------------------------------------
|
739 |
|
|
+;--------------------------------------------------------
|
740 |
|
|
+; global & static initialisations
|
741 |
|
|
+;--------------------------------------------------------
|
742 |
|
|
+ _val_0 EQU $00
|
743 |
|
|
+ _c_0 EQU $01
|
744 |
|
|
+
|
745 |
|
|
+;------------------------------------------------------------
|
746 |
|
|
+;Allocation info for local variables in function 'main'
|
747 |
|
|
+;------------------------------------------------------------
|
748 |
|
|
+;------------------------------------------------------------
|
749 |
|
|
+ ; test6.c:3: char __xdata val = 0;
|
750 |
|
|
+ LOAD s0, $00
|
751 |
|
|
+ STORE s0, _val_0
|
752 |
|
|
+ LOAD sF, $3f
|
753 |
|
|
+ JUMP __sdcc_program_startup
|
754 |
|
|
+;--------------------------------------------------------
|
755 |
|
|
+; Home
|
756 |
|
|
+;--------------------------------------------------------
|
757 |
|
|
+__sdcc_program_startup:
|
758 |
|
|
+ CALL _main
|
759 |
|
|
+; return from main will lock up
|
760 |
|
|
+__sdcc_loop:
|
761 |
|
|
+ JUMP __sdcc_loop
|
762 |
|
|
+;--------------------------------------------------------
|
763 |
|
|
+; code
|
764 |
|
|
+;--------------------------------------------------------
|
765 |
|
|
+;------------------------------------------------------------
|
766 |
|
|
+;Allocation info for local variables in function 'main'
|
767 |
|
|
+;------------------------------------------------------------
|
768 |
|
|
+;------------------------------------------------------------
|
769 |
|
|
+ ; test6.c:6: void interruptHandler() __interrupt
|
770 |
|
|
+interruptHandler:
|
771 |
|
|
+ ; test6.c:8: val++;
|
772 |
|
|
+ STORE s0, (sF)
|
773 |
|
|
+ SUB sF, $01
|
774 |
|
|
+ STORE s1, (sF)
|
775 |
|
|
+ SUB sF, $01
|
776 |
|
|
+ FETCH s1, _val_0
|
777 |
|
|
+ LOAD s0, s1
|
778 |
|
|
+ ADD s0, $01
|
779 |
|
|
+ ADD sF, $01
|
780 |
|
|
+ FETCH s1, (sF)
|
781 |
|
|
+ ADD sF, $01
|
782 |
|
|
+ FETCH s0, (sF)
|
783 |
|
|
+ STORE s0, _val_0
|
784 |
|
|
+ RETI ENABLE
|
785 |
|
|
+;------------------------------------------------------------
|
786 |
|
|
+;Allocation info for local variables in function 'main'
|
787 |
|
|
+;------------------------------------------------------------
|
788 |
|
|
+;------------------------------------------------------------
|
789 |
|
|
+_main:
|
790 |
|
|
+ ; test6.c:11: void main()
|
791 |
|
|
+ ; test6.c:13: c = 0;
|
792 |
|
|
+ LOAD s0, $00
|
793 |
|
|
+ ; test6.c:16: __endasm;
|
794 |
|
|
+ EINT
|
795 |
|
|
+_L00106:
|
796 |
|
|
+_L00102:
|
797 |
|
|
+ ; test6.c:20: c += 4;
|
798 |
|
|
+ ADD s0, $04
|
799 |
|
|
+ JUMP _L00102
|
800 |
|
|
+_L00104:
|
801 |
|
|
+ STORE s0, _c_0
|
802 |
|
|
+ RET
|
803 |
|
|
+;--------------------------------------------------------
|
804 |
|
|
+; interrupt vector
|
805 |
|
|
+;--------------------------------------------------------
|
806 |
|
|
+ ORG $3ff
|
807 |
|
|
+ JUMP interruptHandler
|
808 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test7.kcpsm.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test7.kcpsm.psm
|
809 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test7.kcpsm.psm 1970-01-01 01:00:00.000000000 +0100
|
810 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test7.kcpsm.psm 2011-08-23 15:57:26.000000000 +0200
|
811 |
|
|
@@ -0,0 +1,149 @@
|
812 |
|
|
+;--------------------------------------------------------
|
813 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
814 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
815 |
|
|
+; This file was generated Fri Apr 22 14:05:13 2011
|
816 |
|
|
+;--------------------------------------------------------
|
817 |
|
|
+;--------------------------------------------------------
|
818 |
|
|
+; global & static initialisations
|
819 |
|
|
+;--------------------------------------------------------
|
820 |
|
|
+ CONSTANT _main_c_1_1_0, 00
|
821 |
|
|
+ CONSTANT _main_d_1_1_0, 01
|
822 |
|
|
+ CONSTANT _main_e_1_1_0, 02
|
823 |
|
|
+
|
824 |
|
|
+ LOAD sF, 3f
|
825 |
|
|
+ JUMP __sdcc_program_startup
|
826 |
|
|
+;--------------------------------------------------------
|
827 |
|
|
+; Home
|
828 |
|
|
+;--------------------------------------------------------
|
829 |
|
|
+__sdcc_program_startup:
|
830 |
|
|
+ CALL _main
|
831 |
|
|
+; return from main will lock up
|
832 |
|
|
+__sdcc_loop:
|
833 |
|
|
+ JUMP __sdcc_loop
|
834 |
|
|
+;--------------------------------------------------------
|
835 |
|
|
+; code
|
836 |
|
|
+;--------------------------------------------------------
|
837 |
|
|
+;------------------------------------------------------------
|
838 |
|
|
+;Allocation info for local variables in function 'main'
|
839 |
|
|
+;------------------------------------------------------------
|
840 |
|
|
+;------------------------------------------------------------
|
841 |
|
|
+_main:
|
842 |
|
|
+ ; test7.c:3: void main()
|
843 |
|
|
+ ; test7.c:5: volatile unsigned char c = 1;
|
844 |
|
|
+ LOAD s0, 01
|
845 |
|
|
+ STORE s0, _main_c_1_1_0
|
846 |
|
|
+ ; test7.c:6: volatile unsigned char d = 1;
|
847 |
|
|
+ LOAD s0, 01
|
848 |
|
|
+ STORE s0, _main_d_1_1_0
|
849 |
|
|
+ ; test7.c:7: volatile unsigned char e = 15;
|
850 |
|
|
+ LOAD s0, 0f
|
851 |
|
|
+ STORE s0, _main_e_1_1_0
|
852 |
|
|
+ ; test7.c:9: c <<= 4;
|
853 |
|
|
+ FETCH s0, _main_c_1_1_0
|
854 |
|
|
+ SL0 s0
|
855 |
|
|
+ SL0 s0
|
856 |
|
|
+ SL0 s0
|
857 |
|
|
+ SL0 s0
|
858 |
|
|
+ STORE s0, _main_c_1_1_0
|
859 |
|
|
+ ; test7.c:11: c >>= 3;
|
860 |
|
|
+ FETCH s0, _main_c_1_1_0
|
861 |
|
|
+ SR0 s0
|
862 |
|
|
+ SR0 s0
|
863 |
|
|
+ SR0 s0
|
864 |
|
|
+ STORE s0, _main_c_1_1_0
|
865 |
|
|
+ ; test7.c:13: c |= c;
|
866 |
|
|
+ FETCH s0, _main_c_1_1_0
|
867 |
|
|
+ FETCH s1, _main_c_1_1_0
|
868 |
|
|
+ OR s1, s0
|
869 |
|
|
+ STORE s1, _main_c_1_1_0
|
870 |
|
|
+ ; test7.c:15: c |= d + 1;
|
871 |
|
|
+ FETCH s0, _main_d_1_1_0
|
872 |
|
|
+ ADD s0, 01
|
873 |
|
|
+ FETCH s1, _main_c_1_1_0
|
874 |
|
|
+ OR s1, s0
|
875 |
|
|
+ STORE s1, _main_c_1_1_0
|
876 |
|
|
+ ; test7.c:17: c = c & d;
|
877 |
|
|
+ FETCH s0, _main_c_1_1_0
|
878 |
|
|
+ FETCH s1, _main_d_1_1_0
|
879 |
|
|
+ AND s0, s1
|
880 |
|
|
+ STORE s0, _main_c_1_1_0
|
881 |
|
|
+ ; test7.c:19: d = ~e;
|
882 |
|
|
+ FETCH s0, _main_e_1_1_0
|
883 |
|
|
+ XOR s0, ff
|
884 |
|
|
+ STORE s0, _main_d_1_1_0
|
885 |
|
|
+ ; test7.c:21: e = c ^ d;
|
886 |
|
|
+ FETCH s0, _main_d_1_1_0
|
887 |
|
|
+ FETCH s1, _main_c_1_1_0
|
888 |
|
|
+ XOR s1, s0
|
889 |
|
|
+ STORE s1, _main_e_1_1_0
|
890 |
|
|
+ ; test7.c:23: c = !c && d || e;
|
891 |
|
|
+ FETCH s0, _main_c_1_1_0
|
892 |
|
|
+ LOAD s1, 00
|
893 |
|
|
+ COMPARE s0, 00
|
894 |
|
|
+ JUMP NZ, _LC00101
|
895 |
|
|
+ LOAD s1, 01
|
896 |
|
|
+_LC00101:
|
897 |
|
|
+ COMPARE s1, 00
|
898 |
|
|
+ JUMP NZ, _LC00102
|
899 |
|
|
+ JUMP _L00108
|
900 |
|
|
+_LC00102:
|
901 |
|
|
+ FETCH s0, _main_d_1_1_0
|
902 |
|
|
+ COMPARE s0, 00
|
903 |
|
|
+ JUMP Z, _LC00103
|
904 |
|
|
+ JUMP _L00109
|
905 |
|
|
+_LC00103:
|
906 |
|
|
+_L00108:
|
907 |
|
|
+ LOAD s0, 00
|
908 |
|
|
+ JUMP _L00110
|
909 |
|
|
+_L00109:
|
910 |
|
|
+ LOAD s0, 01
|
911 |
|
|
+_L00110:
|
912 |
|
|
+ COMPARE s0, 00
|
913 |
|
|
+ JUMP Z, _LC00104
|
914 |
|
|
+ JUMP _L00106
|
915 |
|
|
+_LC00104:
|
916 |
|
|
+ FETCH s0, _main_e_1_1_0
|
917 |
|
|
+ COMPARE s0, 00
|
918 |
|
|
+ JUMP Z, _LC00105
|
919 |
|
|
+ JUMP _L00106
|
920 |
|
|
+_LC00105:
|
921 |
|
|
+ LOAD s0, 00
|
922 |
|
|
+ JUMP _L00107
|
923 |
|
|
+_L00106:
|
924 |
|
|
+ LOAD s0, 01
|
925 |
|
|
+_L00107:
|
926 |
|
|
+ STORE s0, _main_c_1_1_0
|
927 |
|
|
+ ; test7.c:24: c = c || e;
|
928 |
|
|
+ FETCH s0, _main_c_1_1_0
|
929 |
|
|
+ COMPARE s0, 00
|
930 |
|
|
+ JUMP Z, _LC00106
|
931 |
|
|
+ JUMP _L00112
|
932 |
|
|
+_LC00106:
|
933 |
|
|
+ FETCH s0, _main_e_1_1_0
|
934 |
|
|
+ COMPARE s0, 00
|
935 |
|
|
+ JUMP Z, _LC00107
|
936 |
|
|
+ JUMP _L00112
|
937 |
|
|
+_LC00107:
|
938 |
|
|
+ LOAD s0, 00
|
939 |
|
|
+ JUMP _L00113
|
940 |
|
|
+_L00112:
|
941 |
|
|
+ LOAD s0, 01
|
942 |
|
|
+_L00113:
|
943 |
|
|
+ STORE s0, _main_c_1_1_0
|
944 |
|
|
+ ; test7.c:26: if (!c)
|
945 |
|
|
+ FETCH s0, _main_c_1_1_0
|
946 |
|
|
+ COMPARE s0, 00
|
947 |
|
|
+ JUMP Z, _LC00108
|
948 |
|
|
+ JUMP _L00103
|
949 |
|
|
+_LC00108:
|
950 |
|
|
+ ; test7.c:28: c = -e;
|
951 |
|
|
+ FETCH s0, _main_e_1_1_0
|
952 |
|
|
+ LOAD s1, s0
|
953 |
|
|
+ XOR s1, ff
|
954 |
|
|
+ ADD s1, 01
|
955 |
|
|
+ STORE s1, _main_c_1_1_0
|
956 |
|
|
+_L00103:
|
957 |
|
|
+ RETURN
|
958 |
|
|
+;--------------------------------------------------------
|
959 |
|
|
+; interrupt vector
|
960 |
|
|
+;--------------------------------------------------------
|
961 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test7.pblazeide.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test7.pblazeide.psm
|
962 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test7.pblazeide.psm 1970-01-01 01:00:00.000000000 +0100
|
963 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test7.pblazeide.psm 2011-08-23 15:57:26.000000000 +0200
|
964 |
|
|
@@ -0,0 +1,149 @@
|
965 |
|
|
+;--------------------------------------------------------
|
966 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
967 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
968 |
|
|
+; This file was generated Fri Apr 22 14:09:05 2011
|
969 |
|
|
+;--------------------------------------------------------
|
970 |
|
|
+;--------------------------------------------------------
|
971 |
|
|
+; global & static initialisations
|
972 |
|
|
+;--------------------------------------------------------
|
973 |
|
|
+ _main_c_1_1_0 EQU $00
|
974 |
|
|
+ _main_d_1_1_0 EQU $01
|
975 |
|
|
+ _main_e_1_1_0 EQU $02
|
976 |
|
|
+
|
977 |
|
|
+ LOAD sF, $3f
|
978 |
|
|
+ JUMP __sdcc_program_startup
|
979 |
|
|
+;--------------------------------------------------------
|
980 |
|
|
+; Home
|
981 |
|
|
+;--------------------------------------------------------
|
982 |
|
|
+__sdcc_program_startup:
|
983 |
|
|
+ CALL _main
|
984 |
|
|
+; return from main will lock up
|
985 |
|
|
+__sdcc_loop:
|
986 |
|
|
+ JUMP __sdcc_loop
|
987 |
|
|
+;--------------------------------------------------------
|
988 |
|
|
+; code
|
989 |
|
|
+;--------------------------------------------------------
|
990 |
|
|
+;------------------------------------------------------------
|
991 |
|
|
+;Allocation info for local variables in function 'main'
|
992 |
|
|
+;------------------------------------------------------------
|
993 |
|
|
+;------------------------------------------------------------
|
994 |
|
|
+_main:
|
995 |
|
|
+ ; test7.c:3: void main()
|
996 |
|
|
+ ; test7.c:5: volatile unsigned char c = 1;
|
997 |
|
|
+ LOAD s0, $01
|
998 |
|
|
+ STORE s0, _main_c_1_1_0
|
999 |
|
|
+ ; test7.c:6: volatile unsigned char d = 1;
|
1000 |
|
|
+ LOAD s0, $01
|
1001 |
|
|
+ STORE s0, _main_d_1_1_0
|
1002 |
|
|
+ ; test7.c:7: volatile unsigned char e = 15;
|
1003 |
|
|
+ LOAD s0, $0f
|
1004 |
|
|
+ STORE s0, _main_e_1_1_0
|
1005 |
|
|
+ ; test7.c:9: c <<= 4;
|
1006 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1007 |
|
|
+ SL0 s0
|
1008 |
|
|
+ SL0 s0
|
1009 |
|
|
+ SL0 s0
|
1010 |
|
|
+ SL0 s0
|
1011 |
|
|
+ STORE s0, _main_c_1_1_0
|
1012 |
|
|
+ ; test7.c:11: c >>= 3;
|
1013 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1014 |
|
|
+ SR0 s0
|
1015 |
|
|
+ SR0 s0
|
1016 |
|
|
+ SR0 s0
|
1017 |
|
|
+ STORE s0, _main_c_1_1_0
|
1018 |
|
|
+ ; test7.c:13: c |= c;
|
1019 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1020 |
|
|
+ FETCH s1, _main_c_1_1_0
|
1021 |
|
|
+ OR s1, s0
|
1022 |
|
|
+ STORE s1, _main_c_1_1_0
|
1023 |
|
|
+ ; test7.c:15: c |= d + 1;
|
1024 |
|
|
+ FETCH s0, _main_d_1_1_0
|
1025 |
|
|
+ ADD s0, $01
|
1026 |
|
|
+ FETCH s1, _main_c_1_1_0
|
1027 |
|
|
+ OR s1, s0
|
1028 |
|
|
+ STORE s1, _main_c_1_1_0
|
1029 |
|
|
+ ; test7.c:17: c = c & d;
|
1030 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1031 |
|
|
+ FETCH s1, _main_d_1_1_0
|
1032 |
|
|
+ AND s0, s1
|
1033 |
|
|
+ STORE s0, _main_c_1_1_0
|
1034 |
|
|
+ ; test7.c:19: d = ~e;
|
1035 |
|
|
+ FETCH s0, _main_e_1_1_0
|
1036 |
|
|
+ XOR s0, $ff
|
1037 |
|
|
+ STORE s0, _main_d_1_1_0
|
1038 |
|
|
+ ; test7.c:21: e = c ^ d;
|
1039 |
|
|
+ FETCH s0, _main_d_1_1_0
|
1040 |
|
|
+ FETCH s1, _main_c_1_1_0
|
1041 |
|
|
+ XOR s1, s0
|
1042 |
|
|
+ STORE s1, _main_e_1_1_0
|
1043 |
|
|
+ ; test7.c:23: c = !c && d || e;
|
1044 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1045 |
|
|
+ LOAD s1, $00
|
1046 |
|
|
+ COMP s0, $00
|
1047 |
|
|
+ JUMP NZ, _LC00101
|
1048 |
|
|
+ LOAD s1, $01
|
1049 |
|
|
+_LC00101:
|
1050 |
|
|
+ COMP s1, $00
|
1051 |
|
|
+ JUMP NZ, _LC00102
|
1052 |
|
|
+ JUMP _L00108
|
1053 |
|
|
+_LC00102:
|
1054 |
|
|
+ FETCH s0, _main_d_1_1_0
|
1055 |
|
|
+ COMP s0, $00
|
1056 |
|
|
+ JUMP Z, _LC00103
|
1057 |
|
|
+ JUMP _L00109
|
1058 |
|
|
+_LC00103:
|
1059 |
|
|
+_L00108:
|
1060 |
|
|
+ LOAD s0, $00
|
1061 |
|
|
+ JUMP _L00110
|
1062 |
|
|
+_L00109:
|
1063 |
|
|
+ LOAD s0, $01
|
1064 |
|
|
+_L00110:
|
1065 |
|
|
+ COMP s0, $00
|
1066 |
|
|
+ JUMP Z, _LC00104
|
1067 |
|
|
+ JUMP _L00106
|
1068 |
|
|
+_LC00104:
|
1069 |
|
|
+ FETCH s0, _main_e_1_1_0
|
1070 |
|
|
+ COMP s0, $00
|
1071 |
|
|
+ JUMP Z, _LC00105
|
1072 |
|
|
+ JUMP _L00106
|
1073 |
|
|
+_LC00105:
|
1074 |
|
|
+ LOAD s0, $00
|
1075 |
|
|
+ JUMP _L00107
|
1076 |
|
|
+_L00106:
|
1077 |
|
|
+ LOAD s0, $01
|
1078 |
|
|
+_L00107:
|
1079 |
|
|
+ STORE s0, _main_c_1_1_0
|
1080 |
|
|
+ ; test7.c:24: c = c || e;
|
1081 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1082 |
|
|
+ COMP s0, $00
|
1083 |
|
|
+ JUMP Z, _LC00106
|
1084 |
|
|
+ JUMP _L00112
|
1085 |
|
|
+_LC00106:
|
1086 |
|
|
+ FETCH s0, _main_e_1_1_0
|
1087 |
|
|
+ COMP s0, $00
|
1088 |
|
|
+ JUMP Z, _LC00107
|
1089 |
|
|
+ JUMP _L00112
|
1090 |
|
|
+_LC00107:
|
1091 |
|
|
+ LOAD s0, $00
|
1092 |
|
|
+ JUMP _L00113
|
1093 |
|
|
+_L00112:
|
1094 |
|
|
+ LOAD s0, $01
|
1095 |
|
|
+_L00113:
|
1096 |
|
|
+ STORE s0, _main_c_1_1_0
|
1097 |
|
|
+ ; test7.c:26: if (!c)
|
1098 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1099 |
|
|
+ COMP s0, $00
|
1100 |
|
|
+ JUMP Z, _LC00108
|
1101 |
|
|
+ JUMP _L00103
|
1102 |
|
|
+_LC00108:
|
1103 |
|
|
+ ; test7.c:28: c = -e;
|
1104 |
|
|
+ FETCH s0, _main_e_1_1_0
|
1105 |
|
|
+ LOAD s1, s0
|
1106 |
|
|
+ XOR s1, $ff
|
1107 |
|
|
+ ADD s1, $01
|
1108 |
|
|
+ STORE s1, _main_c_1_1_0
|
1109 |
|
|
+_L00103:
|
1110 |
|
|
+ RET
|
1111 |
|
|
+;--------------------------------------------------------
|
1112 |
|
|
+; interrupt vector
|
1113 |
|
|
+;--------------------------------------------------------
|
1114 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test8.kcpsm.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test8.kcpsm.psm
|
1115 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test8.kcpsm.psm 1970-01-01 01:00:00.000000000 +0100
|
1116 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test8.kcpsm.psm 2011-08-23 15:57:26.000000000 +0200
|
1117 |
|
|
@@ -0,0 +1,144 @@
|
1118 |
|
|
+;--------------------------------------------------------
|
1119 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
1120 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
1121 |
|
|
+; This file was generated Fri Apr 22 14:05:58 2011
|
1122 |
|
|
+;--------------------------------------------------------
|
1123 |
|
|
+;--------------------------------------------------------
|
1124 |
|
|
+; global & static initialisations
|
1125 |
|
|
+;--------------------------------------------------------
|
1126 |
|
|
+ CONSTANT _main_c_1_1_0, 00
|
1127 |
|
|
+
|
1128 |
|
|
+ LOAD sF, 3f
|
1129 |
|
|
+ JUMP __sdcc_program_startup
|
1130 |
|
|
+;--------------------------------------------------------
|
1131 |
|
|
+; Home
|
1132 |
|
|
+;--------------------------------------------------------
|
1133 |
|
|
+__sdcc_program_startup:
|
1134 |
|
|
+ CALL _main
|
1135 |
|
|
+; return from main will lock up
|
1136 |
|
|
+__sdcc_loop:
|
1137 |
|
|
+ JUMP __sdcc_loop
|
1138 |
|
|
+;--------------------------------------------------------
|
1139 |
|
|
+; code
|
1140 |
|
|
+;--------------------------------------------------------
|
1141 |
|
|
+;------------------------------------------------------------
|
1142 |
|
|
+;Allocation info for local variables in function 'main'
|
1143 |
|
|
+;------------------------------------------------------------
|
1144 |
|
|
+;------------------------------------------------------------
|
1145 |
|
|
+_main:
|
1146 |
|
|
+ ; test8.c:3: void main()
|
1147 |
|
|
+ ; test8.c:5: volatile char c = 5;
|
1148 |
|
|
+ LOAD s0, 05
|
1149 |
|
|
+ STORE s0, _main_c_1_1_0
|
1150 |
|
|
+ ; test8.c:8: switch(c)
|
1151 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1152 |
|
|
+ COMPARE s0, 0a
|
1153 |
|
|
+ JUMP NZ, _LC00101
|
1154 |
|
|
+ JUMP _L00101
|
1155 |
|
|
+_LC00101:
|
1156 |
|
|
+ COMPARE s0, 0b
|
1157 |
|
|
+ JUMP NZ, _LC00102
|
1158 |
|
|
+ JUMP _L00102
|
1159 |
|
|
+_LC00102:
|
1160 |
|
|
+ COMPARE s0, 0c
|
1161 |
|
|
+ JUMP NZ, _LC00103
|
1162 |
|
|
+ JUMP _L00103
|
1163 |
|
|
+_LC00103:
|
1164 |
|
|
+ COMPARE s0, 0d
|
1165 |
|
|
+ JUMP NZ, _LC00104
|
1166 |
|
|
+ JUMP _L00104
|
1167 |
|
|
+_LC00104:
|
1168 |
|
|
+ COMPARE s0, 0e
|
1169 |
|
|
+ JUMP NZ, _LC00105
|
1170 |
|
|
+ JUMP _L00105
|
1171 |
|
|
+_LC00105:
|
1172 |
|
|
+ JUMP _L00106
|
1173 |
|
|
+ ; test8.c:10: case 10: c = 11; break;
|
1174 |
|
|
+_L00101:
|
1175 |
|
|
+ LOAD s0, 0b
|
1176 |
|
|
+ STORE s0, _main_c_1_1_0
|
1177 |
|
|
+ JUMP _L00107
|
1178 |
|
|
+ ; test8.c:11: case 11: c = 22; break;
|
1179 |
|
|
+_L00102:
|
1180 |
|
|
+ LOAD s0, 16
|
1181 |
|
|
+ STORE s0, _main_c_1_1_0
|
1182 |
|
|
+ JUMP _L00107
|
1183 |
|
|
+ ; test8.c:12: case 12: c = 33; break;
|
1184 |
|
|
+_L00103:
|
1185 |
|
|
+ LOAD s0, 21
|
1186 |
|
|
+ STORE s0, _main_c_1_1_0
|
1187 |
|
|
+ JUMP _L00107
|
1188 |
|
|
+ ; test8.c:13: case 13: c = 44; break;
|
1189 |
|
|
+_L00104:
|
1190 |
|
|
+ LOAD s0, 2c
|
1191 |
|
|
+ STORE s0, _main_c_1_1_0
|
1192 |
|
|
+ JUMP _L00107
|
1193 |
|
|
+ ; test8.c:14: case 14: c = 55; break;
|
1194 |
|
|
+_L00105:
|
1195 |
|
|
+ LOAD s0, 37
|
1196 |
|
|
+ STORE s0, _main_c_1_1_0
|
1197 |
|
|
+ JUMP _L00107
|
1198 |
|
|
+ ; test8.c:15: default: c = 99;
|
1199 |
|
|
+_L00106:
|
1200 |
|
|
+ LOAD s0, 63
|
1201 |
|
|
+ STORE s0, _main_c_1_1_0
|
1202 |
|
|
+ ; test8.c:17: }
|
1203 |
|
|
+_L00107:
|
1204 |
|
|
+ ; test8.c:20: switch(c)
|
1205 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1206 |
|
|
+ COMPARE s0, 04
|
1207 |
|
|
+ JUMP NZ, _LC00106
|
1208 |
|
|
+ JUMP _L00111
|
1209 |
|
|
+_LC00106:
|
1210 |
|
|
+ COMPARE s0, 0a
|
1211 |
|
|
+ JUMP NZ, _LC00107
|
1212 |
|
|
+ JUMP _L00108
|
1213 |
|
|
+_LC00107:
|
1214 |
|
|
+ COMPARE s0, 17
|
1215 |
|
|
+ JUMP NZ, _LC00108
|
1216 |
|
|
+ JUMP _L00109
|
1217 |
|
|
+_LC00108:
|
1218 |
|
|
+ COMPARE s0, 1f
|
1219 |
|
|
+ JUMP NZ, _LC00109
|
1220 |
|
|
+ JUMP _L00110
|
1221 |
|
|
+_LC00109:
|
1222 |
|
|
+ COMPARE s0, 3b
|
1223 |
|
|
+ JUMP NZ, _LC00110
|
1224 |
|
|
+ JUMP _L00112
|
1225 |
|
|
+_LC00110:
|
1226 |
|
|
+ JUMP _L00113
|
1227 |
|
|
+ ; test8.c:22: case 10: c = 11; break;
|
1228 |
|
|
+_L00108:
|
1229 |
|
|
+ LOAD s0, 0b
|
1230 |
|
|
+ STORE s0, _main_c_1_1_0
|
1231 |
|
|
+ JUMP _L00115
|
1232 |
|
|
+ ; test8.c:23: case 23: c = 22; break;
|
1233 |
|
|
+_L00109:
|
1234 |
|
|
+ LOAD s0, 16
|
1235 |
|
|
+ STORE s0, _main_c_1_1_0
|
1236 |
|
|
+ JUMP _L00115
|
1237 |
|
|
+ ; test8.c:24: case 31: c = 33; break;
|
1238 |
|
|
+_L00110:
|
1239 |
|
|
+ LOAD s0, 21
|
1240 |
|
|
+ STORE s0, _main_c_1_1_0
|
1241 |
|
|
+ JUMP _L00115
|
1242 |
|
|
+ ; test8.c:25: case 4: c = 44; break;
|
1243 |
|
|
+_L00111:
|
1244 |
|
|
+ LOAD s0, 2c
|
1245 |
|
|
+ STORE s0, _main_c_1_1_0
|
1246 |
|
|
+ JUMP _L00115
|
1247 |
|
|
+ ; test8.c:26: case 59: c = 55; break;
|
1248 |
|
|
+_L00112:
|
1249 |
|
|
+ LOAD s0, 37
|
1250 |
|
|
+ STORE s0, _main_c_1_1_0
|
1251 |
|
|
+ JUMP _L00115
|
1252 |
|
|
+ ; test8.c:27: default: c = 99;
|
1253 |
|
|
+_L00113:
|
1254 |
|
|
+ LOAD s0, 63
|
1255 |
|
|
+ STORE s0, _main_c_1_1_0
|
1256 |
|
|
+ ; test8.c:29: }
|
1257 |
|
|
+_L00115:
|
1258 |
|
|
+ RETURN
|
1259 |
|
|
+;--------------------------------------------------------
|
1260 |
|
|
+; interrupt vector
|
1261 |
|
|
+;--------------------------------------------------------
|
1262 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test8.pblazeide.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test8.pblazeide.psm
|
1263 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test8.pblazeide.psm 1970-01-01 01:00:00.000000000 +0100
|
1264 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test8.pblazeide.psm 2011-08-23 15:57:26.000000000 +0200
|
1265 |
|
|
@@ -0,0 +1,144 @@
|
1266 |
|
|
+;--------------------------------------------------------
|
1267 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
1268 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
1269 |
|
|
+; This file was generated Fri Apr 22 14:09:02 2011
|
1270 |
|
|
+;--------------------------------------------------------
|
1271 |
|
|
+;--------------------------------------------------------
|
1272 |
|
|
+; global & static initialisations
|
1273 |
|
|
+;--------------------------------------------------------
|
1274 |
|
|
+ _main_c_1_1_0 EQU $00
|
1275 |
|
|
+
|
1276 |
|
|
+ LOAD sF, $3f
|
1277 |
|
|
+ JUMP __sdcc_program_startup
|
1278 |
|
|
+;--------------------------------------------------------
|
1279 |
|
|
+; Home
|
1280 |
|
|
+;--------------------------------------------------------
|
1281 |
|
|
+__sdcc_program_startup:
|
1282 |
|
|
+ CALL _main
|
1283 |
|
|
+; return from main will lock up
|
1284 |
|
|
+__sdcc_loop:
|
1285 |
|
|
+ JUMP __sdcc_loop
|
1286 |
|
|
+;--------------------------------------------------------
|
1287 |
|
|
+; code
|
1288 |
|
|
+;--------------------------------------------------------
|
1289 |
|
|
+;------------------------------------------------------------
|
1290 |
|
|
+;Allocation info for local variables in function 'main'
|
1291 |
|
|
+;------------------------------------------------------------
|
1292 |
|
|
+;------------------------------------------------------------
|
1293 |
|
|
+_main:
|
1294 |
|
|
+ ; test8.c:3: void main()
|
1295 |
|
|
+ ; test8.c:5: volatile char c = 5;
|
1296 |
|
|
+ LOAD s0, $05
|
1297 |
|
|
+ STORE s0, _main_c_1_1_0
|
1298 |
|
|
+ ; test8.c:8: switch(c)
|
1299 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1300 |
|
|
+ COMP s0, $0a
|
1301 |
|
|
+ JUMP NZ, _LC00101
|
1302 |
|
|
+ JUMP _L00101
|
1303 |
|
|
+_LC00101:
|
1304 |
|
|
+ COMP s0, $0b
|
1305 |
|
|
+ JUMP NZ, _LC00102
|
1306 |
|
|
+ JUMP _L00102
|
1307 |
|
|
+_LC00102:
|
1308 |
|
|
+ COMP s0, $0c
|
1309 |
|
|
+ JUMP NZ, _LC00103
|
1310 |
|
|
+ JUMP _L00103
|
1311 |
|
|
+_LC00103:
|
1312 |
|
|
+ COMP s0, $0d
|
1313 |
|
|
+ JUMP NZ, _LC00104
|
1314 |
|
|
+ JUMP _L00104
|
1315 |
|
|
+_LC00104:
|
1316 |
|
|
+ COMP s0, $0e
|
1317 |
|
|
+ JUMP NZ, _LC00105
|
1318 |
|
|
+ JUMP _L00105
|
1319 |
|
|
+_LC00105:
|
1320 |
|
|
+ JUMP _L00106
|
1321 |
|
|
+ ; test8.c:10: case 10: c = 11; break;
|
1322 |
|
|
+_L00101:
|
1323 |
|
|
+ LOAD s0, $0b
|
1324 |
|
|
+ STORE s0, _main_c_1_1_0
|
1325 |
|
|
+ JUMP _L00107
|
1326 |
|
|
+ ; test8.c:11: case 11: c = 22; break;
|
1327 |
|
|
+_L00102:
|
1328 |
|
|
+ LOAD s0, $16
|
1329 |
|
|
+ STORE s0, _main_c_1_1_0
|
1330 |
|
|
+ JUMP _L00107
|
1331 |
|
|
+ ; test8.c:12: case 12: c = 33; break;
|
1332 |
|
|
+_L00103:
|
1333 |
|
|
+ LOAD s0, $21
|
1334 |
|
|
+ STORE s0, _main_c_1_1_0
|
1335 |
|
|
+ JUMP _L00107
|
1336 |
|
|
+ ; test8.c:13: case 13: c = 44; break;
|
1337 |
|
|
+_L00104:
|
1338 |
|
|
+ LOAD s0, $2c
|
1339 |
|
|
+ STORE s0, _main_c_1_1_0
|
1340 |
|
|
+ JUMP _L00107
|
1341 |
|
|
+ ; test8.c:14: case 14: c = 55; break;
|
1342 |
|
|
+_L00105:
|
1343 |
|
|
+ LOAD s0, $37
|
1344 |
|
|
+ STORE s0, _main_c_1_1_0
|
1345 |
|
|
+ JUMP _L00107
|
1346 |
|
|
+ ; test8.c:15: default: c = 99;
|
1347 |
|
|
+_L00106:
|
1348 |
|
|
+ LOAD s0, $63
|
1349 |
|
|
+ STORE s0, _main_c_1_1_0
|
1350 |
|
|
+ ; test8.c:17: }
|
1351 |
|
|
+_L00107:
|
1352 |
|
|
+ ; test8.c:20: switch(c)
|
1353 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1354 |
|
|
+ COMP s0, $04
|
1355 |
|
|
+ JUMP NZ, _LC00106
|
1356 |
|
|
+ JUMP _L00111
|
1357 |
|
|
+_LC00106:
|
1358 |
|
|
+ COMP s0, $0a
|
1359 |
|
|
+ JUMP NZ, _LC00107
|
1360 |
|
|
+ JUMP _L00108
|
1361 |
|
|
+_LC00107:
|
1362 |
|
|
+ COMP s0, $17
|
1363 |
|
|
+ JUMP NZ, _LC00108
|
1364 |
|
|
+ JUMP _L00109
|
1365 |
|
|
+_LC00108:
|
1366 |
|
|
+ COMP s0, $1f
|
1367 |
|
|
+ JUMP NZ, _LC00109
|
1368 |
|
|
+ JUMP _L00110
|
1369 |
|
|
+_LC00109:
|
1370 |
|
|
+ COMP s0, $3b
|
1371 |
|
|
+ JUMP NZ, _LC00110
|
1372 |
|
|
+ JUMP _L00112
|
1373 |
|
|
+_LC00110:
|
1374 |
|
|
+ JUMP _L00113
|
1375 |
|
|
+ ; test8.c:22: case 10: c = 11; break;
|
1376 |
|
|
+_L00108:
|
1377 |
|
|
+ LOAD s0, $0b
|
1378 |
|
|
+ STORE s0, _main_c_1_1_0
|
1379 |
|
|
+ JUMP _L00115
|
1380 |
|
|
+ ; test8.c:23: case 23: c = 22; break;
|
1381 |
|
|
+_L00109:
|
1382 |
|
|
+ LOAD s0, $16
|
1383 |
|
|
+ STORE s0, _main_c_1_1_0
|
1384 |
|
|
+ JUMP _L00115
|
1385 |
|
|
+ ; test8.c:24: case 31: c = 33; break;
|
1386 |
|
|
+_L00110:
|
1387 |
|
|
+ LOAD s0, $21
|
1388 |
|
|
+ STORE s0, _main_c_1_1_0
|
1389 |
|
|
+ JUMP _L00115
|
1390 |
|
|
+ ; test8.c:25: case 4: c = 44; break;
|
1391 |
|
|
+_L00111:
|
1392 |
|
|
+ LOAD s0, $2c
|
1393 |
|
|
+ STORE s0, _main_c_1_1_0
|
1394 |
|
|
+ JUMP _L00115
|
1395 |
|
|
+ ; test8.c:26: case 59: c = 55; break;
|
1396 |
|
|
+_L00112:
|
1397 |
|
|
+ LOAD s0, $37
|
1398 |
|
|
+ STORE s0, _main_c_1_1_0
|
1399 |
|
|
+ JUMP _L00115
|
1400 |
|
|
+ ; test8.c:27: default: c = 99;
|
1401 |
|
|
+_L00113:
|
1402 |
|
|
+ LOAD s0, $63
|
1403 |
|
|
+ STORE s0, _main_c_1_1_0
|
1404 |
|
|
+ ; test8.c:29: }
|
1405 |
|
|
+_L00115:
|
1406 |
|
|
+ RET
|
1407 |
|
|
+;--------------------------------------------------------
|
1408 |
|
|
+; interrupt vector
|
1409 |
|
|
+;--------------------------------------------------------
|
1410 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test9.kcpsm.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test9.kcpsm.psm
|
1411 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test9.kcpsm.psm 1970-01-01 01:00:00.000000000 +0100
|
1412 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test9.kcpsm.psm 2011-08-23 15:57:26.000000000 +0200
|
1413 |
|
|
@@ -0,0 +1,125 @@
|
1414 |
|
|
+;--------------------------------------------------------
|
1415 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
1416 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
1417 |
|
|
+; This file was generated Fri Apr 22 14:06:01 2011
|
1418 |
|
|
+;--------------------------------------------------------
|
1419 |
|
|
+;--------------------------------------------------------
|
1420 |
|
|
+; global & static initialisations
|
1421 |
|
|
+;--------------------------------------------------------
|
1422 |
|
|
+ CONSTANT _main_c_1_1_0, 00
|
1423 |
|
|
+
|
1424 |
|
|
+ LOAD sF, 3f
|
1425 |
|
|
+ JUMP __sdcc_program_startup
|
1426 |
|
|
+;--------------------------------------------------------
|
1427 |
|
|
+; Home
|
1428 |
|
|
+;--------------------------------------------------------
|
1429 |
|
|
+__sdcc_program_startup:
|
1430 |
|
|
+ CALL _main
|
1431 |
|
|
+; return from main will lock up
|
1432 |
|
|
+__sdcc_loop:
|
1433 |
|
|
+ JUMP __sdcc_loop
|
1434 |
|
|
+;--------------------------------------------------------
|
1435 |
|
|
+; code
|
1436 |
|
|
+;--------------------------------------------------------
|
1437 |
|
|
+;------------------------------------------------------------
|
1438 |
|
|
+;Allocation info for local variables in function 'main'
|
1439 |
|
|
+;------------------------------------------------------------
|
1440 |
|
|
+;------------------------------------------------------------
|
1441 |
|
|
+_main:
|
1442 |
|
|
+ ; test9.c:7: void main()
|
1443 |
|
|
+ ; test9.c:9: volatile char c = 1;
|
1444 |
|
|
+ LOAD s0, 01
|
1445 |
|
|
+ STORE s0, _main_c_1_1_0
|
1446 |
|
|
+ ; test9.c:10: c = !c;
|
1447 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1448 |
|
|
+ LOAD s1, 00
|
1449 |
|
|
+ COMPARE s0, 00
|
1450 |
|
|
+ JUMP NZ, _LC00101
|
1451 |
|
|
+ LOAD s1, 01
|
1452 |
|
|
+_LC00101:
|
1453 |
|
|
+ STORE s1, _main_c_1_1_0
|
1454 |
|
|
+ ; test9.c:11: c = 0;
|
1455 |
|
|
+ LOAD s0, 00
|
1456 |
|
|
+ STORE s0, _main_c_1_1_0
|
1457 |
|
|
+ ; test9.c:12: c = !c;
|
1458 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1459 |
|
|
+ LOAD s1, 00
|
1460 |
|
|
+ COMPARE s0, 00
|
1461 |
|
|
+ JUMP NZ, _LC00102
|
1462 |
|
|
+ LOAD s1, 01
|
1463 |
|
|
+_LC00102:
|
1464 |
|
|
+ STORE s1, _main_c_1_1_0
|
1465 |
|
|
+ ; test9.c:13: c = c && c;
|
1466 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1467 |
|
|
+ COMPARE s0, 00
|
1468 |
|
|
+ JUMP NZ, _LC00103
|
1469 |
|
|
+ JUMP _L00103
|
1470 |
|
|
+_LC00103:
|
1471 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1472 |
|
|
+ COMPARE s0, 00
|
1473 |
|
|
+ JUMP Z, _LC00104
|
1474 |
|
|
+ JUMP _L00104
|
1475 |
|
|
+_LC00104:
|
1476 |
|
|
+_L00103:
|
1477 |
|
|
+ LOAD s0, 00
|
1478 |
|
|
+ JUMP _L00105
|
1479 |
|
|
+_L00104:
|
1480 |
|
|
+ LOAD s0, 01
|
1481 |
|
|
+_L00105:
|
1482 |
|
|
+ STORE s0, _main_c_1_1_0
|
1483 |
|
|
+ ; test9.c:14: c = c || c;
|
1484 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1485 |
|
|
+ COMPARE s0, 00
|
1486 |
|
|
+ JUMP Z, _LC00105
|
1487 |
|
|
+ JUMP _L00107
|
1488 |
|
|
+_LC00105:
|
1489 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1490 |
|
|
+ COMPARE s0, 00
|
1491 |
|
|
+ JUMP Z, _LC00106
|
1492 |
|
|
+ JUMP _L00107
|
1493 |
|
|
+_LC00106:
|
1494 |
|
|
+ LOAD s0, 00
|
1495 |
|
|
+ JUMP _L00108
|
1496 |
|
|
+_L00107:
|
1497 |
|
|
+ LOAD s0, 01
|
1498 |
|
|
+_L00108:
|
1499 |
|
|
+ STORE s0, _main_c_1_1_0
|
1500 |
|
|
+ ; test9.c:15: c = 29;
|
1501 |
|
|
+ LOAD s0, 1d
|
1502 |
|
|
+ STORE s0, _main_c_1_1_0
|
1503 |
|
|
+ ; test9.c:16: c = c % 13;
|
1504 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1505 |
|
|
+ LOAD sB, s0
|
1506 |
|
|
+ LOAD sC, 0d
|
1507 |
|
|
+ CALL __moduschar
|
1508 |
|
|
+ LOAD s0, sB
|
1509 |
|
|
+ STORE s0, _main_c_1_1_0
|
1510 |
|
|
+_L00101:
|
1511 |
|
|
+ RETURN
|
1512 |
|
|
+
|
1513 |
|
|
+__moduchar:
|
1514 |
|
|
+__moduschar:
|
1515 |
|
|
+ CALL __divuschar
|
1516 |
|
|
+ XOR sB, sC
|
1517 |
|
|
+ XOR sC, sB
|
1518 |
|
|
+ XOR sB, sC
|
1519 |
|
|
+ RETURN
|
1520 |
|
|
+
|
1521 |
|
|
+__divuchar:
|
1522 |
|
|
+ LOAD sE, 08
|
1523 |
|
|
+ LOAD sD, sC
|
1524 |
|
|
+ LOAD sC, 00
|
1525 |
|
|
+_L00107:
|
1526 |
|
|
+ SL0 sB
|
1527 |
|
|
+ SLA sC
|
1528 |
|
|
+ COMPARE sC, sD
|
1529 |
|
|
+ JUMP C, _L00108
|
1530 |
|
|
+ SUB sC, sD
|
1531 |
|
|
+ ADD sB, 01
|
1532 |
|
|
+_L00108:
|
1533 |
|
|
+ SUB sE, 01
|
1534 |
|
|
+ JUMP NZ, _L00107
|
1535 |
|
|
+ RETURN
|
1536 |
|
|
+;--------------------------------------------------------
|
1537 |
|
|
+; interrupt vector
|
1538 |
|
|
+;--------------------------------------------------------
|
1539 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/test9.pblazeide.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test9.pblazeide.psm
|
1540 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/test9.pblazeide.psm 1970-01-01 01:00:00.000000000 +0100
|
1541 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/test9.pblazeide.psm 2011-08-23 15:57:26.000000000 +0200
|
1542 |
|
|
@@ -0,0 +1,125 @@
|
1543 |
|
|
+;--------------------------------------------------------
|
1544 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
1545 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
1546 |
|
|
+; This file was generated Fri Apr 22 14:08:58 2011
|
1547 |
|
|
+;--------------------------------------------------------
|
1548 |
|
|
+;--------------------------------------------------------
|
1549 |
|
|
+; global & static initialisations
|
1550 |
|
|
+;--------------------------------------------------------
|
1551 |
|
|
+ _main_c_1_1_0 EQU $00
|
1552 |
|
|
+
|
1553 |
|
|
+ LOAD sF, $3f
|
1554 |
|
|
+ JUMP __sdcc_program_startup
|
1555 |
|
|
+;--------------------------------------------------------
|
1556 |
|
|
+; Home
|
1557 |
|
|
+;--------------------------------------------------------
|
1558 |
|
|
+__sdcc_program_startup:
|
1559 |
|
|
+ CALL _main
|
1560 |
|
|
+; return from main will lock up
|
1561 |
|
|
+__sdcc_loop:
|
1562 |
|
|
+ JUMP __sdcc_loop
|
1563 |
|
|
+;--------------------------------------------------------
|
1564 |
|
|
+; code
|
1565 |
|
|
+;--------------------------------------------------------
|
1566 |
|
|
+;------------------------------------------------------------
|
1567 |
|
|
+;Allocation info for local variables in function 'main'
|
1568 |
|
|
+;------------------------------------------------------------
|
1569 |
|
|
+;------------------------------------------------------------
|
1570 |
|
|
+_main:
|
1571 |
|
|
+ ; test9.c:7: void main()
|
1572 |
|
|
+ ; test9.c:9: volatile char c = 1;
|
1573 |
|
|
+ LOAD s0, $01
|
1574 |
|
|
+ STORE s0, _main_c_1_1_0
|
1575 |
|
|
+ ; test9.c:10: c = !c;
|
1576 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1577 |
|
|
+ LOAD s1, $00
|
1578 |
|
|
+ COMP s0, $00
|
1579 |
|
|
+ JUMP NZ, _LC00101
|
1580 |
|
|
+ LOAD s1, $01
|
1581 |
|
|
+_LC00101:
|
1582 |
|
|
+ STORE s1, _main_c_1_1_0
|
1583 |
|
|
+ ; test9.c:11: c = 0;
|
1584 |
|
|
+ LOAD s0, $00
|
1585 |
|
|
+ STORE s0, _main_c_1_1_0
|
1586 |
|
|
+ ; test9.c:12: c = !c;
|
1587 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1588 |
|
|
+ LOAD s1, $00
|
1589 |
|
|
+ COMP s0, $00
|
1590 |
|
|
+ JUMP NZ, _LC00102
|
1591 |
|
|
+ LOAD s1, $01
|
1592 |
|
|
+_LC00102:
|
1593 |
|
|
+ STORE s1, _main_c_1_1_0
|
1594 |
|
|
+ ; test9.c:13: c = c && c;
|
1595 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1596 |
|
|
+ COMP s0, $00
|
1597 |
|
|
+ JUMP NZ, _LC00103
|
1598 |
|
|
+ JUMP _L00103
|
1599 |
|
|
+_LC00103:
|
1600 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1601 |
|
|
+ COMP s0, $00
|
1602 |
|
|
+ JUMP Z, _LC00104
|
1603 |
|
|
+ JUMP _L00104
|
1604 |
|
|
+_LC00104:
|
1605 |
|
|
+_L00103:
|
1606 |
|
|
+ LOAD s0, $00
|
1607 |
|
|
+ JUMP _L00105
|
1608 |
|
|
+_L00104:
|
1609 |
|
|
+ LOAD s0, $01
|
1610 |
|
|
+_L00105:
|
1611 |
|
|
+ STORE s0, _main_c_1_1_0
|
1612 |
|
|
+ ; test9.c:14: c = c || c;
|
1613 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1614 |
|
|
+ COMP s0, $00
|
1615 |
|
|
+ JUMP Z, _LC00105
|
1616 |
|
|
+ JUMP _L00107
|
1617 |
|
|
+_LC00105:
|
1618 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1619 |
|
|
+ COMP s0, $00
|
1620 |
|
|
+ JUMP Z, _LC00106
|
1621 |
|
|
+ JUMP _L00107
|
1622 |
|
|
+_LC00106:
|
1623 |
|
|
+ LOAD s0, $00
|
1624 |
|
|
+ JUMP _L00108
|
1625 |
|
|
+_L00107:
|
1626 |
|
|
+ LOAD s0, $01
|
1627 |
|
|
+_L00108:
|
1628 |
|
|
+ STORE s0, _main_c_1_1_0
|
1629 |
|
|
+ ; test9.c:15: c = 29;
|
1630 |
|
|
+ LOAD s0, $1d
|
1631 |
|
|
+ STORE s0, _main_c_1_1_0
|
1632 |
|
|
+ ; test9.c:16: c = c % 13;
|
1633 |
|
|
+ FETCH s0, _main_c_1_1_0
|
1634 |
|
|
+ LOAD sB, s0
|
1635 |
|
|
+ LOAD sC, $0d
|
1636 |
|
|
+ CALL __moduschar
|
1637 |
|
|
+ LOAD s0, sB
|
1638 |
|
|
+ STORE s0, _main_c_1_1_0
|
1639 |
|
|
+_L00101:
|
1640 |
|
|
+ RET
|
1641 |
|
|
+
|
1642 |
|
|
+__moduchar:
|
1643 |
|
|
+__moduschar:
|
1644 |
|
|
+ CALL __divuschar
|
1645 |
|
|
+ XOR sB, sC
|
1646 |
|
|
+ XOR sC, sB
|
1647 |
|
|
+ XOR sB, sC
|
1648 |
|
|
+ RET
|
1649 |
|
|
+
|
1650 |
|
|
+__divuchar:
|
1651 |
|
|
+ LOAD sE, $08
|
1652 |
|
|
+ LOAD sD, sC
|
1653 |
|
|
+ LOAD sC, $00
|
1654 |
|
|
+_L00107:
|
1655 |
|
|
+ SL0 sB
|
1656 |
|
|
+ SLA sC
|
1657 |
|
|
+ COMP sC, sD
|
1658 |
|
|
+ JUMP C, _L00108
|
1659 |
|
|
+ SUB sC, sD
|
1660 |
|
|
+ ADD sB, $01
|
1661 |
|
|
+_L00108:
|
1662 |
|
|
+ SUB sE, $01
|
1663 |
|
|
+ JUMP NZ, _L00107
|
1664 |
|
|
+ RET
|
1665 |
|
|
+;--------------------------------------------------------
|
1666 |
|
|
+; interrupt vector
|
1667 |
|
|
+;--------------------------------------------------------
|
1668 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/testM2.kcpsm.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/testM2.kcpsm.psm
|
1669 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/testM2.kcpsm.psm 1970-01-01 01:00:00.000000000 +0100
|
1670 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/testM2.kcpsm.psm 2011-08-23 15:57:26.000000000 +0200
|
1671 |
|
|
@@ -0,0 +1,230 @@
|
1672 |
|
|
+;--------------------------------------------------------
|
1673 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
1674 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
1675 |
|
|
+; This file was generated Fri Apr 22 14:32:23 2011
|
1676 |
|
|
+;--------------------------------------------------------
|
1677 |
|
|
+;--------------------------------------------------------
|
1678 |
|
|
+; global & static initialisations
|
1679 |
|
|
+;--------------------------------------------------------
|
1680 |
|
|
+ CONSTANT _fun_val_1_1_0, 00
|
1681 |
|
|
+ CONSTANT _pole_7, 01
|
1682 |
|
|
+ CONSTANT _pole_6, 02
|
1683 |
|
|
+ CONSTANT _pole_5, 03
|
1684 |
|
|
+ CONSTANT _pole_4, 04
|
1685 |
|
|
+ CONSTANT _pole_3, 05
|
1686 |
|
|
+ CONSTANT _pole_2, 06
|
1687 |
|
|
+ CONSTANT _pole_1, 07
|
1688 |
|
|
+ CONSTANT _pole_0, 08
|
1689 |
|
|
+ CONSTANT _text_4, 09
|
1690 |
|
|
+ CONSTANT _text_3, 0a
|
1691 |
|
|
+ CONSTANT _text_2, 0b
|
1692 |
|
|
+ CONSTANT _text_1, 0c
|
1693 |
|
|
+ CONSTANT _text_0, 0d
|
1694 |
|
|
+ CONSTANT _nepole_1, 0e
|
1695 |
|
|
+ CONSTANT _nepole_0, 0f
|
1696 |
|
|
+ CONSTANT _main_a_1_1_0, 10
|
1697 |
|
|
+ CONSTANT _main_b_1_1_0, 11
|
1698 |
|
|
+
|
1699 |
|
|
+;------------------------------------------------------------
|
1700 |
|
|
+;Allocation info for local variables in function 'main'
|
1701 |
|
|
+;------------------------------------------------------------
|
1702 |
|
|
+;------------------------------------------------------------
|
1703 |
|
|
+ ; testM2.c:3: int pole[] = {100,200,300,400};
|
1704 |
|
|
+ LOAD s0, _pole_7
|
1705 |
|
|
+ LOAD s1, 00
|
1706 |
|
|
+ STORE s1, (s0)
|
1707 |
|
|
+ ADD s0, 01
|
1708 |
|
|
+ LOAD s1, 64
|
1709 |
|
|
+ STORE s1, (s0)
|
1710 |
|
|
+ SUB s0, 01
|
1711 |
|
|
+ LOAD s1, s0
|
1712 |
|
|
+ ADD s1, 02
|
1713 |
|
|
+ LOAD s2, 00
|
1714 |
|
|
+ STORE s2, (s1)
|
1715 |
|
|
+ ADD s1, 01
|
1716 |
|
|
+ LOAD s2, c8
|
1717 |
|
|
+ STORE s2, (s1)
|
1718 |
|
|
+ ADD s1, 01
|
1719 |
|
|
+ LOAD s2, 01
|
1720 |
|
|
+ STORE s2, (s1)
|
1721 |
|
|
+ ADD s1, 01
|
1722 |
|
|
+ LOAD s2, 2c
|
1723 |
|
|
+ STORE s2, (s1)
|
1724 |
|
|
+ ADD s1, 01
|
1725 |
|
|
+ LOAD s0, 01
|
1726 |
|
|
+ STORE s0, (s1)
|
1727 |
|
|
+ ADD s1, 01
|
1728 |
|
|
+ LOAD s0, 90
|
1729 |
|
|
+ STORE s0, (s1)
|
1730 |
|
|
+ LOAD sF, 3f
|
1731 |
|
|
+ JUMP __sdcc_program_startup
|
1732 |
|
|
+;--------------------------------------------------------
|
1733 |
|
|
+; Home
|
1734 |
|
|
+;--------------------------------------------------------
|
1735 |
|
|
+__sdcc_program_startup:
|
1736 |
|
|
+ CALL _main
|
1737 |
|
|
+; return from main will lock up
|
1738 |
|
|
+__sdcc_loop:
|
1739 |
|
|
+ JUMP __sdcc_loop
|
1740 |
|
|
+;--------------------------------------------------------
|
1741 |
|
|
+; code
|
1742 |
|
|
+;--------------------------------------------------------
|
1743 |
|
|
+;------------------------------------------------------------
|
1744 |
|
|
+;Allocation info for local variables in function 'main'
|
1745 |
|
|
+;------------------------------------------------------------
|
1746 |
|
|
+;------------------------------------------------------------
|
1747 |
|
|
+ ; testM2.c:10: char fun( volatile char *a, int b, char c, char *d)
|
1748 |
|
|
+_fun:
|
1749 |
|
|
+ LOAD s0, sC
|
1750 |
|
|
+ LOAD s1, sD
|
1751 |
|
|
+ LOAD s2, sE
|
1752 |
|
|
+ ; testM2.c:12: volatile char val = 0;
|
1753 |
|
|
+ LOAD s3, 00
|
1754 |
|
|
+ STORE s3, _fun_val_1_1_0
|
1755 |
|
|
+ ; testM2.c:13: char t1 = *d;
|
1756 |
|
|
+ ADD sF, 01
|
1757 |
|
|
+ FETCH s3, (sF)
|
1758 |
|
|
+ FETCH s4, (s3)
|
1759 |
|
|
+ ; testM2.c:15: val = val * c;
|
1760 |
|
|
+ FETCH s5, _fun_val_1_1_0
|
1761 |
|
|
+ LOAD sB, s5
|
1762 |
|
|
+ LOAD sC, s2
|
1763 |
|
|
+ CALL __mulschar
|
1764 |
|
|
+ LOAD s2, sB
|
1765 |
|
|
+ STORE s2, _fun_val_1_1_0
|
1766 |
|
|
+ ; testM2.c:16: b = pole[3] & pole[1];
|
1767 |
|
|
+ LOAD s2, _pole_7
|
1768 |
|
|
+ LOAD s5, s2
|
1769 |
|
|
+ ADD s5, 06
|
1770 |
|
|
+ FETCH s6, (s5)
|
1771 |
|
|
+ ADD s5, 01
|
1772 |
|
|
+ FETCH s7, (s5)
|
1773 |
|
|
+ ADD s2, 02
|
1774 |
|
|
+ FETCH s5, (s2)
|
1775 |
|
|
+ ADD s2, 01
|
1776 |
|
|
+ FETCH s8, (s2)
|
1777 |
|
|
+ AND s7, s8
|
1778 |
|
|
+ AND s6, s5
|
1779 |
|
|
+ ; testM2.c:17: text[2] = 'R';
|
1780 |
|
|
+ LOAD s0, _text_4
|
1781 |
|
|
+ LOAD s1, s0
|
1782 |
|
|
+ ADD s1, 02
|
1783 |
|
|
+ LOAD s2, 52
|
1784 |
|
|
+ STORE s2, (s1)
|
1785 |
|
|
+ ; testM2.c:18: *d = text[3];
|
1786 |
|
|
+ ADD s0, 03
|
1787 |
|
|
+ FETCH s1, (s0)
|
1788 |
|
|
+ STORE s1, (s3)
|
1789 |
|
|
+ ; testM2.c:19: return t1 + b + nepole;
|
1790 |
|
|
+ ADD s4, s7
|
1791 |
|
|
+ FETCH s1, _nepole_0
|
1792 |
|
|
+ LOAD s0, s1
|
1793 |
|
|
+ ADD s4, s0
|
1794 |
|
|
+ LOAD sB, s4
|
1795 |
|
|
+_L00101:
|
1796 |
|
|
+ RETURN
|
1797 |
|
|
+;------------------------------------------------------------
|
1798 |
|
|
+;Allocation info for local variables in function 'main'
|
1799 |
|
|
+;------------------------------------------------------------
|
1800 |
|
|
+;------------------------------------------------------------
|
1801 |
|
|
+_main:
|
1802 |
|
|
+ ; testM2.c:22: void main()
|
1803 |
|
|
+ ; testM2.c:24: volatile char a = 10;
|
1804 |
|
|
+ LOAD s0, 0a
|
1805 |
|
|
+ STORE s0, _main_a_1_1_0
|
1806 |
|
|
+ ; testM2.c:25: volatile char b = 20;
|
1807 |
|
|
+ LOAD s0, 14
|
1808 |
|
|
+ STORE s0, _main_b_1_1_0
|
1809 |
|
|
+ ; testM2.c:26: char c = 30;
|
1810 |
|
|
+ LOAD s0, 1e
|
1811 |
|
|
+ STORE s0, 14
|
1812 |
|
|
+ ; testM2.c:27: gptr = &nepole;
|
1813 |
|
|
+ LOAD s0, _nepole_1
|
1814 |
|
|
+ LOAD s1, s0
|
1815 |
|
|
+ ; testM2.c:28: vgptr = &nepole;
|
1816 |
|
|
+ ; testM2.c:29: pole[1] = 150;
|
1817 |
|
|
+ LOAD s2, _pole_7
|
1818 |
|
|
+ LOAD s3, s2
|
1819 |
|
|
+ ADD s3, 02
|
1820 |
|
|
+ LOAD s4, 00
|
1821 |
|
|
+ STORE s4, (s3)
|
1822 |
|
|
+ ADD s3, 01
|
1823 |
|
|
+ LOAD s4, 96
|
1824 |
|
|
+ STORE s4, (s3)
|
1825 |
|
|
+ ; testM2.c:30: pole[0] = *gptr;
|
1826 |
|
|
+ FETCH s3, (s1)
|
1827 |
|
|
+ ADD s1, 01
|
1828 |
|
|
+ FETCH s4, (s1)
|
1829 |
|
|
+ STORE s3, (s2)
|
1830 |
|
|
+ ADD s2, 01
|
1831 |
|
|
+ STORE s4, (s2)
|
1832 |
|
|
+ ; testM2.c:31: *vgptr = 18;
|
1833 |
|
|
+ LOAD s1, 00
|
1834 |
|
|
+ STORE s1, (s0)
|
1835 |
|
|
+ ADD s0, 01
|
1836 |
|
|
+ LOAD s1, 12
|
1837 |
|
|
+ STORE s1, (s0)
|
1838 |
|
|
+ ; testM2.c:32: fun(&a,555,c, &c);
|
1839 |
|
|
+ LOAD s0, 14
|
1840 |
|
|
+ FETCH s2, 14
|
1841 |
|
|
+ LOAD s1, s2
|
1842 |
|
|
+ LOAD s2, _main_a_1_1_0
|
1843 |
|
|
+ STORE s0, (sF)
|
1844 |
|
|
+ SUB sF, 01
|
1845 |
|
|
+ LOAD sB, s2
|
1846 |
|
|
+ LOAD sC, 2b
|
1847 |
|
|
+ LOAD sD, 02
|
1848 |
|
|
+ LOAD sE, s1
|
1849 |
|
|
+ CALL _fun
|
1850 |
|
|
+ ; testM2.c:33: nepole = c;
|
1851 |
|
|
+ FETCH s1, 14
|
1852 |
|
|
+ LOAD s0, s1
|
1853 |
|
|
+ LOAD s1, 00
|
1854 |
|
|
+ TEST s0, 80
|
1855 |
|
|
+ SUBCY s1, 00
|
1856 |
|
|
+_L00101:
|
1857 |
|
|
+ STORE s1, _nepole_1
|
1858 |
|
|
+ STORE s0, _nepole_0
|
1859 |
|
|
+ RETURN
|
1860 |
|
|
+
|
1861 |
|
|
+__mulschar:
|
1862 |
|
|
+ LOAD sA, 00
|
1863 |
|
|
+ TEST sB, 80
|
1864 |
|
|
+ JUMP Z, _L00104
|
1865 |
|
|
+ XOR sB, FF
|
1866 |
|
|
+ ADD sB, 01
|
1867 |
|
|
+ LOAD sA, 01
|
1868 |
|
|
+_L00104:
|
1869 |
|
|
+ TEST sC, 80
|
1870 |
|
|
+ JUMP Z, _L00105
|
1871 |
|
|
+ XOR sC, FF
|
1872 |
|
|
+ ADD sC, 01
|
1873 |
|
|
+ XOR sA, 01
|
1874 |
|
|
+_L00105:
|
1875 |
|
|
+ CALL __muluchar
|
1876 |
|
|
+ TEST sA, 01
|
1877 |
|
|
+ JUMP Z, _L00106
|
1878 |
|
|
+ XOR sB, FF
|
1879 |
|
|
+ XOR sC, FF
|
1880 |
|
|
+ ADD sB, 01
|
1881 |
|
|
+ ADDCY sC, 00
|
1882 |
|
|
+_L00106:
|
1883 |
|
|
+ RETURN
|
1884 |
|
|
+
|
1885 |
|
|
+__muluchar:
|
1886 |
|
|
+ LOAD sE, 08
|
1887 |
|
|
+ LOAD sD, sC
|
1888 |
|
|
+ LOAD sC, 00
|
1889 |
|
|
+_L00108:
|
1890 |
|
|
+ TEST sB, 01
|
1891 |
|
|
+ JUMP Z, _L00107
|
1892 |
|
|
+ ADD sC, sD
|
1893 |
|
|
+_L00107:
|
1894 |
|
|
+ SR0 sC
|
1895 |
|
|
+ SRA sB
|
1896 |
|
|
+ SUB sE, 01
|
1897 |
|
|
+ JUMP NZ, _L00108
|
1898 |
|
|
+ RETURN
|
1899 |
|
|
+;--------------------------------------------------------
|
1900 |
|
|
+; interrupt vector
|
1901 |
|
|
+;--------------------------------------------------------
|
1902 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/expected/testM2.pblazeide.psm sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/testM2.pblazeide.psm
|
1903 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/expected/testM2.pblazeide.psm 1970-01-01 01:00:00.000000000 +0100
|
1904 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/expected/testM2.pblazeide.psm 2011-08-23 15:57:26.000000000 +0200
|
1905 |
|
|
@@ -0,0 +1,230 @@
|
1906 |
|
|
+;--------------------------------------------------------
|
1907 |
|
|
+; File Created by SDCC : free open source ANSI-C Compiler
|
1908 |
|
|
+; Version 3.0.1 #6227 (Feb 20 2011) (Linux)
|
1909 |
|
|
+; This file was generated Fri Apr 22 14:10:03 2011
|
1910 |
|
|
+;--------------------------------------------------------
|
1911 |
|
|
+;--------------------------------------------------------
|
1912 |
|
|
+; global & static initialisations
|
1913 |
|
|
+;--------------------------------------------------------
|
1914 |
|
|
+ _fun_val_1_1_0 EQU $00
|
1915 |
|
|
+ _pole_7 EQU $01
|
1916 |
|
|
+ _pole_6 EQU $02
|
1917 |
|
|
+ _pole_5 EQU $03
|
1918 |
|
|
+ _pole_4 EQU $04
|
1919 |
|
|
+ _pole_3 EQU $05
|
1920 |
|
|
+ _pole_2 EQU $06
|
1921 |
|
|
+ _pole_1 EQU $07
|
1922 |
|
|
+ _pole_0 EQU $08
|
1923 |
|
|
+ _text_4 EQU $09
|
1924 |
|
|
+ _text_3 EQU $0a
|
1925 |
|
|
+ _text_2 EQU $0b
|
1926 |
|
|
+ _text_1 EQU $0c
|
1927 |
|
|
+ _text_0 EQU $0d
|
1928 |
|
|
+ _nepole_1 EQU $0e
|
1929 |
|
|
+ _nepole_0 EQU $0f
|
1930 |
|
|
+ _main_a_1_1_0 EQU $10
|
1931 |
|
|
+ _main_b_1_1_0 EQU $11
|
1932 |
|
|
+
|
1933 |
|
|
+;------------------------------------------------------------
|
1934 |
|
|
+;Allocation info for local variables in function 'main'
|
1935 |
|
|
+;------------------------------------------------------------
|
1936 |
|
|
+;------------------------------------------------------------
|
1937 |
|
|
+ ; testM2.c:3: int pole[] = {100,200,300,400};
|
1938 |
|
|
+ LOAD s0, _pole_7
|
1939 |
|
|
+ LOAD s1, $00
|
1940 |
|
|
+ STORE s1, (s0)
|
1941 |
|
|
+ ADD s0, $01
|
1942 |
|
|
+ LOAD s1, $64
|
1943 |
|
|
+ STORE s1, (s0)
|
1944 |
|
|
+ SUB s0, $01
|
1945 |
|
|
+ LOAD s1, s0
|
1946 |
|
|
+ ADD s1, $02
|
1947 |
|
|
+ LOAD s2, $00
|
1948 |
|
|
+ STORE s2, (s1)
|
1949 |
|
|
+ ADD s1, $01
|
1950 |
|
|
+ LOAD s2, $c8
|
1951 |
|
|
+ STORE s2, (s1)
|
1952 |
|
|
+ ADD s1, $01
|
1953 |
|
|
+ LOAD s2, $01
|
1954 |
|
|
+ STORE s2, (s1)
|
1955 |
|
|
+ ADD s1, $01
|
1956 |
|
|
+ LOAD s2, $2c
|
1957 |
|
|
+ STORE s2, (s1)
|
1958 |
|
|
+ ADD s1, $01
|
1959 |
|
|
+ LOAD s0, $01
|
1960 |
|
|
+ STORE s0, (s1)
|
1961 |
|
|
+ ADD s1, $01
|
1962 |
|
|
+ LOAD s0, $90
|
1963 |
|
|
+ STORE s0, (s1)
|
1964 |
|
|
+ LOAD sF, $3f
|
1965 |
|
|
+ JUMP __sdcc_program_startup
|
1966 |
|
|
+;--------------------------------------------------------
|
1967 |
|
|
+; Home
|
1968 |
|
|
+;--------------------------------------------------------
|
1969 |
|
|
+__sdcc_program_startup:
|
1970 |
|
|
+ CALL _main
|
1971 |
|
|
+; return from main will lock up
|
1972 |
|
|
+__sdcc_loop:
|
1973 |
|
|
+ JUMP __sdcc_loop
|
1974 |
|
|
+;--------------------------------------------------------
|
1975 |
|
|
+; code
|
1976 |
|
|
+;--------------------------------------------------------
|
1977 |
|
|
+;------------------------------------------------------------
|
1978 |
|
|
+;Allocation info for local variables in function 'main'
|
1979 |
|
|
+;------------------------------------------------------------
|
1980 |
|
|
+;------------------------------------------------------------
|
1981 |
|
|
+ ; testM2.c:10: char fun( volatile char *a, int b, char c, char *d)
|
1982 |
|
|
+_fun:
|
1983 |
|
|
+ LOAD s0, sC
|
1984 |
|
|
+ LOAD s1, sD
|
1985 |
|
|
+ LOAD s2, sE
|
1986 |
|
|
+ ; testM2.c:12: volatile char val = 0;
|
1987 |
|
|
+ LOAD s3, $00
|
1988 |
|
|
+ STORE s3, _fun_val_1_1_0
|
1989 |
|
|
+ ; testM2.c:13: char t1 = *d;
|
1990 |
|
|
+ ADD sF, $01
|
1991 |
|
|
+ FETCH s3, (sF)
|
1992 |
|
|
+ FETCH s4, (s3)
|
1993 |
|
|
+ ; testM2.c:15: val = val * c;
|
1994 |
|
|
+ FETCH s5, _fun_val_1_1_0
|
1995 |
|
|
+ LOAD sB, s5
|
1996 |
|
|
+ LOAD sC, s2
|
1997 |
|
|
+ CALL __mulschar
|
1998 |
|
|
+ LOAD s2, sB
|
1999 |
|
|
+ STORE s2, _fun_val_1_1_0
|
2000 |
|
|
+ ; testM2.c:16: b = pole[3] & pole[1];
|
2001 |
|
|
+ LOAD s2, _pole_7
|
2002 |
|
|
+ LOAD s5, s2
|
2003 |
|
|
+ ADD s5, $06
|
2004 |
|
|
+ FETCH s6, (s5)
|
2005 |
|
|
+ ADD s5, $01
|
2006 |
|
|
+ FETCH s7, (s5)
|
2007 |
|
|
+ ADD s2, $02
|
2008 |
|
|
+ FETCH s5, (s2)
|
2009 |
|
|
+ ADD s2, $01
|
2010 |
|
|
+ FETCH s8, (s2)
|
2011 |
|
|
+ AND s7, s8
|
2012 |
|
|
+ AND s6, s5
|
2013 |
|
|
+ ; testM2.c:17: text[2] = 'R';
|
2014 |
|
|
+ LOAD s0, _text_4
|
2015 |
|
|
+ LOAD s1, s0
|
2016 |
|
|
+ ADD s1, $02
|
2017 |
|
|
+ LOAD s2, $52
|
2018 |
|
|
+ STORE s2, (s1)
|
2019 |
|
|
+ ; testM2.c:18: *d = text[3];
|
2020 |
|
|
+ ADD s0, $03
|
2021 |
|
|
+ FETCH s1, (s0)
|
2022 |
|
|
+ STORE s1, (s3)
|
2023 |
|
|
+ ; testM2.c:19: return t1 + b + nepole;
|
2024 |
|
|
+ ADD s4, s7
|
2025 |
|
|
+ FETCH s1, _nepole_0
|
2026 |
|
|
+ LOAD s0, s1
|
2027 |
|
|
+ ADD s4, s0
|
2028 |
|
|
+ LOAD sB, s4
|
2029 |
|
|
+_L00101:
|
2030 |
|
|
+ RET
|
2031 |
|
|
+;------------------------------------------------------------
|
2032 |
|
|
+;Allocation info for local variables in function 'main'
|
2033 |
|
|
+;------------------------------------------------------------
|
2034 |
|
|
+;------------------------------------------------------------
|
2035 |
|
|
+_main:
|
2036 |
|
|
+ ; testM2.c:22: void main()
|
2037 |
|
|
+ ; testM2.c:24: volatile char a = 10;
|
2038 |
|
|
+ LOAD s0, $0a
|
2039 |
|
|
+ STORE s0, _main_a_1_1_0
|
2040 |
|
|
+ ; testM2.c:25: volatile char b = 20;
|
2041 |
|
|
+ LOAD s0, $14
|
2042 |
|
|
+ STORE s0, _main_b_1_1_0
|
2043 |
|
|
+ ; testM2.c:26: char c = 30;
|
2044 |
|
|
+ LOAD s0, $1e
|
2045 |
|
|
+ STORE s0, 14
|
2046 |
|
|
+ ; testM2.c:27: gptr = &nepole;
|
2047 |
|
|
+ LOAD s0, _nepole_1
|
2048 |
|
|
+ LOAD s1, s0
|
2049 |
|
|
+ ; testM2.c:28: vgptr = &nepole;
|
2050 |
|
|
+ ; testM2.c:29: pole[1] = 150;
|
2051 |
|
|
+ LOAD s2, _pole_7
|
2052 |
|
|
+ LOAD s3, s2
|
2053 |
|
|
+ ADD s3, $02
|
2054 |
|
|
+ LOAD s4, $00
|
2055 |
|
|
+ STORE s4, (s3)
|
2056 |
|
|
+ ADD s3, $01
|
2057 |
|
|
+ LOAD s4, $96
|
2058 |
|
|
+ STORE s4, (s3)
|
2059 |
|
|
+ ; testM2.c:30: pole[0] = *gptr;
|
2060 |
|
|
+ FETCH s3, (s1)
|
2061 |
|
|
+ ADD s1, $01
|
2062 |
|
|
+ FETCH s4, (s1)
|
2063 |
|
|
+ STORE s3, (s2)
|
2064 |
|
|
+ ADD s2, $01
|
2065 |
|
|
+ STORE s4, (s2)
|
2066 |
|
|
+ ; testM2.c:31: *vgptr = 18;
|
2067 |
|
|
+ LOAD s1, $00
|
2068 |
|
|
+ STORE s1, (s0)
|
2069 |
|
|
+ ADD s0, $01
|
2070 |
|
|
+ LOAD s1, $12
|
2071 |
|
|
+ STORE s1, (s0)
|
2072 |
|
|
+ ; testM2.c:32: fun(&a,555,c, &c);
|
2073 |
|
|
+ LOAD s0, 14
|
2074 |
|
|
+ FETCH s2, 14
|
2075 |
|
|
+ LOAD s1, s2
|
2076 |
|
|
+ LOAD s2, _main_a_1_1_0
|
2077 |
|
|
+ STORE s0, (sF)
|
2078 |
|
|
+ SUB sF, $01
|
2079 |
|
|
+ LOAD sB, s2
|
2080 |
|
|
+ LOAD sC, $2b
|
2081 |
|
|
+ LOAD sD, $02
|
2082 |
|
|
+ LOAD sE, s1
|
2083 |
|
|
+ CALL _fun
|
2084 |
|
|
+ ; testM2.c:33: nepole = c;
|
2085 |
|
|
+ FETCH s1, 14
|
2086 |
|
|
+ LOAD s0, s1
|
2087 |
|
|
+ LOAD s1, $00
|
2088 |
|
|
+ TEST s0, $80
|
2089 |
|
|
+ SUBC s1, $00
|
2090 |
|
|
+_L00101:
|
2091 |
|
|
+ STORE s1, _nepole_1
|
2092 |
|
|
+ STORE s0, _nepole_0
|
2093 |
|
|
+ RET
|
2094 |
|
|
+
|
2095 |
|
|
+__mulschar:
|
2096 |
|
|
+ LOAD sA, $00
|
2097 |
|
|
+ TEST sB, $80
|
2098 |
|
|
+ JUMP Z, _L00104
|
2099 |
|
|
+ XOR sB, $FF
|
2100 |
|
|
+ ADD sB, $01
|
2101 |
|
|
+ LOAD sA, $01
|
2102 |
|
|
+_L00104:
|
2103 |
|
|
+ TEST sC, $80
|
2104 |
|
|
+ JUMP Z, _L00105
|
2105 |
|
|
+ XOR sC, $FF
|
2106 |
|
|
+ ADD sC, $01
|
2107 |
|
|
+ XOR sA, $01
|
2108 |
|
|
+_L00105:
|
2109 |
|
|
+ CALL __muluchar
|
2110 |
|
|
+ TEST sA, $01
|
2111 |
|
|
+ JUMP Z, _L00106
|
2112 |
|
|
+ XOR sB, $FF
|
2113 |
|
|
+ XOR sC, $FF
|
2114 |
|
|
+ ADD sB, $01
|
2115 |
|
|
+ ADDC sC, $00
|
2116 |
|
|
+_L00106:
|
2117 |
|
|
+ RET
|
2118 |
|
|
+
|
2119 |
|
|
+__muluchar:
|
2120 |
|
|
+ LOAD sE, $08
|
2121 |
|
|
+ LOAD sD, sC
|
2122 |
|
|
+ LOAD sC, $00
|
2123 |
|
|
+_L00108:
|
2124 |
|
|
+ TEST sB, $01
|
2125 |
|
|
+ JUMP Z, _L00107
|
2126 |
|
|
+ ADD sC, sD
|
2127 |
|
|
+_L00107:
|
2128 |
|
|
+ SR0 sC
|
2129 |
|
|
+ SRA sB
|
2130 |
|
|
+ SUB sE, $01
|
2131 |
|
|
+ JUMP NZ, _L00108
|
2132 |
|
|
+ RET
|
2133 |
|
|
+;--------------------------------------------------------
|
2134 |
|
|
+; interrupt vector
|
2135 |
|
|
+;--------------------------------------------------------
|
2136 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/funargs.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/funargs.c
|
2137 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/funargs.c 1970-01-01 01:00:00.000000000 +0100
|
2138 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/funargs.c 2011-08-23 15:57:24.000000000 +0200
|
2139 |
|
|
@@ -0,0 +1,15 @@
|
2140 |
|
|
+char f(char arg, char arg2)
|
2141 |
|
|
+{
|
2142 |
|
|
+ return arg+arg2;
|
2143 |
|
|
+}
|
2144 |
|
|
+
|
2145 |
|
|
+
|
2146 |
|
|
+void main()
|
2147 |
|
|
+{
|
2148 |
|
|
+ char i = 0;
|
2149 |
|
|
+ for(; i < 10; i++)
|
2150 |
|
|
+ {
|
2151 |
|
|
+ i++;
|
2152 |
|
|
+ f(i, 17);
|
2153 |
|
|
+ }
|
2154 |
|
|
+}
|
2155 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/funlit.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/funlit.c
|
2156 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/funlit.c 1970-01-01 01:00:00.000000000 +0100
|
2157 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/funlit.c 2011-08-23 15:57:24.000000000 +0200
|
2158 |
|
|
@@ -0,0 +1,14 @@
|
2159 |
|
|
+char sum(char nnn1, char n2, char n3)
|
2160 |
|
|
+{
|
2161 |
|
|
+ return nnn1 + n2 + n3;
|
2162 |
|
|
+}
|
2163 |
|
|
+
|
2164 |
|
|
+
|
2165 |
|
|
+void main()
|
2166 |
|
|
+{
|
2167 |
|
|
+ char c = 29;
|
2168 |
|
|
+ char d = 57;
|
2169 |
|
|
+ char e = 113;
|
2170 |
|
|
+ sum (c, d, e);
|
2171 |
|
|
+
|
2172 |
|
|
+}
|
2173 |
|
|
\ No newline at end of file
|
2174 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/funstruct.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/funstruct.c
|
2175 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/funstruct.c 1970-01-01 01:00:00.000000000 +0100
|
2176 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/funstruct.c 2011-08-23 15:57:26.000000000 +0200
|
2177 |
|
|
@@ -0,0 +1,31 @@
|
2178 |
|
|
+struct s {
|
2179 |
|
|
+ int a;
|
2180 |
|
|
+ char b;
|
2181 |
|
|
+} struktura;
|
2182 |
|
|
+
|
2183 |
|
|
+int sum(char nnn1, short n2, int n3)
|
2184 |
|
|
+{
|
2185 |
|
|
+ return (int)nnn1 + n2 + n3;
|
2186 |
|
|
+}
|
2187 |
|
|
+
|
2188 |
|
|
+void main()
|
2189 |
|
|
+{
|
2190 |
|
|
+ char c = 29;
|
2191 |
|
|
+ short d = 57;
|
2192 |
|
|
+ int e = 113;
|
2193 |
|
|
+
|
2194 |
|
|
+
|
2195 |
|
|
+ if (sum(1, 2, 3) > 5)
|
2196 |
|
|
+ {
|
2197 |
|
|
+ sum(2, 3, c + d);
|
2198 |
|
|
+ return;
|
2199 |
|
|
+ }
|
2200 |
|
|
+ else
|
2201 |
|
|
+ {
|
2202 |
|
|
+ struktura.a = 99;
|
2203 |
|
|
+ }
|
2204 |
|
|
+ struktura.a = 2*e;
|
2205 |
|
|
+ struktura.b = c;
|
2206 |
|
|
+ sum (struktura.b, d, e);
|
2207 |
|
|
+
|
2208 |
|
|
+}
|
2209 |
|
|
\ No newline at end of file
|
2210 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/funvar.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/funvar.c
|
2211 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/funvar.c 1970-01-01 01:00:00.000000000 +0100
|
2212 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/funvar.c 2011-08-23 15:57:24.000000000 +0200
|
2213 |
|
|
@@ -0,0 +1,11 @@
|
2214 |
|
|
+char globvar = 13;
|
2215 |
|
|
+
|
2216 |
|
|
+char test(char x)
|
2217 |
|
|
+{
|
2218 |
|
|
+ return x;
|
2219 |
|
|
+}
|
2220 |
|
|
+
|
2221 |
|
|
+void main()
|
2222 |
|
|
+{
|
2223 |
|
|
+ test(globvar);
|
2224 |
|
|
+}
|
2225 |
|
|
\ No newline at end of file
|
2226 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/intr.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/intr.c
|
2227 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/intr.c 1970-01-01 01:00:00.000000000 +0100
|
2228 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/intr.c 2011-08-23 15:57:24.000000000 +0200
|
2229 |
|
|
@@ -0,0 +1,18 @@
|
2230 |
|
|
+// test of inserted asm code into C code
|
2231 |
|
|
+int i;
|
2232 |
|
|
+
|
2233 |
|
|
+void ihandler() __interrupt (3) __using (7)
|
2234 |
|
|
+{
|
2235 |
|
|
+ _asm
|
2236 |
|
|
+ DISALBE INTERRUPT
|
2237 |
|
|
+ _endasm;
|
2238 |
|
|
+}
|
2239 |
|
|
+
|
2240 |
|
|
+int main(int x, int y)
|
2241 |
|
|
+{
|
2242 |
|
|
+_asm
|
2243 |
|
|
+INPUT s0
|
2244 |
|
|
+_endasm;
|
2245 |
|
|
+i = 10;
|
2246 |
|
|
+return i;
|
2247 |
|
|
+}
|
2248 |
|
|
\ No newline at end of file
|
2249 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/lcd.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/lcd.c
|
2250 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/lcd.c 1970-01-01 01:00:00.000000000 +0100
|
2251 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/lcd.c 2011-08-23 15:57:24.000000000 +0200
|
2252 |
|
|
@@ -0,0 +1,54 @@
|
2253 |
|
|
+//#include <stdio.h>
|
2254 |
|
|
+
|
2255 |
|
|
+void __port_write(char port, char arg) { }
|
2256 |
|
|
+char __port_read(char port) { }
|
2257 |
|
|
+void __nop() { }
|
2258 |
|
|
+
|
2259 |
|
|
+#define LED_wr(arg) __port_write(0x80, (arg))
|
2260 |
|
|
+
|
2261 |
|
|
+#define LCD_wr(arg) __port_write(0x01, (arg))
|
2262 |
|
|
+#define LCD_rd() __port_read(0x01)
|
2263 |
|
|
+#define LCD_busy() (LCD_rd() & 0x80) == 0x80
|
2264 |
|
|
+
|
2265 |
|
|
+void delay_ms(int ms)
|
2266 |
|
|
+{
|
2267 |
|
|
+ int i;
|
2268 |
|
|
+ for (i=0;i<ms;i++) {
|
2269 |
|
|
+ for (i=0; i < 10000; i++) __nop();
|
2270 |
|
|
+ }
|
2271 |
|
|
+}
|
2272 |
|
|
+
|
2273 |
|
|
+void LCD_init()
|
2274 |
|
|
+{
|
2275 |
|
|
+ LCD_wr(0x42);
|
2276 |
|
|
+ while (LCD_rd()) { __nop();}
|
2277 |
|
|
+ LCD_wr(0x43);
|
2278 |
|
|
+ delay_ms(10);
|
2279 |
|
|
+ LCD_wr(0x44);
|
2280 |
|
|
+ LCD_wr(0x45);
|
2281 |
|
|
+}
|
2282 |
|
|
+
|
2283 |
|
|
+void LCD_write(char ch)
|
2284 |
|
|
+{
|
2285 |
|
|
+ LCD_wr(0x46);
|
2286 |
|
|
+ LCD_wr(0x47);
|
2287 |
|
|
+}
|
2288 |
|
|
+
|
2289 |
|
|
+
|
2290 |
|
|
+int main(void) {
|
2291 |
|
|
+ char st = 0;
|
2292 |
|
|
+
|
2293 |
|
|
+ while(1) {
|
2294 |
|
|
+ LED_wr(st);
|
2295 |
|
|
+ st ^= 1;
|
2296 |
|
|
+ delay_ms(1000);
|
2297 |
|
|
+ }
|
2298 |
|
|
+/*
|
2299 |
|
|
+ char ch = 0x31;
|
2300 |
|
|
+ LCD_init();
|
2301 |
|
|
+ while (1) {
|
2302 |
|
|
+ LCD_write(ch);
|
2303 |
|
|
+ delay_ms(1000);
|
2304 |
|
|
+ }
|
2305 |
|
|
+*/
|
2306 |
|
|
+}
|
2307 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/operators.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/operators.c
|
2308 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/operators.c 1970-01-01 01:00:00.000000000 +0100
|
2309 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/operators.c 2011-08-23 15:57:24.000000000 +0200
|
2310 |
|
|
@@ -0,0 +1,11 @@
|
2311 |
|
|
+int main()
|
2312 |
|
|
+{
|
2313 |
|
|
+ int i = 0;
|
2314 |
|
|
+ int j = 13;
|
2315 |
|
|
+zkouska:
|
2316 |
|
|
+ i += 2;
|
2317 |
|
|
+ j -= i;
|
2318 |
|
|
+ i |= j;
|
2319 |
|
|
+ goto zkouska;
|
2320 |
|
|
+ return i*j;
|
2321 |
|
|
+}
|
2322 |
|
|
\ No newline at end of file
|
2323 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/pointers.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/pointers.c
|
2324 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/pointers.c 1970-01-01 01:00:00.000000000 +0100
|
2325 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/pointers.c 2011-08-23 15:57:24.000000000 +0200
|
2326 |
|
|
@@ -0,0 +1 @@
|
2327 |
|
|
+// TODO
|
2328 |
|
|
\ No newline at end of file
|
2329 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/simplefunc.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/simplefunc.c
|
2330 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/simplefunc.c 1970-01-01 01:00:00.000000000 +0100
|
2331 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/simplefunc.c 2011-08-23 15:57:24.000000000 +0200
|
2332 |
|
|
@@ -0,0 +1,12 @@
|
2333 |
|
|
+char inc(char number)
|
2334 |
|
|
+{
|
2335 |
|
|
+ return number + 1;
|
2336 |
|
|
+}
|
2337 |
|
|
+
|
2338 |
|
|
+
|
2339 |
|
|
+void main()
|
2340 |
|
|
+{
|
2341 |
|
|
+ char c = 42;
|
2342 |
|
|
+ inc(c);
|
2343 |
|
|
+
|
2344 |
|
|
+}
|
2345 |
|
|
\ No newline at end of file
|
2346 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/stubs.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/stubs.c
|
2347 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/stubs.c 1970-01-01 01:00:00.000000000 +0100
|
2348 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/stubs.c 2011-08-23 15:57:24.000000000 +0200
|
2349 |
|
|
@@ -0,0 +1,5 @@
|
2350 |
|
|
+void main()
|
2351 |
|
|
+{
|
2352 |
|
|
+int i = 42;
|
2353 |
|
|
+for (;;) {i--;};
|
2354 |
|
|
+}
|
2355 |
|
|
\ No newline at end of file
|
2356 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/test10.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/test10.c
|
2357 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/test10.c 1970-01-01 01:00:00.000000000 +0100
|
2358 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/test10.c 2011-08-23 15:57:24.000000000 +0200
|
2359 |
|
|
@@ -0,0 +1,23 @@
|
2360 |
|
|
+// test array of ints
|
2361 |
|
|
+
|
2362 |
|
|
+#define ARRAY_SIZE 10
|
2363 |
|
|
+
|
2364 |
|
|
+volatile short numbers[ARRAY_SIZE] = {9,8,7,6,5,4,3,2,1,0};
|
2365 |
|
|
+
|
2366 |
|
|
+void main()
|
2367 |
|
|
+{
|
2368 |
|
|
+ short i, j, temp;
|
2369 |
|
|
+
|
2370 |
|
|
+ for (i = (ARRAY_SIZE - 1); i > 0; i--)
|
2371 |
|
|
+ {
|
2372 |
|
|
+ for (j = 1; j <= i; j++)
|
2373 |
|
|
+ {
|
2374 |
|
|
+ if (numbers[j-1] > numbers[j])
|
2375 |
|
|
+ {
|
2376 |
|
|
+ temp = numbers[j-1];
|
2377 |
|
|
+ numbers[j-1] = numbers[j];
|
2378 |
|
|
+ numbers[j] = temp;
|
2379 |
|
|
+ }
|
2380 |
|
|
+ }
|
2381 |
|
|
+ }
|
2382 |
|
|
+}
|
2383 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/test6.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/test6.c
|
2384 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/test6.c 1970-01-01 01:00:00.000000000 +0100
|
2385 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/test6.c 2011-08-23 15:57:24.000000000 +0200
|
2386 |
|
|
@@ -0,0 +1,22 @@
|
2387 |
|
|
+// interrupt handler test for pBlazeIDE
|
2388 |
|
|
+
|
2389 |
|
|
+char __xdata val = 0;
|
2390 |
|
|
+char __xdata c;
|
2391 |
|
|
+
|
2392 |
|
|
+void interruptHandler() __interrupt
|
2393 |
|
|
+{
|
2394 |
|
|
+ val++;
|
2395 |
|
|
+}
|
2396 |
|
|
+
|
2397 |
|
|
+void main()
|
2398 |
|
|
+{
|
2399 |
|
|
+ c = 0;
|
2400 |
|
|
+ __asm
|
2401 |
|
|
+ EINT
|
2402 |
|
|
+ __endasm;
|
2403 |
|
|
+
|
2404 |
|
|
+ for (;;) {
|
2405 |
|
|
+
|
2406 |
|
|
+ c += 4;
|
2407 |
|
|
+ }
|
2408 |
|
|
+}
|
2409 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/test7.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/test7.c
|
2410 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/test7.c 1970-01-01 01:00:00.000000000 +0100
|
2411 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/test7.c 2011-08-23 15:57:24.000000000 +0200
|
2412 |
|
|
@@ -0,0 +1,30 @@
|
2413 |
|
|
+// test bitových operacà všeho druhu (pBlazeIDE)
|
2414 |
|
|
+
|
2415 |
|
|
+void main()
|
2416 |
|
|
+{
|
2417 |
|
|
+ volatile unsigned char c = 1;
|
2418 |
|
|
+ volatile unsigned char d = 1;
|
2419 |
|
|
+ volatile unsigned char e = 15;
|
2420 |
|
|
+
|
2421 |
|
|
+ c <<= 4;
|
2422 |
|
|
+
|
2423 |
|
|
+ c >>= 3;
|
2424 |
|
|
+
|
2425 |
|
|
+ c |= c;
|
2426 |
|
|
+
|
2427 |
|
|
+ c |= d + 1;
|
2428 |
|
|
+
|
2429 |
|
|
+ c = c & d;
|
2430 |
|
|
+
|
2431 |
|
|
+ d = ~e;
|
2432 |
|
|
+
|
2433 |
|
|
+ e = c ^ d;
|
2434 |
|
|
+
|
2435 |
|
|
+ c = !c && d || e;
|
2436 |
|
|
+ c = c || e;
|
2437 |
|
|
+
|
2438 |
|
|
+ if (!c)
|
2439 |
|
|
+ {
|
2440 |
|
|
+ c = -e;
|
2441 |
|
|
+ }
|
2442 |
|
|
+}
|
2443 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/test8.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/test8.c
|
2444 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/test8.c 1970-01-01 01:00:00.000000000 +0100
|
2445 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/test8.c 2011-08-23 15:57:24.000000000 +0200
|
2446 |
|
|
@@ -0,0 +1,31 @@
|
2447 |
|
|
+// switch test
|
2448 |
|
|
+
|
2449 |
|
|
+void main()
|
2450 |
|
|
+{
|
2451 |
|
|
+ volatile char c = 5;
|
2452 |
|
|
+
|
2453 |
|
|
+ // JUMPTABLE generated
|
2454 |
|
|
+ switch(c)
|
2455 |
|
|
+ {
|
2456 |
|
|
+ case 10: c = 11; break;
|
2457 |
|
|
+ case 11: c = 22; break;
|
2458 |
|
|
+ case 12: c = 33; break;
|
2459 |
|
|
+ case 13: c = 44; break;
|
2460 |
|
|
+ case 14: c = 55; break;
|
2461 |
|
|
+ default: c = 99;
|
2462 |
|
|
+ break;
|
2463 |
|
|
+ }
|
2464 |
|
|
+
|
2465 |
|
|
+ // sequence of IFXs generated
|
2466 |
|
|
+ switch(c)
|
2467 |
|
|
+ {
|
2468 |
|
|
+ case 10: c = 11; break;
|
2469 |
|
|
+ case 23: c = 22; break;
|
2470 |
|
|
+ case 31: c = 33; break;
|
2471 |
|
|
+ case 4: c = 44; break;
|
2472 |
|
|
+ case 59: c = 55; break;
|
2473 |
|
|
+ default: c = 99;
|
2474 |
|
|
+ break;
|
2475 |
|
|
+ }
|
2476 |
|
|
+
|
2477 |
|
|
+}
|
2478 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/test9.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/test9.c
|
2479 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/test9.c 1970-01-01 01:00:00.000000000 +0100
|
2480 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/test9.c 2011-08-23 15:57:24.000000000 +0200
|
2481 |
|
|
@@ -0,0 +1,17 @@
|
2482 |
|
|
+// test bitových operacà - problem with NOT_OP (pBlazeIDE)
|
2483 |
|
|
+
|
2484 |
|
|
+/* link the C libarary */
|
2485 |
|
|
+
|
2486 |
|
|
+//#pragma library c
|
2487 |
|
|
+
|
2488 |
|
|
+void main()
|
2489 |
|
|
+{
|
2490 |
|
|
+ volatile char c = 1;
|
2491 |
|
|
+ c = !c;
|
2492 |
|
|
+ c = 0;
|
2493 |
|
|
+ c = !c;
|
2494 |
|
|
+ c = c && c;
|
2495 |
|
|
+ c = c || c;
|
2496 |
|
|
+ c = 29;
|
2497 |
|
|
+ c = c % 13;
|
2498 |
|
|
+}
|
2499 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/testINOUT.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/testINOUT.c
|
2500 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/testINOUT.c 1970-01-01 01:00:00.000000000 +0100
|
2501 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/testINOUT.c 2011-08-23 15:57:24.000000000 +0200
|
2502 |
|
|
@@ -0,0 +1,20 @@
|
2503 |
|
|
+// test INPUT/OUTPUT instrukci
|
2504 |
|
|
+volatile char gl = 5;
|
2505 |
|
|
+
|
2506 |
|
|
+// definice portu
|
2507 |
|
|
+extern char PBLAZEPORT[];
|
2508 |
|
|
+
|
2509 |
|
|
+void fun(char *a)
|
2510 |
|
|
+{
|
2511 |
|
|
+ char i;
|
2512 |
|
|
+ for(i = 0; i < *a; i++) {
|
2513 |
|
|
+ PBLAZEPORT[i] = gl;
|
2514 |
|
|
+ }
|
2515 |
|
|
+}
|
2516 |
|
|
+
|
2517 |
|
|
+void main()
|
2518 |
|
|
+{
|
2519 |
|
|
+ char a = PBLAZEPORT[5];
|
2520 |
|
|
+ fun(&a);
|
2521 |
|
|
+
|
2522 |
|
|
+}
|
2523 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/testM2.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/testM2.c
|
2524 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/testM2.c 1970-01-01 01:00:00.000000000 +0100
|
2525 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/testM2.c 2011-08-23 15:57:24.000000000 +0200
|
2526 |
|
|
@@ -0,0 +1,35 @@
|
2527 |
|
|
+// test ruzne typy ukazatelu
|
2528 |
|
|
+
|
2529 |
|
|
+int pole[] = {100,200,300,400};
|
2530 |
|
|
+char text[] = "Pepa";
|
2531 |
|
|
+int nepole = 6;
|
2532 |
|
|
+volatile int *vgptr;
|
2533 |
|
|
+int *gptr;
|
2534 |
|
|
+
|
2535 |
|
|
+
|
2536 |
|
|
+char fun( volatile char *a, int b, char c, char *d)
|
2537 |
|
|
+{
|
2538 |
|
|
+ volatile char val = 0;
|
2539 |
|
|
+ char t1 = *d;
|
2540 |
|
|
+
|
2541 |
|
|
+ val = val * c;
|
2542 |
|
|
+ b = pole[3] & pole[1];
|
2543 |
|
|
+ text[2] = 'R';
|
2544 |
|
|
+ *d = text[3];
|
2545 |
|
|
+ return t1 + b + nepole;
|
2546 |
|
|
+}
|
2547 |
|
|
+
|
2548 |
|
|
+void main()
|
2549 |
|
|
+{
|
2550 |
|
|
+ volatile char a = 10;
|
2551 |
|
|
+ volatile char b = 20;
|
2552 |
|
|
+ char c = 30;
|
2553 |
|
|
+ gptr = &nepole;
|
2554 |
|
|
+ vgptr = &nepole;
|
2555 |
|
|
+ pole[1] = 150;
|
2556 |
|
|
+ pole[0] = *gptr;
|
2557 |
|
|
+ *vgptr = 18;
|
2558 |
|
|
+ fun(&a,555,c, &c);
|
2559 |
|
|
+ nepole = c;
|
2560 |
|
|
+
|
2561 |
|
|
+}
|
2562 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/examples/pblaze/types.c sdcc-src-3.1.0-pblaze/device/examples/pblaze/types.c
|
2563 |
|
|
--- sdcc-src-3.1.0/device/examples/pblaze/types.c 1970-01-01 01:00:00.000000000 +0100
|
2564 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/examples/pblaze/types.c 2011-08-23 15:57:24.000000000 +0200
|
2565 |
|
|
@@ -0,0 +1,18 @@
|
2566 |
|
|
+int i;
|
2567 |
|
|
+struct stype {
|
2568 |
|
|
+ int x;
|
2569 |
|
|
+ int y;
|
2570 |
|
|
+} str;
|
2571 |
|
|
+
|
2572 |
|
|
+int f(char a, short b)
|
2573 |
|
|
+{
|
2574 |
|
|
+ return a + b;
|
2575 |
|
|
+}
|
2576 |
|
|
+
|
2577 |
|
|
+
|
2578 |
|
|
+int main(void)
|
2579 |
|
|
+{
|
2580 |
|
|
+// stype lstr;
|
2581 |
|
|
+ i = str.x = str.y = 13;
|
2582 |
|
|
+ return f(i, str.x);
|
2583 |
|
|
+}
|
2584 |
|
|
\ No newline at end of file
|
2585 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/Makefile.in sdcc-src-3.1.0-pblaze/device/include/Makefile.in
|
2586 |
|
|
--- sdcc-src-3.1.0/device/include/Makefile.in 2011-10-12 16:09:15.000000000 +0200
|
2587 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/Makefile.in 2011-12-05 22:46:57.573665600 +0100
|
2588 |
|
|
@@ -71,6 +71,10 @@
|
2589 |
|
|
done; \
|
2590 |
|
|
done; \
|
2591 |
|
|
fi
|
2592 |
|
|
+ # picoblaze
|
2593 |
|
|
+ if [ "`grep pblaze $(top_builddir)/ports.build`" = pblaze ]; then \
|
2594 |
|
|
+ $(CP) $(srcdir)/pblaze/*.h $(sdcc_includedir)/pblaze; \
|
2595 |
|
|
+ fi
|
2596 |
|
|
find $(sdcc_includedir) -type d -name '.svn' -exec rm -rf {} \;
|
2597 |
|
|
# correct file modes
|
2598 |
|
|
find $(sdcc_includedir) -type f -exec chmod 644 {} \;
|
2599 |
|
|
@@ -96,7 +100,7 @@
|
2600 |
|
|
# ---------------------------------
|
2601 |
|
|
installdirs:
|
2602 |
|
|
mkdir -p $(sdcc_includedir)
|
2603 |
|
|
- for target in mcs51 ds390 ds400 pic14 pic16 z80 z180 gbz80 hc08; \
|
2604 |
|
|
+ for target in mcs51 ds390 ds400 pic14 pic16 z80 z180 gbz80 hc08 pblaze; \
|
2605 |
|
|
do \
|
2606 |
|
|
if [ -d $(srcdir)/$${target} ]; \
|
2607 |
|
|
then \
|
2608 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/ctype.h sdcc-src-3.1.0-pblaze/device/include/pblaze/ctype.h
|
2609 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/ctype.h 1970-01-01 01:00:00.000000000 +0100
|
2610 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/ctype.h 2011-08-23 15:56:36.000000000 +0200
|
2611 |
|
|
@@ -0,0 +1,74 @@
|
2612 |
|
|
+/*-------------------------------------------------------------------------
|
2613 |
|
|
+ ctype.h - ANSI functions forward declarations
|
2614 |
|
|
+
|
2615 |
|
|
+ Modified for pic16 port by Vangelis Rokas, 2004, vrokas@otenet.gr
|
2616 |
|
|
+
|
2617 |
|
|
+ Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
|
2618 |
|
|
+
|
2619 |
|
|
+ Revisions:
|
2620 |
|
|
+ 1.0 - June.1.2000 1.0 - Bela Torok / bela.torok@kssg.ch
|
2621 |
|
|
+ order: function definitions -> macros
|
2622 |
|
|
+ corretced macro: isalpha(c)
|
2623 |
|
|
+ added macros: _tolower(c), _toupper(c), tolower(c), toupper(c) toascii(c)
|
2624 |
|
|
+
|
2625 |
|
|
+
|
2626 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
2627 |
|
|
+ under the terms of the GNU General Public License as published by the
|
2628 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
2629 |
|
|
+ later version.
|
2630 |
|
|
+
|
2631 |
|
|
+ This program is distributed in the hope that it will be useful,
|
2632 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2633 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2634 |
|
|
+ GNU General Public License for more details.
|
2635 |
|
|
+
|
2636 |
|
|
+ You should have received a copy of the GNU General Public License
|
2637 |
|
|
+ along with this program; if not, write to the Free Software
|
2638 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
2639 |
|
|
+
|
2640 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
2641 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
2642 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
2643 |
|
|
+-------------------------------------------------------------------------*/
|
2644 |
|
|
+
|
2645 |
|
|
+/*
|
2646 |
|
|
+** $Id: ctype.h 3648 2005-01-22 18:02:16Z vrokas $
|
2647 |
|
|
+*/
|
2648 |
|
|
+
|
2649 |
|
|
+
|
2650 |
|
|
+#ifndef __CTYPE_H
|
2651 |
|
|
+#define __CTYPE_H 1
|
2652 |
|
|
+
|
2653 |
|
|
+/* link the C libarary */
|
2654 |
|
|
+#pragma library c
|
2655 |
|
|
+
|
2656 |
|
|
+#include <sdcc-lib.h>
|
2657 |
|
|
+
|
2658 |
|
|
+extern char iscntrl (unsigned char ) ;
|
2659 |
|
|
+extern char isdigit (unsigned char ) ;
|
2660 |
|
|
+extern char isgraph (unsigned char ) ;
|
2661 |
|
|
+extern char islower (unsigned char ) ;
|
2662 |
|
|
+extern char isupper (unsigned char ) ;
|
2663 |
|
|
+extern char isprint (unsigned char ) ;
|
2664 |
|
|
+extern char ispunct (unsigned char ) ;
|
2665 |
|
|
+extern char isspace (unsigned char ) ;
|
2666 |
|
|
+extern char isxdigit (unsigned char ) ;
|
2667 |
|
|
+
|
2668 |
|
|
+#define isalnum(c) (isalpha(c) || isdigit(c))
|
2669 |
|
|
+#define isalpha(c) (isupper(c) || islower(c))
|
2670 |
|
|
+
|
2671 |
|
|
+/* ANSI versions of _tolower & _toupper
|
2672 |
|
|
+#define _tolower(c) ((c) - ('a' - 'A'))
|
2673 |
|
|
+#define _toupper(c) ((c) + ('a' - 'A'))
|
2674 |
|
|
+*/
|
2675 |
|
|
+
|
2676 |
|
|
+// The _tolower & _toupper functions below can applied to any
|
2677 |
|
|
+// alpha characters regardless of the case (upper or lower)
|
2678 |
|
|
+#define _tolower(c) ((c) | ('a' - 'A'))
|
2679 |
|
|
+#define _toupper(c) ((c) & ~('a' - 'A'))
|
2680 |
|
|
+
|
2681 |
|
|
+#define tolower(c) ((isupper(c)) ? _tolower(c) : (c))
|
2682 |
|
|
+#define toupper(c) ((islower(c)) ? _toupper(c) : (c))
|
2683 |
|
|
+#define toascii(c) ((c) & 0x7F)
|
2684 |
|
|
+
|
2685 |
|
|
+#endif
|
2686 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/delay.h sdcc-src-3.1.0-pblaze/device/include/pblaze/delay.h
|
2687 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/delay.h 1970-01-01 01:00:00.000000000 +0100
|
2688 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/delay.h 2011-08-23 15:56:36.000000000 +0200
|
2689 |
|
|
@@ -0,0 +1,75 @@
|
2690 |
|
|
+
|
2691 |
|
|
+/*
|
2692 |
|
|
+ * delay.h - delay functions header file
|
2693 |
|
|
+ *
|
2694 |
|
|
+ * adopted for SDCC and picoBlaze port by Zbynek Krivka, 2010 <krivka @ fit.vutbr.cz>
|
2695 |
|
|
+ *
|
2696 |
|
|
+ * This program is free software; you can redistribute it and/or
|
2697 |
|
|
+ * modify it under the terms of the GNU Library General Public License
|
2698 |
|
|
+ * as published by the Free Software Foundation; either version 2
|
2699 |
|
|
+ * of the License, or (at your option) any later version.
|
2700 |
|
|
+ *
|
2701 |
|
|
+ * This library is distributed in the hope that it will be useful,
|
2702 |
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2703 |
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2704 |
|
|
+ * GNU General Public License for more details.
|
2705 |
|
|
+ *
|
2706 |
|
|
+ * You should have received a copy of the GNU General Public License
|
2707 |
|
|
+ * along with this program; if not, write to the Free Software
|
2708 |
|
|
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
2709 |
|
|
+ */
|
2710 |
|
|
+
|
2711 |
|
|
+#ifndef __DELAY_H__
|
2712 |
|
|
+#define __DELAY_H__
|
2713 |
|
|
+
|
2714 |
|
|
+
|
2715 |
|
|
+//#pragma library c
|
2716 |
|
|
+
|
2717 |
|
|
+/*
|
2718 |
|
|
+ * the delayNNtcy family of functions performs a
|
2719 |
|
|
+ * delay of NN cycles. Possible values for NN are:
|
2720 |
|
|
+ * 10 10*n cycles delay
|
2721 |
|
|
+ * 100 100*n cycles delay
|
2722 |
|
|
+ * 1k 1000*n cycles delay
|
2723 |
|
|
+ * 10k 10000*n cycles delay
|
2724 |
|
|
+ * 100k 100000*n cycles delay
|
2725 |
|
|
+ * 1m 1000000*n cycles delay
|
2726 |
|
|
+ */
|
2727 |
|
|
+
|
2728 |
|
|
+/*
|
2729 |
|
|
+void delay10tcy(unsigned char) __wparam;
|
2730 |
|
|
+void delay100tcy(unsigned char) __wparam;
|
2731 |
|
|
+void delay1ktcy(unsigned char) __wparam;
|
2732 |
|
|
+void delay10ktcy(unsigned char) __wparam;
|
2733 |
|
|
+void delay100ktcy(unsigned char) __wparam;
|
2734 |
|
|
+void delay1mtcy(unsigned char) __wparam;
|
2735 |
|
|
+*/
|
2736 |
|
|
+
|
2737 |
|
|
+void delay(unsigned char time);
|
2738 |
|
|
+//TODO: void delay(unsigned int time);
|
2739 |
|
|
+
|
2740 |
|
|
+void delay(unsigned char time)
|
2741 |
|
|
+{
|
2742 |
|
|
+ volatile unsigned char i = time;
|
2743 |
|
|
+ for(; i > 0; i--)
|
2744 |
|
|
+ {
|
2745 |
|
|
+ __asm
|
2746 |
|
|
+ LOAD s2, 00
|
2747 |
|
|
+ ADD s2, 01
|
2748 |
|
|
+
|
2749 |
|
|
+ LOAD s1, 00
|
2750 |
|
|
+rpt22:
|
2751 |
|
|
+ ADD s1, 01
|
2752 |
|
|
+
|
2753 |
|
|
+ LOAD s0, 00
|
2754 |
|
|
+rpt11:
|
2755 |
|
|
+ ADD s0, 01
|
2756 |
|
|
+ JUMP NZ, rpt11
|
2757 |
|
|
+
|
2758 |
|
|
+ COMPARE s1, 00
|
2759 |
|
|
+ JUMP NZ, rpt22
|
2760 |
|
|
+
|
2761 |
|
|
+ __endasm;
|
2762 |
|
|
+ }
|
2763 |
|
|
+}
|
2764 |
|
|
+#endif
|
2765 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/intr.h sdcc-src-3.1.0-pblaze/device/include/pblaze/intr.h
|
2766 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/intr.h 1970-01-01 01:00:00.000000000 +0100
|
2767 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/intr.h 2011-08-23 15:56:36.000000000 +0200
|
2768 |
|
|
@@ -0,0 +1,59 @@
|
2769 |
|
|
+/*
|
2770 |
|
|
+ * intr.h - Interrupts functions header file for FITKit
|
2771 |
|
|
+ *
|
2772 |
|
|
+ * adopted for SDCC and picoBlaze port by Zbynek Krivka, 2010 <krivka @ fit.vutbr.cz>
|
2773 |
|
|
+ *
|
2774 |
|
|
+*/
|
2775 |
|
|
+
|
2776 |
|
|
+#ifndef __INTR_H__
|
2777 |
|
|
+#define __INTR_H__
|
2778 |
|
|
+
|
2779 |
|
|
+#define KCPSM
|
2780 |
|
|
+
|
2781 |
|
|
+#ifdef KCPSM
|
2782 |
|
|
+#define EINT ENABLE INTERRUPT
|
2783 |
|
|
+#define DINT DISABLE INTERRUPT
|
2784 |
|
|
+#else
|
2785 |
|
|
+#define EINT EINT
|
2786 |
|
|
+#define DINT DINT
|
2787 |
|
|
+#endif
|
2788 |
|
|
+
|
2789 |
|
|
+#define BOOL unsigned char
|
2790 |
|
|
+
|
2791 |
|
|
+void pbcc_enable_interrupt(void);
|
2792 |
|
|
+void pbcc_disable_interrupt(void);
|
2793 |
|
|
+//inline bool pbcc_enabled_interrupt();
|
2794 |
|
|
+//void pbcc_set_interrupt_handler(void *(void))
|
2795 |
|
|
+//void pbcc_set_interrupt(BOOL enable);
|
2796 |
|
|
+
|
2797 |
|
|
+
|
2798 |
|
|
+void pbcc_enable_interrupt(void)
|
2799 |
|
|
+{
|
2800 |
|
|
+ __asm
|
2801 |
|
|
+ EINT
|
2802 |
|
|
+ __endasm;
|
2803 |
|
|
+}
|
2804 |
|
|
+
|
2805 |
|
|
+void pbcc_disable_interrupt(void)
|
2806 |
|
|
+{
|
2807 |
|
|
+ __asm;
|
2808 |
|
|
+ DINT
|
2809 |
|
|
+ __endasm;
|
2810 |
|
|
+}
|
2811 |
|
|
+/*
|
2812 |
|
|
+void pbcc_set_interrupt(BOOL enable)
|
2813 |
|
|
+{
|
2814 |
|
|
+ if (enable)
|
2815 |
|
|
+ {
|
2816 |
|
|
+ pbcc_enable_interrupt();
|
2817 |
|
|
+ }
|
2818 |
|
|
+ else
|
2819 |
|
|
+ {
|
2820 |
|
|
+ pbcc_disable_interrupt();
|
2821 |
|
|
+ }
|
2822 |
|
|
+
|
2823 |
|
|
+}
|
2824 |
|
|
+*/
|
2825 |
|
|
+#endif
|
2826 |
|
|
+
|
2827 |
|
|
+
|
2828 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/kbd.h sdcc-src-3.1.0-pblaze/device/include/pblaze/kbd.h
|
2829 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/kbd.h 1970-01-01 01:00:00.000000000 +0100
|
2830 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/kbd.h 2011-08-23 15:56:36.000000000 +0200
|
2831 |
|
|
@@ -0,0 +1,169 @@
|
2832 |
|
|
+/*
|
2833 |
|
|
+ * kbd.h - Keyboarch (16 keys) peripheral functions header file for FITKit
|
2834 |
|
|
+ *
|
2835 |
|
|
+ * adopted for SDCC and picoBlaze port by Zbynek Krivka, 2010 <krivka @ fit.vutbr.cz>
|
2836 |
|
|
+ *
|
2837 |
|
|
+*/
|
2838 |
|
|
+
|
2839 |
|
|
+#ifndef __KBD_H__
|
2840 |
|
|
+#define __KBD_H__
|
2841 |
|
|
+
|
2842 |
|
|
+#include "delay.h"
|
2843 |
|
|
+#include "port.h"
|
2844 |
|
|
+
|
2845 |
|
|
+#define port_kb_low 60
|
2846 |
|
|
+#define port_kb_high 61
|
2847 |
|
|
+
|
2848 |
|
|
+#define CHAR_SPACE 0x20
|
2849 |
|
|
+#define CHAR_0 0x30
|
2850 |
|
|
+#define CHAR_1 0x31
|
2851 |
|
|
+#define CHAR_2 0x32
|
2852 |
|
|
+#define CHAR_3 0x33
|
2853 |
|
|
+#define CHAR_4 0x34
|
2854 |
|
|
+#define CHAR_5 0x35
|
2855 |
|
|
+#define CHAR_6 0x36
|
2856 |
|
|
+#define CHAR_7 0x37
|
2857 |
|
|
+#define CHAR_8 0x38
|
2858 |
|
|
+#define CHAR_9 0x39
|
2859 |
|
|
+#define CHAR_A 0x41
|
2860 |
|
|
+#define CHAR_B 0x42
|
2861 |
|
|
+#define CHAR_C 0x43
|
2862 |
|
|
+#define CHAR_D 0x44
|
2863 |
|
|
+#define CHAR_STAR 0x2A
|
2864 |
|
|
+#define CHAR_HASH 0x23
|
2865 |
|
|
+
|
2866 |
|
|
+#define ASM_CHAR_SPACE 20
|
2867 |
|
|
+#define ASM_CHAR_0 30
|
2868 |
|
|
+#define ASM_CHAR_1 31
|
2869 |
|
|
+#define ASM_CHAR_2 32
|
2870 |
|
|
+#define ASM_CHAR_3 33
|
2871 |
|
|
+#define ASM_CHAR_4 34
|
2872 |
|
|
+#define ASM_CHAR_5 35
|
2873 |
|
|
+#define ASM_CHAR_6 36
|
2874 |
|
|
+#define ASM_CHAR_7 37
|
2875 |
|
|
+#define ASM_CHAR_8 38
|
2876 |
|
|
+#define ASM_CHAR_9 39
|
2877 |
|
|
+#define ASM_CHAR_A 41
|
2878 |
|
|
+#define ASM_CHAR_B 42
|
2879 |
|
|
+#define ASM_CHAR_C 43
|
2880 |
|
|
+#define ASM_CHAR_D 44
|
2881 |
|
|
+#define ASM_CHAR_STAR 2A
|
2882 |
|
|
+#define ASM_CHAR_HASH 23
|
2883 |
|
|
+
|
2884 |
|
|
+
|
2885 |
|
|
+unsigned char readkey()
|
2886 |
|
|
+{
|
2887 |
|
|
+ volatile unsigned char key = 0;
|
2888 |
|
|
+ __asm
|
2889 |
|
|
+ INPUT _key, port_kb_low
|
2890 |
|
|
+xch1:
|
2891 |
|
|
+ SRA _key
|
2892 |
|
|
+ JUMP NC, xch4
|
2893 |
|
|
+ LOAD _key, ASM_CHAR_1
|
2894 |
|
|
+ JUMP xchno
|
2895 |
|
|
+
|
2896 |
|
|
+xch4:
|
2897 |
|
|
+ SRA _key
|
2898 |
|
|
+ JUMP NC, xch7
|
2899 |
|
|
+ LOAD _key, ASM_CHAR_4
|
2900 |
|
|
+ JUMP xchno
|
2901 |
|
|
+
|
2902 |
|
|
+xch7:
|
2903 |
|
|
+ SRA _key
|
2904 |
|
|
+ JUMP NC, xchs
|
2905 |
|
|
+ LOAD _key, ASM_CHAR_7
|
2906 |
|
|
+ JUMP xchno
|
2907 |
|
|
+
|
2908 |
|
|
+xchs:
|
2909 |
|
|
+ SRA _key
|
2910 |
|
|
+ JUMP NC, xch2
|
2911 |
|
|
+ LOAD _key, ASM_CHAR_STAR
|
2912 |
|
|
+ JUMP xchno
|
2913 |
|
|
+
|
2914 |
|
|
+xch2:
|
2915 |
|
|
+ SRA _key
|
2916 |
|
|
+ JUMP NC, xch5
|
2917 |
|
|
+ LOAD _key, ASM_CHAR_2
|
2918 |
|
|
+ JUMP xchno
|
2919 |
|
|
+
|
2920 |
|
|
+xch5:
|
2921 |
|
|
+ SRA _key
|
2922 |
|
|
+ JUMP NC, xch8
|
2923 |
|
|
+ LOAD _key, ASM_CHAR_5
|
2924 |
|
|
+ JUMP xchno
|
2925 |
|
|
+
|
2926 |
|
|
+xch8:
|
2927 |
|
|
+ SRA _key
|
2928 |
|
|
+ JUMP NC, xch0
|
2929 |
|
|
+ LOAD _key, ASM_CHAR_8
|
2930 |
|
|
+ JUMP xchno
|
2931 |
|
|
+
|
2932 |
|
|
+xch0:
|
2933 |
|
|
+ SRA _key
|
2934 |
|
|
+ JUMP NC, xch3
|
2935 |
|
|
+ LOAD _key, ASM_CHAR_0
|
2936 |
|
|
+ JUMP xchno
|
2937 |
|
|
+
|
2938 |
|
|
+xch3:
|
2939 |
|
|
+ INPUT _key, port_kb_high
|
2940 |
|
|
+ SRA _key
|
2941 |
|
|
+ JUMP NC, xch6
|
2942 |
|
|
+ LOAD _key, ASM_CHAR_3
|
2943 |
|
|
+ JUMP xchno
|
2944 |
|
|
+
|
2945 |
|
|
+xch6:
|
2946 |
|
|
+ SRA _key
|
2947 |
|
|
+ JUMP NC, xch9
|
2948 |
|
|
+ LOAD _key, ASM_CHAR_6
|
2949 |
|
|
+ JUMP xchno
|
2950 |
|
|
+
|
2951 |
|
|
+xch9:
|
2952 |
|
|
+ SRA _key
|
2953 |
|
|
+ JUMP NC, xchm
|
2954 |
|
|
+ LOAD _key, ASM_CHAR_9
|
2955 |
|
|
+ JUMP xchno
|
2956 |
|
|
+
|
2957 |
|
|
+xchm:
|
2958 |
|
|
+ SRA _key
|
2959 |
|
|
+ JUMP NC, xcha
|
2960 |
|
|
+ LOAD _key, ASM_CHAR_HASH
|
2961 |
|
|
+ JUMP xchno
|
2962 |
|
|
+
|
2963 |
|
|
+xcha:
|
2964 |
|
|
+ SRA _key
|
2965 |
|
|
+ JUMP NC, xchb
|
2966 |
|
|
+ LOAD _key, ASM_CHAR_A
|
2967 |
|
|
+ JUMP xchno
|
2968 |
|
|
+
|
2969 |
|
|
+xchb:
|
2970 |
|
|
+ SRA _key
|
2971 |
|
|
+ JUMP NC, xchc
|
2972 |
|
|
+ LOAD _key, ASM_CHAR_B
|
2973 |
|
|
+ JUMP xchno
|
2974 |
|
|
+
|
2975 |
|
|
+xchc:
|
2976 |
|
|
+ SRA _key
|
2977 |
|
|
+ JUMP NC, xchd
|
2978 |
|
|
+ LOAD _key, ASM_CHAR_C
|
2979 |
|
|
+ JUMP xchno
|
2980 |
|
|
+
|
2981 |
|
|
+xchd:
|
2982 |
|
|
+ SRA _key
|
2983 |
|
|
+ JUMP NC, xchno
|
2984 |
|
|
+ LOAD _key, ASM_CHAR_D
|
2985 |
|
|
+
|
2986 |
|
|
+xchno:
|
2987 |
|
|
+
|
2988 |
|
|
+ __endasm;
|
2989 |
|
|
+
|
2990 |
|
|
+ return key;
|
2991 |
|
|
+}
|
2992 |
|
|
+
|
2993 |
|
|
+
|
2994 |
|
|
+
|
2995 |
|
|
+
|
2996 |
|
|
+
|
2997 |
|
|
+
|
2998 |
|
|
+
|
2999 |
|
|
+
|
3000 |
|
|
+#endif
|
3001 |
|
|
\ No newline at end of file
|
3002 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/lcd.h sdcc-src-3.1.0-pblaze/device/include/pblaze/lcd.h
|
3003 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/lcd.h 1970-01-01 01:00:00.000000000 +0100
|
3004 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/lcd.h 2011-08-23 15:56:36.000000000 +0200
|
3005 |
|
|
@@ -0,0 +1,96 @@
|
3006 |
|
|
+/*
|
3007 |
|
|
+ * lcd.h - LCD peripheral functions header file for FITKit
|
3008 |
|
|
+ *
|
3009 |
|
|
+ * adopted for SDCC and picoBlaze port by Zbynek Krivka, 2010 <krivka @ fit.vutbr.cz>
|
3010 |
|
|
+ *
|
3011 |
|
|
+*/
|
3012 |
|
|
+
|
3013 |
|
|
+#ifndef __LCD_H__
|
3014 |
|
|
+#define __LCD_H__
|
3015 |
|
|
+
|
3016 |
|
|
+#include "delay.h"
|
3017 |
|
|
+#include "port.h"
|
3018 |
|
|
+
|
3019 |
|
|
+#define port_lcd_high 41
|
3020 |
|
|
+#define port_lcd_low 40
|
3021 |
|
|
+#define LCD_CLEAR_DISPLAY 01
|
3022 |
|
|
+#define LCD_wr(arg) __port_write(0x40, (arg)); __port_write(0x41, 01)
|
3023 |
|
|
+#define MIN_PAUSE 10
|
3024 |
|
|
+
|
3025 |
|
|
+void LCD_clear(void);
|
3026 |
|
|
+void LCD_init(void);
|
3027 |
|
|
+void LCD_set_cursor(void);
|
3028 |
|
|
+void LCD_write(unsigned char ch);
|
3029 |
|
|
+
|
3030 |
|
|
+void LCD_clear(void)
|
3031 |
|
|
+{
|
3032 |
|
|
+ __asm
|
3033 |
|
|
+ ; LCD clear
|
3034 |
|
|
+ LOAD s6, LCD_CLEAR_DISPLAY
|
3035 |
|
|
+ OUTPUT s6, port_lcd_low
|
3036 |
|
|
+ LOAD s6, 00
|
3037 |
|
|
+ OUTPUT s6, port_lcd_high
|
3038 |
|
|
+ __endasm;
|
3039 |
|
|
+ delay(MIN_PAUSE);
|
3040 |
|
|
+}
|
3041 |
|
|
+
|
3042 |
|
|
+void LCD_set_cursor()
|
3043 |
|
|
+{
|
3044 |
|
|
+ __asm;
|
3045 |
|
|
+ ; LCD - set cursor at the line beginning
|
3046 |
|
|
+ LOAD s6, 80
|
3047 |
|
|
+ OUTPUT s6, port_lcd_low
|
3048 |
|
|
+ LOAD s6, 00
|
3049 |
|
|
+ OUTPUT s6, port_lcd_high
|
3050 |
|
|
+ __endasm;
|
3051 |
|
|
+ delay(MIN_PAUSE);
|
3052 |
|
|
+}
|
3053 |
|
|
+
|
3054 |
|
|
+void LCD_init()
|
3055 |
|
|
+{
|
3056 |
|
|
+ __asm
|
3057 |
|
|
+ ; LCD clear
|
3058 |
|
|
+ LOAD s6, LCD_CLEAR_DISPLAY
|
3059 |
|
|
+ OUTPUT s6, port_lcd_low
|
3060 |
|
|
+ LOAD s6, 00
|
3061 |
|
|
+ OUTPUT s6, port_lcd_high
|
3062 |
|
|
+ __endasm;
|
3063 |
|
|
+ delay(MIN_PAUSE);
|
3064 |
|
|
+ __asm
|
3065 |
|
|
+ ; LCD function set - 8-bit carry, display consists of 2 parts, font 5x8
|
3066 |
|
|
+ LOAD s6, 38
|
3067 |
|
|
+ OUTPUT s6, port_lcd_low
|
3068 |
|
|
+ LOAD s6, 00
|
3069 |
|
|
+ OUTPUT s6, port_lcd_high
|
3070 |
|
|
+ __endasm;
|
3071 |
|
|
+ delay(MIN_PAUSE);
|
3072 |
|
|
+ __asm
|
3073 |
|
|
+ ; LCD display - show the cursor, turn the display ON
|
3074 |
|
|
+ LOAD s6, 0E
|
3075 |
|
|
+ OUTPUT s6, port_lcd_low
|
3076 |
|
|
+ LOAD s6, 00
|
3077 |
|
|
+ OUTPUT s6, port_lcd_high
|
3078 |
|
|
+ __endasm;
|
3079 |
|
|
+ delay(MIN_PAUSE);
|
3080 |
|
|
+ __asm
|
3081 |
|
|
+ ; LCD entry mode - increment cursor address automatically
|
3082 |
|
|
+ LOAD s6, 06
|
3083 |
|
|
+ OUTPUT s6, port_lcd_low
|
3084 |
|
|
+ LOAD s6, 00
|
3085 |
|
|
+ OUTPUT s6, port_lcd_high
|
3086 |
|
|
+ __endasm;
|
3087 |
|
|
+
|
3088 |
|
|
+ LCD_set_cursor();
|
3089 |
|
|
+
|
3090 |
|
|
+ delay(MIN_PAUSE);
|
3091 |
|
|
+}
|
3092 |
|
|
+
|
3093 |
|
|
+void LCD_write(unsigned char ch)
|
3094 |
|
|
+{
|
3095 |
|
|
+ __port_write(0x40, ch);
|
3096 |
|
|
+ __port_write(0x41, 01);
|
3097 |
|
|
+}
|
3098 |
|
|
+
|
3099 |
|
|
+#endif
|
3100 |
|
|
+
|
3101 |
|
|
+
|
3102 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/limits.h sdcc-src-3.1.0-pblaze/device/include/pblaze/limits.h
|
3103 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/limits.h 1970-01-01 01:00:00.000000000 +0100
|
3104 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/limits.h 2011-08-23 15:56:36.000000000 +0200
|
3105 |
|
|
@@ -0,0 +1,51 @@
|
3106 |
|
|
+/*-------------------------------------------------------------------------
|
3107 |
|
|
+ limits.h - ANSI defines constants for sizes of integral types
|
3108 |
|
|
+
|
3109 |
|
|
+ Adopted for the picoBlaze port by Zbynek Krivka
|
3110 |
|
|
+ [ krivka @ fit.vutbr.cz ] 2010
|
3111 |
|
|
+
|
3112 |
|
|
+ Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
|
3113 |
|
|
+
|
3114 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
3115 |
|
|
+ under the terms of the GNU General Public License as published by the
|
3116 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
3117 |
|
|
+ later version.
|
3118 |
|
|
+
|
3119 |
|
|
+ This program is distributed in the hope that it will be useful,
|
3120 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
3121 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
3122 |
|
|
+ GNU General Public License for more details.
|
3123 |
|
|
+
|
3124 |
|
|
+ You should have received a copy of the GNU General Public License
|
3125 |
|
|
+ along with this program; if not, write to the Free Software
|
3126 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
3127 |
|
|
+
|
3128 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
3129 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
3130 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
3131 |
|
|
+-------------------------------------------------------------------------*/
|
3132 |
|
|
+
|
3133 |
|
|
+#ifndef __LIMITS_H
|
3134 |
|
|
+#define __LIMITS_H 1
|
3135 |
|
|
+
|
3136 |
|
|
+#define CHAR_BIT 8 /* bits in a char */
|
3137 |
|
|
+#define CHAR_MAX 127
|
3138 |
|
|
+#define CHAR_MIN -128
|
3139 |
|
|
+#define SCHAR_MAX CHAR_MAX
|
3140 |
|
|
+#define SCHAR_MIN CHAR_MIN
|
3141 |
|
|
+#define UCHAR_MAX 0xff
|
3142 |
|
|
+#define UCHAR_MIN 0
|
3143 |
|
|
+#define INT_MIN -32768
|
3144 |
|
|
+#define INT_MAX 32767
|
3145 |
|
|
+#define SHRT_MAX INT_MAX
|
3146 |
|
|
+#define SHRT_MIN INT_MIN
|
3147 |
|
|
+#define UINT_MAX 0xffff
|
3148 |
|
|
+#define UINT_MIN 0
|
3149 |
|
|
+#define USHRT_MAX UINT_MAX
|
3150 |
|
|
+#define USHRT_MIN UINT_MIN
|
3151 |
|
|
+#define LONG_MIN -2147483648
|
3152 |
|
|
+#define LONG_MAX 2147483647
|
3153 |
|
|
+#define ULONG_MAX 0xffffffff
|
3154 |
|
|
+#define ULONG_MIN 0
|
3155 |
|
|
+
|
3156 |
|
|
+#endif
|
3157 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/math.h sdcc-src-3.1.0-pblaze/device/include/pblaze/math.h
|
3158 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/math.h 1970-01-01 01:00:00.000000000 +0100
|
3159 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/math.h 2011-08-23 15:56:36.000000000 +0200
|
3160 |
|
|
@@ -0,0 +1,80 @@
|
3161 |
|
|
+/*
|
3162 |
|
|
+ * math.h - Basic Mathematical (decimal only) functions header file
|
3163 |
|
|
+ *
|
3164 |
|
|
+ * adopted for SDCC and picoBlaze port by Zbynek Krivka, 2010 <krivka @ fit.vutbr.cz>
|
3165 |
|
|
+ *
|
3166 |
|
|
+*/
|
3167 |
|
|
+
|
3168 |
|
|
+#ifndef __MATH_H__
|
3169 |
|
|
+#define __MATH_H__
|
3170 |
|
|
+
|
3171 |
|
|
+/*
|
3172 |
|
|
+#pragma library math
|
3173 |
|
|
+
|
3174 |
|
|
+#include <sdcc-lib.h>
|
3175 |
|
|
+
|
3176 |
|
|
+#define PI 3.1415926536
|
3177 |
|
|
+#define TWO_PI 6.2831853071
|
3178 |
|
|
+#define HALF_PI 1.5707963268
|
3179 |
|
|
+#define QUART_PI 0.7853981634
|
3180 |
|
|
+#define iPI 0.3183098862
|
3181 |
|
|
+#define iTWO_PI 0.1591549431
|
3182 |
|
|
+#define TWO_O_PI 0.6366197724
|
3183 |
|
|
+
|
3184 |
|
|
+// EPS=B**(-t/2), where B is the radix of the floating-point representation
|
3185 |
|
|
+// and there are t base-B digits in the significand. Therefore, for floats
|
3186 |
|
|
+// EPS=2**(-12). Also define EPS2=EPS*EPS.
|
3187 |
|
|
+#define EPS 244.14062E-6
|
3188 |
|
|
+#define EPS2 59.6046E-9
|
3189 |
|
|
+#define XMAX 3.402823466E+38
|
3190 |
|
|
+
|
3191 |
|
|
+union float_long
|
3192 |
|
|
+{
|
3193 |
|
|
+ float f;
|
3194 |
|
|
+ long l;
|
3195 |
|
|
+};
|
3196 |
|
|
+*/
|
3197 |
|
|
+
|
3198 |
|
|
+/**********************************************
|
3199 |
|
|
+ * Prototypes for float ANSI C math functions *
|
3200 |
|
|
+ **********************************************/
|
3201 |
|
|
+
|
3202 |
|
|
+/* Trigonometric functions */
|
3203 |
|
|
+/*
|
3204 |
|
|
+float sinf(const float x) _MATH_REENTRANT;
|
3205 |
|
|
+float cosf(const float x) _MATH_REENTRANT;
|
3206 |
|
|
+float tanf(const float x) _MATH_REENTRANT;
|
3207 |
|
|
+float cotf(const float x) _MATH_REENTRANT;
|
3208 |
|
|
+float asinf(const float x) _MATH_REENTRANT;
|
3209 |
|
|
+float acosf(const float x) _MATH_REENTRANT;
|
3210 |
|
|
+float atanf(const float x) _MATH_REENTRANT;
|
3211 |
|
|
+float atan2f(const float x, const float y);
|
3212 |
|
|
+*/
|
3213 |
|
|
+/* Hyperbolic functions */
|
3214 |
|
|
+/*
|
3215 |
|
|
+float sinhf(const float x) _MATH_REENTRANT;
|
3216 |
|
|
+float coshf(const float x) _MATH_REENTRANT;
|
3217 |
|
|
+float tanhf(const float x) _MATH_REENTRANT;
|
3218 |
|
|
+
|
3219 |
|
|
+/* Exponential, logarithmic and power functions */
|
3220 |
|
|
+/*
|
3221 |
|
|
+float expf(const float x);
|
3222 |
|
|
+float logf(const float x) _MATH_REENTRANT;
|
3223 |
|
|
+float log10f(const float x) _MATH_REENTRANT;
|
3224 |
|
|
+float powf(const float x, const float y);
|
3225 |
|
|
+float sqrtf(const float a) _MATH_REENTRANT;
|
3226 |
|
|
+*/
|
3227 |
|
|
+/* Nearest integer, absolute value, and remainder functions */
|
3228 |
|
|
+/*
|
3229 |
|
|
+float fabsf(const float x) _MATH_REENTRANT;
|
3230 |
|
|
+float frexpf(const float x, int *pw2);
|
3231 |
|
|
+float ldexpf(const float x, const int pw2);
|
3232 |
|
|
+float ceilf(float x) _MATH_REENTRANT;
|
3233 |
|
|
+float floorf(float x) _MATH_REENTRANT;
|
3234 |
|
|
+float modff(float x, float * y);
|
3235 |
|
|
+*/
|
3236 |
|
|
+
|
3237 |
|
|
+unsigned int pow(const unsigned int x, const unsigned int y);
|
3238 |
|
|
+unsigned int sqrt(const unsigned int a); //_MATH_REENTRANT;
|
3239 |
|
|
+
|
3240 |
|
|
+#endif /* __MATH_H */
|
3241 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/pblaze3.h sdcc-src-3.1.0-pblaze/device/include/pblaze/pblaze3.h
|
3242 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/pblaze3.h 1970-01-01 01:00:00.000000000 +0100
|
3243 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/pblaze3.h 2011-08-23 15:56:36.000000000 +0200
|
3244 |
|
|
@@ -0,0 +1,1070 @@
|
3245 |
|
|
+
|
3246 |
|
|
+/*
|
3247 |
|
|
+ * pblaze.h - PicoBlaze3 Device Library Header
|
3248 |
|
|
+ *
|
3249 |
|
|
+ * This file is part of the GNU PIC Library.
|
3250 |
|
|
+ *
|
3251 |
|
|
+ * January, 2004
|
3252 |
|
|
+ * The GNU PIC Library is maintained by,
|
3253 |
|
|
+ * Vangelis Rokas <vrokas@otenet.gr>
|
3254 |
|
|
+ *
|
3255 |
|
|
+ * $Id: pic18f452.h 3769 2005-05-24 11:22:24Z tecodev $
|
3256 |
|
|
+ *
|
3257 |
|
|
+ */
|
3258 |
|
|
+
|
3259 |
|
|
+#ifndef __PBLAZE3_H__
|
3260 |
|
|
+#define __PBLAZE3_H__
|
3261 |
|
|
+
|
3262 |
|
|
+extern __sfr __at (0xf80) PORTA;
|
3263 |
|
|
+typedef union {
|
3264 |
|
|
+ struct {
|
3265 |
|
|
+ unsigned RA0:1;
|
3266 |
|
|
+ unsigned RA1:1;
|
3267 |
|
|
+ unsigned RA2:1;
|
3268 |
|
|
+ unsigned RA3:1;
|
3269 |
|
|
+ unsigned RA4:1;
|
3270 |
|
|
+ unsigned RA5:1;
|
3271 |
|
|
+ unsigned RA6:1;
|
3272 |
|
|
+ unsigned :1;
|
3273 |
|
|
+ };
|
3274 |
|
|
+
|
3275 |
|
|
+ struct {
|
3276 |
|
|
+ unsigned AN0:1;
|
3277 |
|
|
+ unsigned AN1:1;
|
3278 |
|
|
+ unsigned AN2:1;
|
3279 |
|
|
+ unsigned AN3:1;
|
3280 |
|
|
+ unsigned :1;
|
3281 |
|
|
+ unsigned AN4:1;
|
3282 |
|
|
+ unsigned OSC2:1;
|
3283 |
|
|
+ unsigned :1;
|
3284 |
|
|
+ };
|
3285 |
|
|
+
|
3286 |
|
|
+ struct {
|
3287 |
|
|
+ unsigned :1;
|
3288 |
|
|
+ unsigned :1;
|
3289 |
|
|
+ unsigned VREFM:1;
|
3290 |
|
|
+ unsigned VREFP:1;
|
3291 |
|
|
+ unsigned T0CKI:1;
|
3292 |
|
|
+ unsigned SS:1;
|
3293 |
|
|
+ unsigned CLK0:1;
|
3294 |
|
|
+ unsigned :1;
|
3295 |
|
|
+ };
|
3296 |
|
|
+
|
3297 |
|
|
+ struct {
|
3298 |
|
|
+ unsigned :1;
|
3299 |
|
|
+ unsigned :1;
|
3300 |
|
|
+ unsigned :1;
|
3301 |
|
|
+ unsigned :1;
|
3302 |
|
|
+ unsigned :1;
|
3303 |
|
|
+ unsigned LVDIN:1;
|
3304 |
|
|
+ unsigned :1;
|
3305 |
|
|
+ unsigned :1;
|
3306 |
|
|
+ };
|
3307 |
|
|
+} __PORTAbits_t;
|
3308 |
|
|
+
|
3309 |
|
|
+extern volatile __PORTAbits_t __at (0xf80) PORTAbits;
|
3310 |
|
|
+
|
3311 |
|
|
+extern __sfr __at (0xf81) PORTB;
|
3312 |
|
|
+typedef union {
|
3313 |
|
|
+ struct {
|
3314 |
|
|
+ unsigned RB0:1;
|
3315 |
|
|
+ unsigned RB1:1;
|
3316 |
|
|
+ unsigned RB2:1;
|
3317 |
|
|
+ unsigned RB3:1;
|
3318 |
|
|
+ unsigned RB4:1;
|
3319 |
|
|
+ unsigned RB5:1;
|
3320 |
|
|
+ unsigned RB6:1;
|
3321 |
|
|
+ unsigned RB7:1;
|
3322 |
|
|
+ };
|
3323 |
|
|
+
|
3324 |
|
|
+ struct {
|
3325 |
|
|
+ unsigned INT0:1;
|
3326 |
|
|
+ unsigned INT1:1;
|
3327 |
|
|
+ unsigned INT2:1;
|
3328 |
|
|
+ unsigned INT3:1;
|
3329 |
|
|
+ unsigned :1;
|
3330 |
|
|
+ unsigned :1;
|
3331 |
|
|
+ unsigned :1;
|
3332 |
|
|
+ unsigned :1;
|
3333 |
|
|
+ };
|
3334 |
|
|
+} __PORTBbits_t;
|
3335 |
|
|
+
|
3336 |
|
|
+extern volatile __PORTBbits_t __at (0xf81) PORTBbits;
|
3337 |
|
|
+
|
3338 |
|
|
+extern __sfr __at (0xf82) PORTC;
|
3339 |
|
|
+typedef union {
|
3340 |
|
|
+ struct {
|
3341 |
|
|
+ unsigned RC0:1;
|
3342 |
|
|
+ unsigned RC1:1;
|
3343 |
|
|
+ unsigned RC2:1;
|
3344 |
|
|
+ unsigned RC3:1;
|
3345 |
|
|
+ unsigned RC4:1;
|
3346 |
|
|
+ unsigned RC5:1;
|
3347 |
|
|
+ unsigned RC6:1;
|
3348 |
|
|
+ unsigned RC7:1;
|
3349 |
|
|
+ };
|
3350 |
|
|
+
|
3351 |
|
|
+ struct {
|
3352 |
|
|
+ unsigned T1OSO:1;
|
3353 |
|
|
+ unsigned T1OSI:1;
|
3354 |
|
|
+ unsigned :1;
|
3355 |
|
|
+ unsigned SCK:1;
|
3356 |
|
|
+ unsigned SDI:1;
|
3357 |
|
|
+ unsigned SDO:1;
|
3358 |
|
|
+ unsigned TX:1;
|
3359 |
|
|
+ unsigned RX:1;
|
3360 |
|
|
+ };
|
3361 |
|
|
+
|
3362 |
|
|
+ struct {
|
3363 |
|
|
+ unsigned T1CKI:1;
|
3364 |
|
|
+ unsigned CCP2:1;
|
3365 |
|
|
+ unsigned CCP1:1;
|
3366 |
|
|
+ unsigned SCL:1;
|
3367 |
|
|
+ unsigned SDA:1;
|
3368 |
|
|
+ unsigned :1;
|
3369 |
|
|
+ unsigned CK:1;
|
3370 |
|
|
+ unsigned DT:1;
|
3371 |
|
|
+ };
|
3372 |
|
|
+} __PORTCbits_t;
|
3373 |
|
|
+
|
3374 |
|
|
+extern volatile __PORTCbits_t __at (0xf82) PORTCbits;
|
3375 |
|
|
+
|
3376 |
|
|
+extern __sfr __at (0xf83) PORTD;
|
3377 |
|
|
+typedef union {
|
3378 |
|
|
+ struct {
|
3379 |
|
|
+ unsigned RD0:1;
|
3380 |
|
|
+ unsigned RD1:1;
|
3381 |
|
|
+ unsigned RD2:1;
|
3382 |
|
|
+ unsigned RD3:1;
|
3383 |
|
|
+ unsigned RD4:1;
|
3384 |
|
|
+ unsigned RD5:1;
|
3385 |
|
|
+ unsigned RD6:1;
|
3386 |
|
|
+ unsigned RD7:1;
|
3387 |
|
|
+ };
|
3388 |
|
|
+
|
3389 |
|
|
+ struct {
|
3390 |
|
|
+ unsigned AD0:1;
|
3391 |
|
|
+ unsigned AD1:1;
|
3392 |
|
|
+ unsigned AD2:1;
|
3393 |
|
|
+ unsigned AD3:1;
|
3394 |
|
|
+ unsigned AD4:1;
|
3395 |
|
|
+ unsigned AD5:1;
|
3396 |
|
|
+ unsigned AD6:1;
|
3397 |
|
|
+ unsigned AD7:1;
|
3398 |
|
|
+ };
|
3399 |
|
|
+} __PORTDbits_t;
|
3400 |
|
|
+
|
3401 |
|
|
+extern volatile __PORTDbits_t __at (0xf83) PORTDbits;
|
3402 |
|
|
+
|
3403 |
|
|
+extern __sfr __at (0xf84) PORTE;
|
3404 |
|
|
+typedef union {
|
3405 |
|
|
+ struct {
|
3406 |
|
|
+ unsigned RE0:1;
|
3407 |
|
|
+ unsigned RE1:1;
|
3408 |
|
|
+ unsigned RE2:1;
|
3409 |
|
|
+ unsigned :1;
|
3410 |
|
|
+ unsigned :1;
|
3411 |
|
|
+ unsigned :1;
|
3412 |
|
|
+ unsigned :1;
|
3413 |
|
|
+ unsigned :1;
|
3414 |
|
|
+ };
|
3415 |
|
|
+
|
3416 |
|
|
+ struct {
|
3417 |
|
|
+ unsigned ALE:1;
|
3418 |
|
|
+ unsigned OE:1;
|
3419 |
|
|
+ unsigned WRL:1;
|
3420 |
|
|
+ unsigned WRH:1;
|
3421 |
|
|
+ unsigned :1;
|
3422 |
|
|
+ unsigned :1;
|
3423 |
|
|
+ unsigned :1;
|
3424 |
|
|
+ unsigned CCP2:1;
|
3425 |
|
|
+ };
|
3426 |
|
|
+
|
3427 |
|
|
+ struct {
|
3428 |
|
|
+ unsigned AN5:1;
|
3429 |
|
|
+ unsigned :1;
|
3430 |
|
|
+ unsigned :1;
|
3431 |
|
|
+ unsigned :1;
|
3432 |
|
|
+ unsigned :1;
|
3433 |
|
|
+ unsigned :1;
|
3434 |
|
|
+ unsigned :1;
|
3435 |
|
|
+ unsigned :1;
|
3436 |
|
|
+ };
|
3437 |
|
|
+} __PORTEbits_t;
|
3438 |
|
|
+
|
3439 |
|
|
+extern volatile __PORTEbits_t __at (0xf84) PORTEbits;
|
3440 |
|
|
+
|
3441 |
|
|
+extern __sfr __at (0xf89) LATA;
|
3442 |
|
|
+typedef union {
|
3443 |
|
|
+ struct {
|
3444 |
|
|
+ unsigned LATA0:1;
|
3445 |
|
|
+ unsigned LATA1:1;
|
3446 |
|
|
+ unsigned LATA2:1;
|
3447 |
|
|
+ unsigned LATA3:1;
|
3448 |
|
|
+ unsigned LATA4:1;
|
3449 |
|
|
+ unsigned LATA5:1;
|
3450 |
|
|
+ unsigned LATA6:1;
|
3451 |
|
|
+ unsigned :1;
|
3452 |
|
|
+ };
|
3453 |
|
|
+} __LATAbits_t;
|
3454 |
|
|
+
|
3455 |
|
|
+extern volatile __LATAbits_t __at (0xf89) LATAbits;
|
3456 |
|
|
+
|
3457 |
|
|
+extern __sfr __at (0xf8a) LATB;
|
3458 |
|
|
+typedef union {
|
3459 |
|
|
+ struct {
|
3460 |
|
|
+ unsigned LATB0:1;
|
3461 |
|
|
+ unsigned LATB1:1;
|
3462 |
|
|
+ unsigned LATB2:1;
|
3463 |
|
|
+ unsigned LATB3:1;
|
3464 |
|
|
+ unsigned LATB4:1;
|
3465 |
|
|
+ unsigned LATB5:1;
|
3466 |
|
|
+ unsigned LATB6:1;
|
3467 |
|
|
+ unsigned LATB7:1;
|
3468 |
|
|
+ };
|
3469 |
|
|
+} __LATBbits_t;
|
3470 |
|
|
+
|
3471 |
|
|
+extern volatile __LATBbits_t __at (0xf8a) LATBbits;
|
3472 |
|
|
+
|
3473 |
|
|
+extern __sfr __at (0xf8b) LATC;
|
3474 |
|
|
+typedef union {
|
3475 |
|
|
+ struct {
|
3476 |
|
|
+ unsigned LATC0:1;
|
3477 |
|
|
+ unsigned LATC1:1;
|
3478 |
|
|
+ unsigned LATC2:1;
|
3479 |
|
|
+ unsigned LATC3:1;
|
3480 |
|
|
+ unsigned LATC4:1;
|
3481 |
|
|
+ unsigned LATC5:1;
|
3482 |
|
|
+ unsigned LATC6:1;
|
3483 |
|
|
+ unsigned LATC7:1;
|
3484 |
|
|
+ };
|
3485 |
|
|
+} __LATCbits_t;
|
3486 |
|
|
+
|
3487 |
|
|
+extern volatile __LATCbits_t __at (0xf8b) LATCbits;
|
3488 |
|
|
+
|
3489 |
|
|
+extern __sfr __at (0xf8c) LATD;
|
3490 |
|
|
+typedef union {
|
3491 |
|
|
+ struct {
|
3492 |
|
|
+ unsigned LATD0:1;
|
3493 |
|
|
+ unsigned LATD1:1;
|
3494 |
|
|
+ unsigned LATD2:1;
|
3495 |
|
|
+ unsigned LATD3:1;
|
3496 |
|
|
+ unsigned LATD4:1;
|
3497 |
|
|
+ unsigned LATD5:1;
|
3498 |
|
|
+ unsigned LATD6:1;
|
3499 |
|
|
+ unsigned LATD7:1;
|
3500 |
|
|
+ };
|
3501 |
|
|
+} __LATDbits_t;
|
3502 |
|
|
+
|
3503 |
|
|
+extern volatile __LATDbits_t __at (0xf8c) LATDbits;
|
3504 |
|
|
+
|
3505 |
|
|
+extern __sfr __at (0xf8d) LATE;
|
3506 |
|
|
+typedef union {
|
3507 |
|
|
+ struct {
|
3508 |
|
|
+ unsigned LATE0:1;
|
3509 |
|
|
+ unsigned LATE1:1;
|
3510 |
|
|
+ unsigned LATE2:1;
|
3511 |
|
|
+ unsigned LATE3:1;
|
3512 |
|
|
+ unsigned LATE4:1;
|
3513 |
|
|
+ unsigned LATE5:1;
|
3514 |
|
|
+ unsigned LATE6:1;
|
3515 |
|
|
+ unsigned LATE7:1;
|
3516 |
|
|
+ };
|
3517 |
|
|
+} __LATEbits_t;
|
3518 |
|
|
+
|
3519 |
|
|
+extern volatile __LATEbits_t __at (0xf8d) LATEbits;
|
3520 |
|
|
+
|
3521 |
|
|
+extern __sfr __at (0xf92) TRISA;
|
3522 |
|
|
+typedef union {
|
3523 |
|
|
+ struct {
|
3524 |
|
|
+ unsigned TRISA0:1;
|
3525 |
|
|
+ unsigned TRISA1:1;
|
3526 |
|
|
+ unsigned TRISA2:1;
|
3527 |
|
|
+ unsigned TRISA3:1;
|
3528 |
|
|
+ unsigned TRISA4:1;
|
3529 |
|
|
+ unsigned TRISA5:1;
|
3530 |
|
|
+ unsigned TRISA6:1;
|
3531 |
|
|
+ unsigned :1;
|
3532 |
|
|
+ };
|
3533 |
|
|
+} __TRISAbits_t;
|
3534 |
|
|
+
|
3535 |
|
|
+extern volatile __TRISAbits_t __at (0xf92) TRISAbits;
|
3536 |
|
|
+
|
3537 |
|
|
+extern __sfr __at (0xf93) TRISB;
|
3538 |
|
|
+typedef union {
|
3539 |
|
|
+ struct {
|
3540 |
|
|
+ unsigned TRISB0:1;
|
3541 |
|
|
+ unsigned TRISB1:1;
|
3542 |
|
|
+ unsigned TRISB2:1;
|
3543 |
|
|
+ unsigned TRISB3:1;
|
3544 |
|
|
+ unsigned TRISB4:1;
|
3545 |
|
|
+ unsigned TRISB5:1;
|
3546 |
|
|
+ unsigned TRISB6:1;
|
3547 |
|
|
+ unsigned TRISB7:1;
|
3548 |
|
|
+ };
|
3549 |
|
|
+} __TRISBbits_t;
|
3550 |
|
|
+
|
3551 |
|
|
+extern volatile __TRISBbits_t __at (0xf93) TRISBbits;
|
3552 |
|
|
+
|
3553 |
|
|
+extern __sfr __at (0xf94) TRISC;
|
3554 |
|
|
+typedef union {
|
3555 |
|
|
+ struct {
|
3556 |
|
|
+ unsigned TRISC0:1;
|
3557 |
|
|
+ unsigned TRISC1:1;
|
3558 |
|
|
+ unsigned TRISC2:1;
|
3559 |
|
|
+ unsigned TRISC3:1;
|
3560 |
|
|
+ unsigned TRISC4:1;
|
3561 |
|
|
+ unsigned TRISC5:1;
|
3562 |
|
|
+ unsigned TRISC6:1;
|
3563 |
|
|
+ unsigned TRISC7:1;
|
3564 |
|
|
+ };
|
3565 |
|
|
+} __TRISCbits_t;
|
3566 |
|
|
+
|
3567 |
|
|
+extern volatile __TRISCbits_t __at (0xf94) TRISCbits;
|
3568 |
|
|
+
|
3569 |
|
|
+extern __sfr __at (0xf95) TRISD;
|
3570 |
|
|
+typedef union {
|
3571 |
|
|
+ struct {
|
3572 |
|
|
+ unsigned TRISD0:1;
|
3573 |
|
|
+ unsigned TRISD1:1;
|
3574 |
|
|
+ unsigned TRISD2:1;
|
3575 |
|
|
+ unsigned TRISD3:1;
|
3576 |
|
|
+ unsigned TRISD4:1;
|
3577 |
|
|
+ unsigned TRISD5:1;
|
3578 |
|
|
+ unsigned TRISD6:1;
|
3579 |
|
|
+ unsigned TRISD7:1;
|
3580 |
|
|
+ };
|
3581 |
|
|
+} __TRISDbits_t;
|
3582 |
|
|
+
|
3583 |
|
|
+extern volatile __TRISDbits_t __at (0xf95) TRISDbits;
|
3584 |
|
|
+
|
3585 |
|
|
+extern __sfr __at (0xf96) TRISE;
|
3586 |
|
|
+typedef union {
|
3587 |
|
|
+ struct {
|
3588 |
|
|
+ unsigned TRISE0:1;
|
3589 |
|
|
+ unsigned TRISE1:1;
|
3590 |
|
|
+ unsigned TRISE2:1;
|
3591 |
|
|
+ unsigned :1;
|
3592 |
|
|
+ unsigned PSPMODE:1;
|
3593 |
|
|
+ unsigned IBOV:1;
|
3594 |
|
|
+ unsigned OBF:1;
|
3595 |
|
|
+ unsigned IBF:1;
|
3596 |
|
|
+ };
|
3597 |
|
|
+} __TRISEbits_t;
|
3598 |
|
|
+
|
3599 |
|
|
+extern volatile __TRISEbits_t __at (0xf96) TRISEbits;
|
3600 |
|
|
+
|
3601 |
|
|
+extern __sfr __at (0xf9d) PIE1;
|
3602 |
|
|
+typedef union {
|
3603 |
|
|
+ struct {
|
3604 |
|
|
+ unsigned TMR1IE:1;
|
3605 |
|
|
+ unsigned TMR2IE:1;
|
3606 |
|
|
+ unsigned CCP1IE:1;
|
3607 |
|
|
+ unsigned SSPIE:1;
|
3608 |
|
|
+ unsigned TXIE:1;
|
3609 |
|
|
+ unsigned RCIE:1;
|
3610 |
|
|
+ unsigned ADIE:1;
|
3611 |
|
|
+ unsigned PSPIE:1;
|
3612 |
|
|
+ };
|
3613 |
|
|
+} __PIE1bits_t;
|
3614 |
|
|
+
|
3615 |
|
|
+extern volatile __PIE1bits_t __at (0xf9d) PIE1bits;
|
3616 |
|
|
+
|
3617 |
|
|
+extern __sfr __at (0xf9e) PIR1;
|
3618 |
|
|
+typedef union {
|
3619 |
|
|
+ struct {
|
3620 |
|
|
+ unsigned TMR1IF:1;
|
3621 |
|
|
+ unsigned TMR2IF:1;
|
3622 |
|
|
+ unsigned CCP1IF:1;
|
3623 |
|
|
+ unsigned SSPIF:1;
|
3624 |
|
|
+ unsigned TXIF:1;
|
3625 |
|
|
+ unsigned RCIF:1;
|
3626 |
|
|
+ unsigned ADIF:1;
|
3627 |
|
|
+ unsigned PSPIF:1;
|
3628 |
|
|
+ };
|
3629 |
|
|
+} __PIR1bits_t;
|
3630 |
|
|
+
|
3631 |
|
|
+extern volatile __PIR1bits_t __at (0xf9e) PIR1bits;
|
3632 |
|
|
+
|
3633 |
|
|
+extern __sfr __at (0xf9f) IPR1;
|
3634 |
|
|
+typedef union {
|
3635 |
|
|
+ struct {
|
3636 |
|
|
+ unsigned TMR1IP:1;
|
3637 |
|
|
+ unsigned TMR2IP:1;
|
3638 |
|
|
+ unsigned CCP1IP:1;
|
3639 |
|
|
+ unsigned SSPIP:1;
|
3640 |
|
|
+ unsigned TXIP:1;
|
3641 |
|
|
+ unsigned RCIP:1;
|
3642 |
|
|
+ unsigned ADIP:1;
|
3643 |
|
|
+ unsigned PSPIP:1;
|
3644 |
|
|
+ };
|
3645 |
|
|
+} __IPR1bits_t;
|
3646 |
|
|
+
|
3647 |
|
|
+extern volatile __IPR1bits_t __at (0xf9f) IPR1bits;
|
3648 |
|
|
+
|
3649 |
|
|
+extern __sfr __at (0xfa0) PIE2;
|
3650 |
|
|
+typedef union {
|
3651 |
|
|
+ struct {
|
3652 |
|
|
+ unsigned CCP2IE:1;
|
3653 |
|
|
+ unsigned TMR3IE:1;
|
3654 |
|
|
+ unsigned LVDIE:1;
|
3655 |
|
|
+ unsigned BCLIE:1;
|
3656 |
|
|
+ unsigned EEIE:1;
|
3657 |
|
|
+ unsigned :1;
|
3658 |
|
|
+ unsigned :1;
|
3659 |
|
|
+ unsigned :1;
|
3660 |
|
|
+ };
|
3661 |
|
|
+} __PIE2bits_t;
|
3662 |
|
|
+
|
3663 |
|
|
+extern volatile __PIE2bits_t __at (0xfa0) PIE2bits;
|
3664 |
|
|
+
|
3665 |
|
|
+extern __sfr __at (0xfa1) PIR2;
|
3666 |
|
|
+typedef union {
|
3667 |
|
|
+ struct {
|
3668 |
|
|
+ unsigned CCP2IF:1;
|
3669 |
|
|
+ unsigned TMR3IF:1;
|
3670 |
|
|
+ unsigned LVDIF:1;
|
3671 |
|
|
+ unsigned BCLIF:1;
|
3672 |
|
|
+ unsigned EEIF:1;
|
3673 |
|
|
+ unsigned :1;
|
3674 |
|
|
+ unsigned :1;
|
3675 |
|
|
+ unsigned :1;
|
3676 |
|
|
+ };
|
3677 |
|
|
+} __PIR2bits_t;
|
3678 |
|
|
+
|
3679 |
|
|
+extern volatile __PIR2bits_t __at (0xfa1) PIR2bits;
|
3680 |
|
|
+
|
3681 |
|
|
+extern __sfr __at (0xfa2) IPR2;
|
3682 |
|
|
+typedef union {
|
3683 |
|
|
+ struct {
|
3684 |
|
|
+ unsigned CCP2IP:1;
|
3685 |
|
|
+ unsigned TMR3IP:1;
|
3686 |
|
|
+ unsigned LVDIP:1;
|
3687 |
|
|
+ unsigned BCLIP:1;
|
3688 |
|
|
+ unsigned EEIP:1;
|
3689 |
|
|
+ unsigned :1;
|
3690 |
|
|
+ unsigned :1;
|
3691 |
|
|
+ unsigned :1;
|
3692 |
|
|
+ };
|
3693 |
|
|
+} __IPR2bits_t;
|
3694 |
|
|
+
|
3695 |
|
|
+extern volatile __IPR2bits_t __at (0xfa2) IPR2bits;
|
3696 |
|
|
+
|
3697 |
|
|
+extern __sfr __at (0xfa6) EECON1;
|
3698 |
|
|
+typedef union {
|
3699 |
|
|
+ struct {
|
3700 |
|
|
+ unsigned RD:1;
|
3701 |
|
|
+ unsigned WR:1;
|
3702 |
|
|
+ unsigned WREN:1;
|
3703 |
|
|
+ unsigned WRERR:1;
|
3704 |
|
|
+ unsigned FREE:1;
|
3705 |
|
|
+ unsigned :1;
|
3706 |
|
|
+ unsigned CFGS:1;
|
3707 |
|
|
+ unsigned EEPGD:1;
|
3708 |
|
|
+ };
|
3709 |
|
|
+} __EECON1bits_t;
|
3710 |
|
|
+
|
3711 |
|
|
+extern volatile __EECON1bits_t __at (0xfa6) EECON1bits;
|
3712 |
|
|
+
|
3713 |
|
|
+extern __sfr __at (0xfa7) EECON2;
|
3714 |
|
|
+extern __sfr __at (0xfa8) EEDATA;
|
3715 |
|
|
+extern __sfr __at (0xfa9) EEADR;
|
3716 |
|
|
+extern __sfr __at (0xfab) RCSTA;
|
3717 |
|
|
+typedef union {
|
3718 |
|
|
+ struct {
|
3719 |
|
|
+ unsigned RX9D:1;
|
3720 |
|
|
+ unsigned OERR:1;
|
3721 |
|
|
+ unsigned FERR:1;
|
3722 |
|
|
+ unsigned ADDEN:1;
|
3723 |
|
|
+ unsigned CREN:1;
|
3724 |
|
|
+ unsigned SREN:1;
|
3725 |
|
|
+ unsigned RX9:1;
|
3726 |
|
|
+ unsigned SPEN:1;
|
3727 |
|
|
+ };
|
3728 |
|
|
+} __RCSTAbits_t;
|
3729 |
|
|
+
|
3730 |
|
|
+extern volatile __RCSTAbits_t __at (0xfab) RCSTAbits;
|
3731 |
|
|
+
|
3732 |
|
|
+extern __sfr __at (0xfac) TXSTA;
|
3733 |
|
|
+typedef union {
|
3734 |
|
|
+ struct {
|
3735 |
|
|
+ unsigned TX9D:1;
|
3736 |
|
|
+ unsigned TRMT:1;
|
3737 |
|
|
+ unsigned BRGH:1;
|
3738 |
|
|
+ unsigned :1;
|
3739 |
|
|
+ unsigned SYNC:1;
|
3740 |
|
|
+ unsigned TXEN:1;
|
3741 |
|
|
+ unsigned TX9:1;
|
3742 |
|
|
+ unsigned CSRC:1;
|
3743 |
|
|
+ };
|
3744 |
|
|
+} __TXSTAbits_t;
|
3745 |
|
|
+
|
3746 |
|
|
+extern volatile __TXSTAbits_t __at (0xfac) TXSTAbits;
|
3747 |
|
|
+
|
3748 |
|
|
+extern __sfr __at (0xfad) TXREG;
|
3749 |
|
|
+extern __sfr __at (0xfae) RCREG;
|
3750 |
|
|
+extern __sfr __at (0xfaf) SPBRG;
|
3751 |
|
|
+extern __sfr __at (0xfb1) T3CON;
|
3752 |
|
|
+typedef union {
|
3753 |
|
|
+ struct {
|
3754 |
|
|
+ unsigned TMR3ON:1;
|
3755 |
|
|
+ unsigned TMR3CS:1;
|
3756 |
|
|
+ unsigned T3SYNC:1;
|
3757 |
|
|
+ unsigned T3CCP1:1;
|
3758 |
|
|
+ unsigned T3CKPS0:1;
|
3759 |
|
|
+ unsigned T3CKPS1:1;
|
3760 |
|
|
+ unsigned T3CCP2:1;
|
3761 |
|
|
+ unsigned RD16:1;
|
3762 |
|
|
+ };
|
3763 |
|
|
+} __T3CONbits_t;
|
3764 |
|
|
+
|
3765 |
|
|
+extern volatile __T3CONbits_t __at (0xfb1) T3CONbits;
|
3766 |
|
|
+
|
3767 |
|
|
+extern __sfr __at (0xfb2) TMR3L;
|
3768 |
|
|
+extern __sfr __at (0xfb3) TMR3H;
|
3769 |
|
|
+extern __sfr __at (0xfba) CCP2CON;
|
3770 |
|
|
+typedef union {
|
3771 |
|
|
+ struct {
|
3772 |
|
|
+ unsigned CCP2M0:1;
|
3773 |
|
|
+ unsigned CCP2M1:1;
|
3774 |
|
|
+ unsigned CCP2M2:1;
|
3775 |
|
|
+ unsigned CCP2M3:1;
|
3776 |
|
|
+ unsigned DCCP2Y:1;
|
3777 |
|
|
+ unsigned DCCP2X:1;
|
3778 |
|
|
+ unsigned :1;
|
3779 |
|
|
+ unsigned :1;
|
3780 |
|
|
+ };
|
3781 |
|
|
+} __CCP2CONbits_t;
|
3782 |
|
|
+
|
3783 |
|
|
+extern volatile __CCP2CONbits_t __at (0xfba) CCP2CONbits;
|
3784 |
|
|
+
|
3785 |
|
|
+extern __sfr __at (0xfbb) CCPR2L;
|
3786 |
|
|
+extern __sfr __at (0xfbc) CCPR2H;
|
3787 |
|
|
+extern __sfr __at (0xfbd) CCP1CON;
|
3788 |
|
|
+typedef union {
|
3789 |
|
|
+ struct {
|
3790 |
|
|
+ unsigned CCP1M0:1;
|
3791 |
|
|
+ unsigned CCP1M1:1;
|
3792 |
|
|
+ unsigned CCP1M2:1;
|
3793 |
|
|
+ unsigned CCP1M3:1;
|
3794 |
|
|
+ unsigned DCCP1Y:1;
|
3795 |
|
|
+ unsigned DCCP1X:1;
|
3796 |
|
|
+ unsigned :1;
|
3797 |
|
|
+ unsigned :1;
|
3798 |
|
|
+ };
|
3799 |
|
|
+} __CCP1CONbits_t;
|
3800 |
|
|
+
|
3801 |
|
|
+extern volatile __CCP1CONbits_t __at (0xfbd) CCP1CONbits;
|
3802 |
|
|
+
|
3803 |
|
|
+extern __sfr __at (0xfbe) CCPR1L;
|
3804 |
|
|
+extern __sfr __at (0xfbf) CCPR1H;
|
3805 |
|
|
+extern __sfr __at (0xfc1) ADCON1;
|
3806 |
|
|
+typedef union {
|
3807 |
|
|
+ struct {
|
3808 |
|
|
+ unsigned PCFG0:1;
|
3809 |
|
|
+ unsigned PCFG1:1;
|
3810 |
|
|
+ unsigned PCFG2:1;
|
3811 |
|
|
+ unsigned PCFG3:1;
|
3812 |
|
|
+ unsigned :1;
|
3813 |
|
|
+ unsigned :1;
|
3814 |
|
|
+ unsigned ADCS2:1;
|
3815 |
|
|
+ unsigned ADFM:1;
|
3816 |
|
|
+ };
|
3817 |
|
|
+} __ADCON1bits_t;
|
3818 |
|
|
+
|
3819 |
|
|
+extern volatile __ADCON1bits_t __at (0xfc1) ADCON1bits;
|
3820 |
|
|
+
|
3821 |
|
|
+extern __sfr __at (0xfc2) ADCON0;
|
3822 |
|
|
+typedef union {
|
3823 |
|
|
+ struct {
|
3824 |
|
|
+ unsigned ADON:1;
|
3825 |
|
|
+ unsigned :1;
|
3826 |
|
|
+ unsigned GO:1;
|
3827 |
|
|
+ unsigned CHS0:1;
|
3828 |
|
|
+ unsigned CHS1:1;
|
3829 |
|
|
+ unsigned CHS2:1;
|
3830 |
|
|
+ unsigned ADCS0:1;
|
3831 |
|
|
+ unsigned ADCS1:1;
|
3832 |
|
|
+ };
|
3833 |
|
|
+} __ADCON0bits_t;
|
3834 |
|
|
+
|
3835 |
|
|
+extern volatile __ADCON0bits_t __at (0xfc2) ADCON0bits;
|
3836 |
|
|
+
|
3837 |
|
|
+extern __sfr __at (0xfc3) ADRESL;
|
3838 |
|
|
+extern __sfr __at (0xfc4) ADRESH;
|
3839 |
|
|
+extern __sfr __at (0xfc5) SSPCON2;
|
3840 |
|
|
+typedef union {
|
3841 |
|
|
+ struct {
|
3842 |
|
|
+ unsigned SEN:1;
|
3843 |
|
|
+ unsigned RSEN:1;
|
3844 |
|
|
+ unsigned PEN:1;
|
3845 |
|
|
+ unsigned RCEN:1;
|
3846 |
|
|
+ unsigned ACKEN:1;
|
3847 |
|
|
+ unsigned ACKDT:1;
|
3848 |
|
|
+ unsigned ACKSTAT:1;
|
3849 |
|
|
+ unsigned GCEN:1;
|
3850 |
|
|
+ };
|
3851 |
|
|
+} __SSPCON2bits_t;
|
3852 |
|
|
+
|
3853 |
|
|
+extern volatile __SSPCON2bits_t __at (0xfc5) SSPCON2bits;
|
3854 |
|
|
+
|
3855 |
|
|
+extern __sfr __at (0xfc6) SSPCON1;
|
3856 |
|
|
+typedef union {
|
3857 |
|
|
+ struct {
|
3858 |
|
|
+ unsigned SSPM0:1;
|
3859 |
|
|
+ unsigned SSPM1:1;
|
3860 |
|
|
+ unsigned SSPM2:1;
|
3861 |
|
|
+ unsigned SSPM3:1;
|
3862 |
|
|
+ unsigned CKP:1;
|
3863 |
|
|
+ unsigned SSPEN:1;
|
3864 |
|
|
+ unsigned SSPOV:1;
|
3865 |
|
|
+ unsigned WCOL:1;
|
3866 |
|
|
+ };
|
3867 |
|
|
+} __SSPCON1bits_t;
|
3868 |
|
|
+
|
3869 |
|
|
+extern volatile __SSPCON1bits_t __at (0xfc6) SSPCON1bits;
|
3870 |
|
|
+
|
3871 |
|
|
+extern __sfr __at (0xfc7) SSPSTAT;
|
3872 |
|
|
+typedef union {
|
3873 |
|
|
+ struct {
|
3874 |
|
|
+ unsigned BF:1;
|
3875 |
|
|
+ unsigned UA:1;
|
3876 |
|
|
+ unsigned R_W:1;
|
3877 |
|
|
+ unsigned S:1;
|
3878 |
|
|
+ unsigned P:1;
|
3879 |
|
|
+ unsigned D_A:1;
|
3880 |
|
|
+ unsigned CKE:1;
|
3881 |
|
|
+ unsigned SMP:1;
|
3882 |
|
|
+ };
|
3883 |
|
|
+} __SSPSTATbits_t;
|
3884 |
|
|
+
|
3885 |
|
|
+extern volatile __SSPSTATbits_t __at (0xfc7) SSPSTATbits;
|
3886 |
|
|
+
|
3887 |
|
|
+extern __sfr __at (0xfc8) SSPADD;
|
3888 |
|
|
+extern __sfr __at (0xfc9) SSPBUF;
|
3889 |
|
|
+extern __sfr __at (0xfca) T2CON;
|
3890 |
|
|
+typedef union {
|
3891 |
|
|
+ struct {
|
3892 |
|
|
+ unsigned T2CKPS0:1;
|
3893 |
|
|
+ unsigned T2CKPS1:1;
|
3894 |
|
|
+ unsigned TMR2ON:1;
|
3895 |
|
|
+ unsigned TOUTPS0:1;
|
3896 |
|
|
+ unsigned TOUTPS1:1;
|
3897 |
|
|
+ unsigned TOUTPS2:1;
|
3898 |
|
|
+ unsigned TOUTPS3:1;
|
3899 |
|
|
+ unsigned :1;
|
3900 |
|
|
+ };
|
3901 |
|
|
+} __T2CONbits_t;
|
3902 |
|
|
+
|
3903 |
|
|
+extern volatile __T2CONbits_t __at (0xfca) T2CONbits;
|
3904 |
|
|
+
|
3905 |
|
|
+extern __sfr __at (0xfcb) PR2;
|
3906 |
|
|
+extern __sfr __at (0xfcc) TMR2;
|
3907 |
|
|
+extern __sfr __at (0xfcd) T1CON;
|
3908 |
|
|
+typedef union {
|
3909 |
|
|
+ struct {
|
3910 |
|
|
+ unsigned TMR1ON:1;
|
3911 |
|
|
+ unsigned TMR1CS:1;
|
3912 |
|
|
+ unsigned NOT_T1SYNC:1;
|
3913 |
|
|
+ unsigned T1OSCEN:1;
|
3914 |
|
|
+ unsigned T1CKPS0:1;
|
3915 |
|
|
+ unsigned T1CKPS1:1;
|
3916 |
|
|
+ unsigned :1;
|
3917 |
|
|
+ unsigned RD16:1;
|
3918 |
|
|
+ };
|
3919 |
|
|
+} __T1CONbits_t;
|
3920 |
|
|
+
|
3921 |
|
|
+extern volatile __T1CONbits_t __at (0xfcd) T1CONbits;
|
3922 |
|
|
+
|
3923 |
|
|
+extern __sfr __at (0xfce) TMR1L;
|
3924 |
|
|
+extern __sfr __at (0xfcf) TMR1H;
|
3925 |
|
|
+extern __sfr __at (0xfd0) RCON;
|
3926 |
|
|
+typedef union {
|
3927 |
|
|
+ struct {
|
3928 |
|
|
+ unsigned BOR:1;
|
3929 |
|
|
+ unsigned POR:1;
|
3930 |
|
|
+ unsigned PD:1;
|
3931 |
|
|
+ unsigned TO:1;
|
3932 |
|
|
+ unsigned RI:1;
|
3933 |
|
|
+ unsigned :1;
|
3934 |
|
|
+ unsigned :1;
|
3935 |
|
|
+ unsigned IPEN:1;
|
3936 |
|
|
+ };
|
3937 |
|
|
+} __RCONbits_t;
|
3938 |
|
|
+
|
3939 |
|
|
+extern volatile __RCONbits_t __at (0xfd0) RCONbits;
|
3940 |
|
|
+
|
3941 |
|
|
+extern __sfr __at (0xfd1) WDTCON;
|
3942 |
|
|
+typedef union {
|
3943 |
|
|
+ struct {
|
3944 |
|
|
+ unsigned SWDTEN:1;
|
3945 |
|
|
+ unsigned :1;
|
3946 |
|
|
+ unsigned :1;
|
3947 |
|
|
+ unsigned :1;
|
3948 |
|
|
+ unsigned :1;
|
3949 |
|
|
+ unsigned :1;
|
3950 |
|
|
+ unsigned :1;
|
3951 |
|
|
+ unsigned :1;
|
3952 |
|
|
+ };
|
3953 |
|
|
+
|
3954 |
|
|
+ struct {
|
3955 |
|
|
+ unsigned SWDTE:1;
|
3956 |
|
|
+ unsigned :1;
|
3957 |
|
|
+ unsigned :1;
|
3958 |
|
|
+ unsigned :1;
|
3959 |
|
|
+ unsigned :1;
|
3960 |
|
|
+ unsigned :1;
|
3961 |
|
|
+ unsigned :1;
|
3962 |
|
|
+ unsigned :1;
|
3963 |
|
|
+ };
|
3964 |
|
|
+} __WDTCONbits_t;
|
3965 |
|
|
+
|
3966 |
|
|
+extern volatile __WDTCONbits_t __at (0xfd1) WDTCONbits;
|
3967 |
|
|
+
|
3968 |
|
|
+extern __sfr __at (0xfd2) LVDCON;
|
3969 |
|
|
+typedef union {
|
3970 |
|
|
+ struct {
|
3971 |
|
|
+ unsigned LVDL0:1;
|
3972 |
|
|
+ unsigned LVDL1:1;
|
3973 |
|
|
+ unsigned LVDL2:1;
|
3974 |
|
|
+ unsigned LVDL3:1;
|
3975 |
|
|
+ unsigned LVDEN:1;
|
3976 |
|
|
+ unsigned VRST:1;
|
3977 |
|
|
+ unsigned :1;
|
3978 |
|
|
+ unsigned :1;
|
3979 |
|
|
+ };
|
3980 |
|
|
+
|
3981 |
|
|
+ struct {
|
3982 |
|
|
+ unsigned LVV0:1;
|
3983 |
|
|
+ unsigned LVV1:1;
|
3984 |
|
|
+ unsigned LVV2:1;
|
3985 |
|
|
+ unsigned LVV3:1;
|
3986 |
|
|
+ unsigned :1;
|
3987 |
|
|
+ unsigned BGST:1;
|
3988 |
|
|
+ unsigned :1;
|
3989 |
|
|
+ unsigned :1;
|
3990 |
|
|
+ };
|
3991 |
|
|
+} __LVDCONbits_t;
|
3992 |
|
|
+
|
3993 |
|
|
+extern volatile __LVDCONbits_t __at (0xfd2) LVDCONbits;
|
3994 |
|
|
+
|
3995 |
|
|
+extern __sfr __at (0xfd3) OSCCON;
|
3996 |
|
|
+typedef union {
|
3997 |
|
|
+ struct {
|
3998 |
|
|
+ unsigned SCS:1;
|
3999 |
|
|
+ unsigned :1;
|
4000 |
|
|
+ unsigned :1;
|
4001 |
|
|
+ unsigned :1;
|
4002 |
|
|
+ unsigned :1;
|
4003 |
|
|
+ unsigned :1;
|
4004 |
|
|
+ unsigned :1;
|
4005 |
|
|
+ unsigned :1;
|
4006 |
|
|
+ };
|
4007 |
|
|
+} __OSCCONbits_t;
|
4008 |
|
|
+
|
4009 |
|
|
+extern volatile __OSCCONbits_t __at (0xfd3) OSCCONbits;
|
4010 |
|
|
+
|
4011 |
|
|
+extern __sfr __at (0xfd5) T0CON;
|
4012 |
|
|
+typedef union {
|
4013 |
|
|
+ struct {
|
4014 |
|
|
+ unsigned T0PS0:1;
|
4015 |
|
|
+ unsigned T0PS1:1;
|
4016 |
|
|
+ unsigned T0PS2:1;
|
4017 |
|
|
+ unsigned PSA:1;
|
4018 |
|
|
+ unsigned T0SE:1;
|
4019 |
|
|
+ unsigned T0CS:1;
|
4020 |
|
|
+ unsigned T08BIT:1;
|
4021 |
|
|
+ unsigned TMR0ON:1;
|
4022 |
|
|
+ };
|
4023 |
|
|
+} __T0CONbits_t;
|
4024 |
|
|
+
|
4025 |
|
|
+extern volatile __T0CONbits_t __at (0xfd5) T0CONbits;
|
4026 |
|
|
+
|
4027 |
|
|
+extern __sfr __at (0xfd6) TMR0L;
|
4028 |
|
|
+extern __sfr __at (0xfd7) TMR0H;
|
4029 |
|
|
+extern __sfr __at (0xfd8) STATUS;
|
4030 |
|
|
+typedef union {
|
4031 |
|
|
+ struct {
|
4032 |
|
|
+ unsigned C:1;
|
4033 |
|
|
+ unsigned DC:1;
|
4034 |
|
|
+ unsigned Z:1;
|
4035 |
|
|
+ unsigned OV:1;
|
4036 |
|
|
+ unsigned N:1;
|
4037 |
|
|
+ unsigned :1;
|
4038 |
|
|
+ unsigned :1;
|
4039 |
|
|
+ unsigned :1;
|
4040 |
|
|
+ };
|
4041 |
|
|
+} __STATUSbits_t;
|
4042 |
|
|
+
|
4043 |
|
|
+extern volatile __STATUSbits_t __at (0xfd8) STATUSbits;
|
4044 |
|
|
+
|
4045 |
|
|
+extern __sfr __at (0xfd9) FSR2L;
|
4046 |
|
|
+extern __sfr __at (0xfda) FSR2H;
|
4047 |
|
|
+extern __sfr __at (0xfdb) PLUSW2;
|
4048 |
|
|
+extern __sfr __at (0xfdc) PREINC2;
|
4049 |
|
|
+extern __sfr __at (0xfdd) POSTDEC2;
|
4050 |
|
|
+extern __sfr __at (0xfde) POSTINC2;
|
4051 |
|
|
+extern __sfr __at (0xfdf) INDF2;
|
4052 |
|
|
+extern __sfr __at (0xfe0) BSR;
|
4053 |
|
|
+extern __sfr __at (0xfe1) FSR1L;
|
4054 |
|
|
+extern __sfr __at (0xfe2) FSR1H;
|
4055 |
|
|
+extern __sfr __at (0xfe3) PLUSW1;
|
4056 |
|
|
+extern __sfr __at (0xfe4) PREINC1;
|
4057 |
|
|
+extern __sfr __at (0xfe5) POSTDEC1;
|
4058 |
|
|
+extern __sfr __at (0xfe6) POSTINC1;
|
4059 |
|
|
+extern __sfr __at (0xfe7) INDF1;
|
4060 |
|
|
+extern __sfr __at (0xfe8) WREG;
|
4061 |
|
|
+extern __sfr __at (0xfe9) FSR0L;
|
4062 |
|
|
+extern __sfr __at (0xfea) FSR0H;
|
4063 |
|
|
+extern __sfr __at (0xfeb) PLUSW0;
|
4064 |
|
|
+extern __sfr __at (0xfec) PREINC0;
|
4065 |
|
|
+extern __sfr __at (0xfed) POSTDEC0;
|
4066 |
|
|
+extern __sfr __at (0xfee) POSTINC0;
|
4067 |
|
|
+extern __sfr __at (0xfef) INDF0;
|
4068 |
|
|
+extern __sfr __at (0xff0) INTCON3;
|
4069 |
|
|
+typedef union {
|
4070 |
|
|
+ struct {
|
4071 |
|
|
+ unsigned INT1F:1;
|
4072 |
|
|
+ unsigned INT2F:1;
|
4073 |
|
|
+ unsigned :1;
|
4074 |
|
|
+ unsigned INT1E:1;
|
4075 |
|
|
+ unsigned INT2E:1;
|
4076 |
|
|
+ unsigned :1;
|
4077 |
|
|
+ unsigned INT1P:1;
|
4078 |
|
|
+ unsigned INT2P:1;
|
4079 |
|
|
+ };
|
4080 |
|
|
+
|
4081 |
|
|
+ struct {
|
4082 |
|
|
+ unsigned INT1IF:1;
|
4083 |
|
|
+ unsigned INT2IF:1;
|
4084 |
|
|
+ unsigned :1;
|
4085 |
|
|
+ unsigned INT1IE:1;
|
4086 |
|
|
+ unsigned INT2IE:1;
|
4087 |
|
|
+ unsigned :1;
|
4088 |
|
|
+ unsigned INT1IP:1;
|
4089 |
|
|
+ unsigned INT2IP:1;
|
4090 |
|
|
+ };
|
4091 |
|
|
+} __INTCON3bits_t;
|
4092 |
|
|
+
|
4093 |
|
|
+extern volatile __INTCON3bits_t __at (0xff0) INTCON3bits;
|
4094 |
|
|
+
|
4095 |
|
|
+extern __sfr __at (0xff1) INTCON2;
|
4096 |
|
|
+typedef union {
|
4097 |
|
|
+ struct {
|
4098 |
|
|
+ unsigned RBIP:1;
|
4099 |
|
|
+ unsigned :1;
|
4100 |
|
|
+ unsigned T0IP:1;
|
4101 |
|
|
+ unsigned :1;
|
4102 |
|
|
+ unsigned INTEDG2:1;
|
4103 |
|
|
+ unsigned INTEDG1:1;
|
4104 |
|
|
+ unsigned INTEDG0:1;
|
4105 |
|
|
+ unsigned RBPU:1;
|
4106 |
|
|
+ };
|
4107 |
|
|
+} __INTCON2bits_t;
|
4108 |
|
|
+
|
4109 |
|
|
+extern volatile __INTCON2bits_t __at (0xff1) INTCON2bits;
|
4110 |
|
|
+
|
4111 |
|
|
+extern __sfr __at (0xff2) INTCON;
|
4112 |
|
|
+typedef union {
|
4113 |
|
|
+ struct {
|
4114 |
|
|
+ unsigned RBIF:1;
|
4115 |
|
|
+ unsigned INT0F:1;
|
4116 |
|
|
+ unsigned T0IF:1;
|
4117 |
|
|
+ unsigned RBIE:1;
|
4118 |
|
|
+ unsigned INT0E:1;
|
4119 |
|
|
+ unsigned T0IE:1;
|
4120 |
|
|
+ unsigned PEIE:1;
|
4121 |
|
|
+ unsigned GIE:1;
|
4122 |
|
|
+ };
|
4123 |
|
|
+} __INTCONbits_t;
|
4124 |
|
|
+
|
4125 |
|
|
+extern volatile __INTCONbits_t __at (0xff2) INTCONbits;
|
4126 |
|
|
+
|
4127 |
|
|
+extern __sfr __at (0xff3) PRODL;
|
4128 |
|
|
+extern __sfr __at (0xff4) PRODH;
|
4129 |
|
|
+extern __sfr __at (0xff5) TABLAT;
|
4130 |
|
|
+extern __sfr __at (0xff6) TBLPTRL;
|
4131 |
|
|
+extern __sfr __at (0xff7) TBLPTRH;
|
4132 |
|
|
+extern __sfr __at (0xff8) TBLPTRU;
|
4133 |
|
|
+extern __sfr __at (0xff9) PCL;
|
4134 |
|
|
+extern __sfr __at (0xffa) PCLATH;
|
4135 |
|
|
+extern __sfr __at (0xffb) PCLATU;
|
4136 |
|
|
+extern __sfr __at (0xffc) STKPTR;
|
4137 |
|
|
+typedef union {
|
4138 |
|
|
+ struct {
|
4139 |
|
|
+ unsigned STKPTR0:1;
|
4140 |
|
|
+ unsigned STKPTR1:1;
|
4141 |
|
|
+ unsigned STKPTR2:1;
|
4142 |
|
|
+ unsigned STKPTR3:1;
|
4143 |
|
|
+ unsigned STKPTR4:1;
|
4144 |
|
|
+ unsigned :1;
|
4145 |
|
|
+ unsigned STKUNF:1;
|
4146 |
|
|
+ unsigned STKFUL:1;
|
4147 |
|
|
+ };
|
4148 |
|
|
+} __STKPTRbits_t;
|
4149 |
|
|
+
|
4150 |
|
|
+extern volatile __STKPTRbits_t __at (0xffc) STKPTRbits;
|
4151 |
|
|
+
|
4152 |
|
|
+extern __sfr __at (0xffd) TOSL;
|
4153 |
|
|
+extern __sfr __at (0xffe) TOSH;
|
4154 |
|
|
+extern __sfr __at (0xfff) TOSU;
|
4155 |
|
|
+
|
4156 |
|
|
+
|
4157 |
|
|
+/* Configuration registers locations */
|
4158 |
|
|
+#define __CONFIG1H 0x300001
|
4159 |
|
|
+#define __CONFIG2L 0x300002
|
4160 |
|
|
+#define __CONFIG2H 0x300003
|
4161 |
|
|
+#define __CONFIG3H 0x300005
|
4162 |
|
|
+#define __CONFIG4L 0x300006
|
4163 |
|
|
+#define __CONFIG5L 0x300008
|
4164 |
|
|
+#define __CONFIG5H 0x300009
|
4165 |
|
|
+#define __CONFIG6L 0x30000A
|
4166 |
|
|
+#define __CONFIG6H 0x30000B
|
4167 |
|
|
+#define __CONFIG7L 0x30000C
|
4168 |
|
|
+#define __CONFIG7H 0x30000D
|
4169 |
|
|
+
|
4170 |
|
|
+
|
4171 |
|
|
+
|
4172 |
|
|
+/* Oscillator 1H options */
|
4173 |
|
|
+#define _OSC_RC_OSC2_1H 0xFF /* RC-OSC2 as RA6 */
|
4174 |
|
|
+#define _OSC_HS_PLL_1H 0xFE /* HS-PLL Enabled */
|
4175 |
|
|
+#define _OSC_EC_OSC2_RA6_1H 0xFD /* EC-OSC2 as RA6 */
|
4176 |
|
|
+#define _OSC_EC_OSC2_Clock_Out_1H 0xFC /* EC-OSC2 as Clock_Out */
|
4177 |
|
|
+#define _OSC_RC_1H 0xFB /* RC */
|
4178 |
|
|
+#define _OSC_HS_1H 0xFA /* HS */
|
4179 |
|
|
+#define _OSC_XT_1H 0xF9 /* XT */
|
4180 |
|
|
+#define _OSC_LP_1H 0xF8 /* LP */
|
4181 |
|
|
+
|
4182 |
|
|
+/* Osc. Switch Enable 1H options */
|
4183 |
|
|
+#define _OSCS_OFF_1H 0xFF /* Disabled */
|
4184 |
|
|
+#define _OSCS_ON_1H 0xDF /* Enabled */
|
4185 |
|
|
+
|
4186 |
|
|
+/* Power Up Timer 2L options */
|
4187 |
|
|
+#define _PUT_OFF_2L 0xFF /* Disabled */
|
4188 |
|
|
+#define _PUT_ON_2L 0xFE /* Enabled */
|
4189 |
|
|
+
|
4190 |
|
|
+/* Brown Out Detect 2L options */
|
4191 |
|
|
+#define _BODEN_ON_2L 0xFF /* Enabled */
|
4192 |
|
|
+#define _BODEN_OFF_2L 0xFD /* Disabled */
|
4193 |
|
|
+
|
4194 |
|
|
+/* Brown Out Voltage 2L options */
|
4195 |
|
|
+#define _BODENV_2_0V_2L 0xFF /* 2.0V */
|
4196 |
|
|
+#define _BODENV_2_7V_2L 0xFB /* 2.7V */
|
4197 |
|
|
+#define _BODENV_4_2V_2L 0xF7 /* 4.2V */
|
4198 |
|
|
+#define _BODENV_4_5V_2L 0xF3 /* 4.5V */
|
4199 |
|
|
+
|
4200 |
|
|
+/* Watchdog Timer 2H options */
|
4201 |
|
|
+#define _WDT_ON_2H 0xFF /* Enabled */
|
4202 |
|
|
+#define _WDT_OFF_2H 0xFE /* Disabled */
|
4203 |
|
|
+
|
4204 |
|
|
+/* Watchdog Postscaler 2H options */
|
4205 |
|
|
+#define _WDTPS_1_128_2H 0xFF /* 1:128 */
|
4206 |
|
|
+#define _WDTPS_1_64_2H 0xFD /* 1:64 */
|
4207 |
|
|
+#define _WDTPS_1_32_2H 0xFB /* 1:32 */
|
4208 |
|
|
+#define _WDTPS_1_16_2H 0xF9 /* 1:16 */
|
4209 |
|
|
+#define _WDTPS_1_8_2H 0xF7 /* 1:8 */
|
4210 |
|
|
+#define _WDTPS_1_4_2H 0xF5 /* 1:4 */
|
4211 |
|
|
+#define _WDTPS_1_2_2H 0xF3 /* 1:2 */
|
4212 |
|
|
+#define _WDTPS_1_1_2H 0xF1 /* 1:1 */
|
4213 |
|
|
+
|
4214 |
|
|
+/* CCP2 Mux 3H options */
|
4215 |
|
|
+#define _CCP2MUX_RC1_3H 0xFF /* RC1 */
|
4216 |
|
|
+#define _CCP2MUX_RB3_3H 0xFE /* RB3 */
|
4217 |
|
|
+
|
4218 |
|
|
+/* Low Voltage Program 4L options */
|
4219 |
|
|
+#define _LVP_ON_4L 0xFF /* Enabled */
|
4220 |
|
|
+#define _LVP_OFF_4L 0xFB /* Disabled */
|
4221 |
|
|
+
|
4222 |
|
|
+/* Background Debug 4L options */
|
4223 |
|
|
+#define _BACKBUG_OFF_4L 0xFF /* Disabled */
|
4224 |
|
|
+#define _BACKBUG_ON_4L 0x7F /* Enabled */
|
4225 |
|
|
+
|
4226 |
|
|
+/* Stack Overflow Reset 4L options */
|
4227 |
|
|
+#define _STVR_ON_4L 0xFF /* Enabled */
|
4228 |
|
|
+#define _STVR_OFF_4L 0xFE /* Disabled */
|
4229 |
|
|
+
|
4230 |
|
|
+/* Code Protect 00200-01FFF 5L options */
|
4231 |
|
|
+#define _CP_0_OFF_5L 0xFF /* Disabled */
|
4232 |
|
|
+#define _CP_0_ON_5L 0xFE /* Enabled */
|
4233 |
|
|
+
|
4234 |
|
|
+/* Code Protect 02000-03FFF 5L options */
|
4235 |
|
|
+#define _CP_1_OFF_5L 0xFF /* Disabled */
|
4236 |
|
|
+#define _CP_1_ON_5L 0xFD /* Enabled */
|
4237 |
|
|
+
|
4238 |
|
|
+/* Code Protect 04000-05FFF 5L options */
|
4239 |
|
|
+#define _CP_2_OFF_5L 0xFF /* Disabled */
|
4240 |
|
|
+#define _CP_2_ON_5L 0xFB /* Enabled */
|
4241 |
|
|
+
|
4242 |
|
|
+/* Code Protect 06000-07FFF 5L options */
|
4243 |
|
|
+#define _CP_3_OFF_5L 0xFF /* Disabled */
|
4244 |
|
|
+#define _CP_3_ON_5L 0xF7 /* Enabled */
|
4245 |
|
|
+
|
4246 |
|
|
+/* Data EE Read Protect 5H options */
|
4247 |
|
|
+#define _CPD_OFF_5H 0xFF /* Disabled */
|
4248 |
|
|
+#define _CPD_ON_5H 0x7F /* Enabled */
|
4249 |
|
|
+
|
4250 |
|
|
+/* Code Protect Boot 5H options */
|
4251 |
|
|
+#define _CPB_OFF_5H 0xFF /* Disabled */
|
4252 |
|
|
+#define _CPB_ON_5H 0xBF /* Enabled */
|
4253 |
|
|
+
|
4254 |
|
|
+/* Table Write Protect 00200-01FFF 6L options */
|
4255 |
|
|
+#define _WRT_0_OFF_6L 0xFF /* Disabled */
|
4256 |
|
|
+#define _WRT_0_ON_6L 0xFE /* Enabled */
|
4257 |
|
|
+
|
4258 |
|
|
+/* Table Write Protect 02000-03FFF 6L options */
|
4259 |
|
|
+#define _WRT_1_OFF_6L 0xFF /* Disabled */
|
4260 |
|
|
+#define _WRT_1_ON_6L 0xFD /* Enabled */
|
4261 |
|
|
+
|
4262 |
|
|
+/* Table Write Protect 04000-05FFF 6L options */
|
4263 |
|
|
+#define _WRT_2_OFF_6L 0xFF /* Disabled */
|
4264 |
|
|
+#define _WRT_2_ON_6L 0xFB /* Enabled */
|
4265 |
|
|
+
|
4266 |
|
|
+/* Table Write Protect 06000-07FFF 6L options */
|
4267 |
|
|
+#define _WRT_3_OFF_6L 0xFF /* Disabled */
|
4268 |
|
|
+#define _WRT_3_ON_6L 0xF7 /* Enabled */
|
4269 |
|
|
+
|
4270 |
|
|
+/* Data EE Write Protect 6H options */
|
4271 |
|
|
+#define _WRTD_OFF_6H 0xFF /* Disabled */
|
4272 |
|
|
+#define _WRTD_ON_6H 0x7F /* Enabled */
|
4273 |
|
|
+
|
4274 |
|
|
+/* Table Write Protect Boot 6H options */
|
4275 |
|
|
+#define _WRTB_OFF_6H 0xFF /* Disabled */
|
4276 |
|
|
+#define _WRTB_ON_6H 0xBF /* Enabled */
|
4277 |
|
|
+
|
4278 |
|
|
+/* Config. Write Protect 6H options */
|
4279 |
|
|
+#define _WRTC_OFF_6H 0xFF /* Disabled */
|
4280 |
|
|
+#define _WRTC_ON_6H 0xDF /* Enabled */
|
4281 |
|
|
+
|
4282 |
|
|
+/* Table Read Protect 00200-01FFF 7L options */
|
4283 |
|
|
+#define _EBTR_0_OFF_7L 0xFF /* Disabled */
|
4284 |
|
|
+#define _EBTR_0_ON_7L 0xFE /* Enabled */
|
4285 |
|
|
+
|
4286 |
|
|
+/* Table Read Protect 02000-03FFF 7L options */
|
4287 |
|
|
+#define _EBTR_1_OFF_7L 0xFF /* Disabled */
|
4288 |
|
|
+#define _EBTR_1_ON_7L 0xFD /* Enabled */
|
4289 |
|
|
+
|
4290 |
|
|
+/* Table Read Protect 04000-05FFF 7L options */
|
4291 |
|
|
+#define _EBTR_2_OFF_7L 0xFF /* Disabled */
|
4292 |
|
|
+#define _EBTR_2_ON_7L 0xFB /* Enabled */
|
4293 |
|
|
+
|
4294 |
|
|
+/* Table Read Protect 06000-07FFF 7L options */
|
4295 |
|
|
+#define _EBTR_3_OFF_7L 0xFF /* Disabled */
|
4296 |
|
|
+#define _EBTR_3_ON_7L 0xF7 /* Enabled */
|
4297 |
|
|
+
|
4298 |
|
|
+/* Table Read Protect Boot 7H options */
|
4299 |
|
|
+#define _EBTRB_OFF_7H 0xFF /* Disabled */
|
4300 |
|
|
+#define _EBTRB_ON_7H 0xBF /* Enabled */
|
4301 |
|
|
+
|
4302 |
|
|
+
|
4303 |
|
|
+/* Device ID locations */
|
4304 |
|
|
+#define __IDLOC0 0x200000
|
4305 |
|
|
+#define __IDLOC1 0x200001
|
4306 |
|
|
+#define __IDLOC2 0x200002
|
4307 |
|
|
+#define __IDLOC3 0x200003
|
4308 |
|
|
+#define __IDLOC4 0x200004
|
4309 |
|
|
+#define __IDLOC5 0x200005
|
4310 |
|
|
+#define __IDLOC6 0x200006
|
4311 |
|
|
+#define __IDLOC7 0x200007
|
4312 |
|
|
+
|
4313 |
|
|
+
|
4314 |
|
|
+#endif
|
4315 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/pblazedevices.txt sdcc-src-3.1.0-pblaze/device/include/pblaze/pblazedevices.txt
|
4316 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/pblazedevices.txt 1970-01-01 01:00:00.000000000 +0100
|
4317 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/pblazedevices.txt 2011-08-23 15:56:36.000000000 +0200
|
4318 |
|
|
@@ -0,0 +1,53 @@
|
4319 |
|
|
+#
|
4320 |
|
|
+# Specification of devices supported by the PIC16 target of the
|
4321 |
|
|
+# Small Devices C Compiler (SDCC).
|
4322 |
|
|
+#
|
4323 |
|
|
+# Lines starting with a hash '#' are ignored.
|
4324 |
|
|
+# A new device specification must begin with a 'name' command.
|
4325 |
|
|
+# Numbers can be given in any way acceptable for scanf's %d,
|
4326 |
|
|
+# i.e., octal (0[0-7]*), decimal ([1-9][0-9]*), or hexadecimal
|
4327 |
|
|
+# (0[xX][0-9a-fA-F]+).
|
4328 |
|
|
+# Strings must not be quoted and may not contain whitespace!
|
4329 |
|
|
+#
|
4330 |
|
|
+# Valid commands are:
|
4331 |
|
|
+# name <name>
|
4332 |
|
|
+# Begin specification of device type <name>, e.g. 18f6720.
|
4333 |
|
|
+# Aliases 'p<name>' and 'pic<name>' will be recognized as well.
|
4334 |
|
|
+# using <name>
|
4335 |
|
|
+# Import specification from the named entry, which must be defined
|
4336 |
|
|
+# earlier. Later commands overrule imported ones.
|
4337 |
|
|
+# ramsize <size>
|
4338 |
|
|
+# This device has <size> bytes of RAM.
|
4339 |
|
|
+# split <offset>
|
4340 |
|
|
+# Addresses below <offset> refer to bank 0, addresses above <offset>
|
4341 |
|
|
+# refer to SFRs in bank 15 for references via the access bank.
|
4342 |
|
|
+# configrange <first> <last>
|
4343 |
|
|
+# Configuration registers occupy addresses <first> to <last> (both
|
4344 |
|
|
+# included).
|
4345 |
|
|
+# configword <address> <mask> <value>
|
4346 |
|
|
+# The config word at address <address> only implements the bits
|
4347 |
|
|
+# indicated via <mask> (all others will be forced to 0 by the
|
4348 |
|
|
+# compiler).
|
4349 |
|
|
+# Unless overridden in C code, use the given default <value>.
|
4350 |
|
|
+# idlocrange <first> <last>
|
4351 |
|
|
+# ID locations occupy addresses <first> to <last> (both included).
|
4352 |
|
|
+# idword <address> <value>
|
4353 |
|
|
+# Unless overridden in C code, use the given default <value>.
|
4354 |
|
|
+#
|
4355 |
|
|
+
|
4356 |
|
|
+name picoBlaze3
|
4357 |
|
|
+ramsize 64
|
4358 |
|
|
+split 0x40
|
4359 |
|
|
+configrange 0x300001 0x30000d
|
4360 |
|
|
+configword 0x300001 0x27 0xff
|
4361 |
|
|
+configword 0x300002 0x0f 0xff
|
4362 |
|
|
+configword 0x300003 0x0f 0xff
|
4363 |
|
|
+configword 0x300005 0x01 0xff
|
4364 |
|
|
+configword 0x300006 0x85 0xff
|
4365 |
|
|
+configword 0x300008 0x0f 0xff
|
4366 |
|
|
+configword 0x300009 0xc0 0xff
|
4367 |
|
|
+configword 0x30000a 0x0f 0xff
|
4368 |
|
|
+configword 0x30000b 0xe0 0xff
|
4369 |
|
|
+configword 0x30000c 0x0f 0xff
|
4370 |
|
|
+configword 0x30000d 0x40 0xff
|
4371 |
|
|
+idlocrange 0x200000 0x200007
|
4372 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/port.h sdcc-src-3.1.0-pblaze/device/include/pblaze/port.h
|
4373 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/port.h 1970-01-01 01:00:00.000000000 +0100
|
4374 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/port.h 2011-08-23 15:56:36.000000000 +0200
|
4375 |
|
|
@@ -0,0 +1,39 @@
|
4376 |
|
|
+#ifndef __PORT_H__
|
4377 |
|
|
+#define __PORT_H__
|
4378 |
|
|
+
|
4379 |
|
|
+#define MIN_PAUSE 10
|
4380 |
|
|
+
|
4381 |
|
|
+#include "delay.h"
|
4382 |
|
|
+/*
|
4383 |
|
|
+ * port.h - port communication functions header file
|
4384 |
|
|
+ *
|
4385 |
|
|
+ * adopted for SDCC and picoBlaze port by Zbynek Krivka, 2010 <krivka @ fit.vutbr.cz>
|
4386 |
|
|
+ *
|
4387 |
|
|
+*/
|
4388 |
|
|
+void __port_write(unsigned char, unsigned char);
|
4389 |
|
|
+unsigned char __port_read(volatile unsigned char);
|
4390 |
|
|
+
|
4391 |
|
|
+void __port_write(unsigned char port, unsigned char arg)
|
4392 |
|
|
+{
|
4393 |
|
|
+ unsigned volatile char p;
|
4394 |
|
|
+ unsigned volatile char a;
|
4395 |
|
|
+ p = port;
|
4396 |
|
|
+ a = arg;
|
4397 |
|
|
+ __asm
|
4398 |
|
|
+ OUTPUT _a, _p
|
4399 |
|
|
+ __endasm;
|
4400 |
|
|
+ delay(MIN_PAUSE);
|
4401 |
|
|
+}
|
4402 |
|
|
+
|
4403 |
|
|
+unsigned char __port_read(volatile unsigned char port)
|
4404 |
|
|
+{
|
4405 |
|
|
+ volatile unsigned char d = 0;
|
4406 |
|
|
+ volatile unsigned char p = port;
|
4407 |
|
|
+ __asm
|
4408 |
|
|
+ INPUT _d, _p
|
4409 |
|
|
+ __endasm;
|
4410 |
|
|
+ delay(MIN_PAUSE);
|
4411 |
|
|
+ return d;
|
4412 |
|
|
+}
|
4413 |
|
|
+
|
4414 |
|
|
+#endif
|
4415 |
|
|
\ No newline at end of file
|
4416 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/include/pblaze/stdint.h sdcc-src-3.1.0-pblaze/device/include/pblaze/stdint.h
|
4417 |
|
|
--- sdcc-src-3.1.0/device/include/pblaze/stdint.h 1970-01-01 01:00:00.000000000 +0100
|
4418 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/include/pblaze/stdint.h 2011-08-23 15:56:36.000000000 +0200
|
4419 |
|
|
@@ -0,0 +1,157 @@
|
4420 |
|
|
+/*-------------------------------------------------------------------------
|
4421 |
|
|
+ stdint.h - ISO C99 7.18 Integer types <stdint.h>
|
4422 |
|
|
+
|
4423 |
|
|
+ Written By - Maarten Brock, sourceforge.brock@dse.nl (2005)
|
4424 |
|
|
+
|
4425 |
|
|
+ This library is free software; you can redistribute it and/or
|
4426 |
|
|
+ modify it under the terms of the GNU Lesser General Public
|
4427 |
|
|
+ License as published by the Free Software Foundation; either
|
4428 |
|
|
+ version 2.1 of the License, or (at your option) any later version.
|
4429 |
|
|
+
|
4430 |
|
|
+ This library is distributed in the hope that it will be useful,
|
4431 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
4432 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
4433 |
|
|
+ Lesser General Public License for more details.
|
4434 |
|
|
+
|
4435 |
|
|
+ You should have received a copy of the GNU Lesser General Public
|
4436 |
|
|
+ License along with this library; if not, write to the Free Software
|
4437 |
|
|
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
4438 |
|
|
+-------------------------------------------------------------------------*/
|
4439 |
|
|
+
|
4440 |
|
|
+#ifndef _STDINT_H
|
4441 |
|
|
+#define _STDINT_H 1
|
4442 |
|
|
+
|
4443 |
|
|
+/* Exact integral types. */
|
4444 |
|
|
+
|
4445 |
|
|
+/* Signed. */
|
4446 |
|
|
+
|
4447 |
|
|
+typedef signed char int8_t;
|
4448 |
|
|
+typedef short int int16_t;
|
4449 |
|
|
+typedef long int int32_t;
|
4450 |
|
|
+
|
4451 |
|
|
+/* Unsigned. */
|
4452 |
|
|
+typedef unsigned char uint8_t;
|
4453 |
|
|
+typedef unsigned short int uint16_t;
|
4454 |
|
|
+typedef unsigned long int uint32_t;
|
4455 |
|
|
+
|
4456 |
|
|
+
|
4457 |
|
|
+/* Small types. */
|
4458 |
|
|
+
|
4459 |
|
|
+/* Signed. */
|
4460 |
|
|
+typedef signed char int_least8_t;
|
4461 |
|
|
+typedef short int int_least16_t;
|
4462 |
|
|
+typedef long int int_least32_t;
|
4463 |
|
|
+
|
4464 |
|
|
+/* Unsigned. */
|
4465 |
|
|
+typedef unsigned char uint_least8_t;
|
4466 |
|
|
+typedef unsigned short int uint_least16_t;
|
4467 |
|
|
+typedef unsigned long int uint_least32_t;
|
4468 |
|
|
+
|
4469 |
|
|
+
|
4470 |
|
|
+/* Fast types. */
|
4471 |
|
|
+
|
4472 |
|
|
+/* Signed. */
|
4473 |
|
|
+typedef signed char int_fast8_t;
|
4474 |
|
|
+typedef int int_fast16_t;
|
4475 |
|
|
+typedef long int int_fast32_t;
|
4476 |
|
|
+
|
4477 |
|
|
+/* Unsigned. */
|
4478 |
|
|
+typedef unsigned char uint_fast8_t;
|
4479 |
|
|
+typedef unsigned int uint_fast16_t;
|
4480 |
|
|
+typedef unsigned long int uint_fast32_t;
|
4481 |
|
|
+
|
4482 |
|
|
+
|
4483 |
|
|
+/* Types for `void *' pointers. */
|
4484 |
|
|
+typedef long int intptr_t;
|
4485 |
|
|
+typedef unsigned long int uintptr_t;
|
4486 |
|
|
+
|
4487 |
|
|
+
|
4488 |
|
|
+/* Largest integral types. */
|
4489 |
|
|
+typedef long int intmax_t;
|
4490 |
|
|
+typedef unsigned long int uintmax_t;
|
4491 |
|
|
+
|
4492 |
|
|
+
|
4493 |
|
|
+/* Limits of integral types. */
|
4494 |
|
|
+
|
4495 |
|
|
+/* Minimum of signed integral types. */
|
4496 |
|
|
+# define INT8_MIN (-128)
|
4497 |
|
|
+# define INT16_MIN (-32767-1)
|
4498 |
|
|
+# define INT32_MIN (-2147483647L-1)
|
4499 |
|
|
+/* Maximum of signed integral types. */
|
4500 |
|
|
+# define INT8_MAX (127)
|
4501 |
|
|
+# define INT16_MAX (32767)
|
4502 |
|
|
+# define INT32_MAX (2147483647L)
|
4503 |
|
|
+
|
4504 |
|
|
+/* Maximum of unsigned integral types. */
|
4505 |
|
|
+# define UINT8_MAX (255)
|
4506 |
|
|
+# define UINT16_MAX (65535)
|
4507 |
|
|
+# define UINT32_MAX (4294967295UL)
|
4508 |
|
|
+
|
4509 |
|
|
+/* Minimum of signed integral types having a minimum size. */
|
4510 |
|
|
+# define INT_LEAST8_MIN (-128)
|
4511 |
|
|
+# define INT_LEAST16_MIN (-32767-1)
|
4512 |
|
|
+# define INT_LEAST32_MIN (-2147483647L-1)
|
4513 |
|
|
+/* Maximum of signed integral types having a minimum size. */
|
4514 |
|
|
+# define INT_LEAST8_MAX (127)
|
4515 |
|
|
+# define INT_LEAST16_MAX (32767)
|
4516 |
|
|
+# define INT_LEAST32_MAX (2147483647L)
|
4517 |
|
|
+
|
4518 |
|
|
+/* Maximum of unsigned integral types having a minimum size. */
|
4519 |
|
|
+# define UINT_LEAST8_MAX (255)
|
4520 |
|
|
+# define UINT_LEAST16_MAX (65535)
|
4521 |
|
|
+# define UINT_LEAST32_MAX (4294967295UL)
|
4522 |
|
|
+
|
4523 |
|
|
+/* Minimum of fast signed integral types having a minimum size. */
|
4524 |
|
|
+# define INT_FAST8_MIN (-128)
|
4525 |
|
|
+# define INT_FAST16_MIN (-32767-1)
|
4526 |
|
|
+# define INT_FAST32_MIN (-2147483647L-1)
|
4527 |
|
|
+
|
4528 |
|
|
+/* Maximum of fast signed integral types having a minimum size. */
|
4529 |
|
|
+# define INT_FAST8_MAX (127)
|
4530 |
|
|
+# define INT_FAST16_MAX (32767)
|
4531 |
|
|
+# define INT_FAST32_MAX (2147483647L)
|
4532 |
|
|
+
|
4533 |
|
|
+/* Maximum of fast unsigned integral types having a minimum size. */
|
4534 |
|
|
+# define UINT_FAST8_MAX (255)
|
4535 |
|
|
+# define UINT_FAST16_MAX (65535)
|
4536 |
|
|
+# define UINT_FAST32_MAX (4294967295UL)
|
4537 |
|
|
+
|
4538 |
|
|
+/* Values to test for integral types holding `void *' pointer. */
|
4539 |
|
|
+# define INTPTR_MIN (-2147483647L-1)
|
4540 |
|
|
+# define INTPTR_MAX (2147483647L)
|
4541 |
|
|
+# define UINTPTR_MAX (4294967295UL)
|
4542 |
|
|
+
|
4543 |
|
|
+/* Minimum for largest signed integral type. */
|
4544 |
|
|
+# define INTMAX_MIN (-__INT32_C(-2147483647L)-1)
|
4545 |
|
|
+/* Maximum for largest signed integral type. */
|
4546 |
|
|
+# define INTMAX_MAX (__INT32_C(2147483647L))
|
4547 |
|
|
+
|
4548 |
|
|
+/* Maximum for largest unsigned integral type. */
|
4549 |
|
|
+# define UINTMAX_MAX (__UINT32_C(4294967295UL))
|
4550 |
|
|
+
|
4551 |
|
|
+
|
4552 |
|
|
+/* Limits of other integer types. */
|
4553 |
|
|
+
|
4554 |
|
|
+/* Limits of `ptrdiff_t' type. */
|
4555 |
|
|
+# define PTRDIFF_MIN (-2147483647L-1)
|
4556 |
|
|
+# define PTRDIFF_MAX (2147483647L)
|
4557 |
|
|
+
|
4558 |
|
|
+/* Limit of `size_t' type. */
|
4559 |
|
|
+# define SIZE_MAX (65535)
|
4560 |
|
|
+
|
4561 |
|
|
+/* Signed. */
|
4562 |
|
|
+# define INT8_C(c) c
|
4563 |
|
|
+# define INT16_C(c) c
|
4564 |
|
|
+# define INT32_C(c) c ## L
|
4565 |
|
|
+
|
4566 |
|
|
+/* Unsigned. */
|
4567 |
|
|
+# define UINT8_C(c) c ## U
|
4568 |
|
|
+# define UINT16_C(c) c ## U
|
4569 |
|
|
+# define UINT32_C(c) c ## UL
|
4570 |
|
|
+
|
4571 |
|
|
+/* Maximal type. */
|
4572 |
|
|
+# define INTMAX_C(c) c ## L
|
4573 |
|
|
+# define UINTMAX_C(c) c ## UL
|
4574 |
|
|
+
|
4575 |
|
|
+
|
4576 |
|
|
+#endif /* stdint.h */
|
4577 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/lib/Makefile.in sdcc-src-3.1.0-pblaze/device/lib/Makefile.in
|
4578 |
|
|
--- sdcc-src-3.1.0/device/lib/Makefile.in 2011-11-01 17:35:46.000000000 +0100
|
4579 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/lib/Makefile.in 2011-12-04 13:55:53.223464300 +0100
|
4580 |
|
|
@@ -70,6 +70,7 @@
|
4581 |
|
|
OPT_DISABLE_Z80 = @OPT_DISABLE_Z80@
|
4582 |
|
|
OPT_DISABLE_Z180 = @OPT_DISABLE_Z180@
|
4583 |
|
|
OPT_DISABLE_R2K = @OPT_DISABLE_R2K@
|
4584 |
|
|
+OPT_DISABLE_PBLAZE= @OPT_DISABLE_PBLAZE@
|
4585 |
|
|
|
4586 |
|
|
SOURCES_FLOAT = $(COMMON_FLOAT) \
|
4587 |
|
|
_fscmp.c \
|
4588 |
|
|
diff -NaurbB sdcc-src-3.1.0/device/non-free/lib/Makefile.in sdcc-src-3.1.0-pblaze/device/non-free/lib/Makefile.in
|
4589 |
|
|
--- sdcc-src-3.1.0/device/non-free/lib/Makefile.in 2011-10-25 20:43:54.000000000 +0200
|
4590 |
|
|
+++ sdcc-src-3.1.0-pblaze/device/non-free/lib/Makefile.in 2011-12-04 13:57:07.901735700 +0100
|
4591 |
|
|
@@ -68,6 +68,7 @@
|
4592 |
|
|
OPT_DISABLE_PIC16 = @OPT_DISABLE_PIC16@
|
4593 |
|
|
OPT_DISABLE_XA51 = @OPT_DISABLE_XA51@
|
4594 |
|
|
OPT_DISABLE_Z80 = @OPT_DISABLE_Z80@
|
4595 |
|
|
+OPT_DISABLE_PBLAZE= @OPT_DISABLE_PBLAZE@
|
4596 |
|
|
|
4597 |
|
|
SOURCES_FLOAT = $(COMMON_FLOAT) \
|
4598 |
|
|
_fscmp.c \
|
4599 |
|
|
diff -NaurbB sdcc-src-3.1.0/doc/sdcc_pblaze_instructions.txt sdcc-src-3.1.0-pblaze/doc/sdcc_pblaze_instructions.txt
|
4600 |
|
|
--- sdcc-src-3.1.0/doc/sdcc_pblaze_instructions.txt 1970-01-01 01:00:00.000000000 +0100
|
4601 |
|
|
+++ sdcc-src-3.1.0-pblaze/doc/sdcc_pblaze_instructions.txt 2011-12-06 21:32:48.872001100 +0100
|
4602 |
|
|
@@ -0,0 +1,57 @@
|
4603 |
|
|
+
|
4604 |
|
|
+# ================ #
|
4605 |
|
|
+# PHASE : ADD PORT #
|
4606 |
|
|
+# ================ #
|
4607 |
|
|
+# configure
|
4608 |
|
|
+- in : sdcc\configure.in.
|
4609 |
|
|
+- near "Now handle the port selection"
|
4610 |
|
|
+- add :
|
4611 |
|
|
+AC_DO_PORT(pblaze, pblaze, PBLAZE, [Excludes the PBLAZE port])
|
4612 |
|
|
+
|
4613 |
|
|
+- near : "Generating output files"
|
4614 |
|
|
+- add :
|
4615 |
|
|
+if test $OPT_DISABLE_PBLAZE = 0; then
|
4616 |
|
|
+ AC_CONFIG_FILES([src/pblaze/Makefile])
|
4617 |
|
|
+fi
|
4618 |
|
|
+
|
4619 |
|
|
+- near : "ENABLED Ports:"
|
4620 |
|
|
+- add :
|
4621 |
|
|
+ pblaze ${enable_pblaze_port}
|
4622 |
|
|
+
|
4623 |
|
|
+# directory:
|
4624 |
|
|
+- add :
|
4625 |
|
|
+sdcc\device\include\pblaze
|
4626 |
|
|
+sdcc\src\pblaze
|
4627 |
|
|
+sdcc\tests\pblaze
|
4628 |
|
|
+
|
4629 |
|
|
+# =================== #
|
4630 |
|
|
+# PHASE : COMPILATION #
|
4631 |
|
|
+# =================== #
|
4632 |
|
|
+# decompress
|
4633 |
|
|
+tar -xjf sdcc-src-3.1.0.tar.bz2
|
4634 |
|
|
+
|
4635 |
|
|
+# move to directory
|
4636 |
|
|
+cd sdcc
|
4637 |
|
|
+
|
4638 |
|
|
+# configure
|
4639 |
|
|
+./configure \
|
4640 |
|
|
+--disable-mcs51-port \
|
4641 |
|
|
+--disable-gbz80-port \
|
4642 |
|
|
+--disable-z80-port \
|
4643 |
|
|
+--disable-z180-port \
|
4644 |
|
|
+--disable-avr-port \
|
4645 |
|
|
+--disable-ds390-port \
|
4646 |
|
|
+--disable-ds400-port \
|
4647 |
|
|
+--disable-hc08-port \
|
4648 |
|
|
+--disable-pic14-port \
|
4649 |
|
|
+--disable-pic16-port \
|
4650 |
|
|
+--disable-r2k-port \
|
4651 |
|
|
+--disable-xa51-port \
|
4652 |
|
|
+--disable-ucsim \
|
4653 |
|
|
+--disable-device-lib \
|
4654 |
|
|
+--disable-packihx
|
4655 |
|
|
+
|
4656 |
|
|
+# make
|
4657 |
|
|
+make
|
4658 |
|
|
+
|
4659 |
|
|
+# install
|
4660 |
|
|
\ No newline at end of file
|
4661 |
|
|
diff -NaurbB sdcc-src-3.1.0/sdcc_vc_in.h sdcc-src-3.1.0-pblaze/sdcc_vc_in.h
|
4662 |
|
|
--- sdcc-src-3.1.0/sdcc_vc_in.h 2011-06-10 23:19:02.000000000 +0200
|
4663 |
|
|
+++ sdcc-src-3.1.0-pblaze/sdcc_vc_in.h 2011-12-04 15:18:59.087639400 +0100
|
4664 |
|
|
@@ -77,6 +77,7 @@
|
4665 |
|
|
#undef OPT_DISABLE_PIC14
|
4666 |
|
|
#undef OPT_DISABLE_PIC16
|
4667 |
|
|
#define OPT_DISABLE_XA51 1
|
4668 |
|
|
+#undef OPT_DISABLE_PBLAZE
|
4669 |
|
|
|
4670 |
|
|
#endif /* SDCC_VC_HEADER */
|
4671 |
|
|
|
4672 |
|
|
diff -NaurbB sdcc-src-3.1.0/sdccconf_in.h sdcc-src-3.1.0-pblaze/sdccconf_in.h
|
4673 |
|
|
--- sdcc-src-3.1.0/sdccconf_in.h 2011-10-09 20:21:10.000000000 +0200
|
4674 |
|
|
+++ sdcc-src-3.1.0-pblaze/sdccconf_in.h 2011-12-04 13:59:25.373598600 +0100
|
4675 |
|
|
@@ -138,6 +138,9 @@
|
4676 |
|
|
#undef OPT_DISABLE_R2K
|
4677 |
|
|
|
4678 |
|
|
/* XXX */
|
4679 |
|
|
+#undef OPT_DISABLE_PBLAZE
|
4680 |
|
|
+
|
4681 |
|
|
+/* XXX */
|
4682 |
|
|
#undef OPT_DISABLE_SDCDB
|
4683 |
|
|
|
4684 |
|
|
/* XXX */
|
4685 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/SDCCmain.c sdcc-src-3.1.0-pblaze/src/SDCCmain.c
|
4686 |
|
|
--- sdcc-src-3.1.0/src/SDCCmain.c 2011-10-09 20:21:10.000000000 +0200
|
4687 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/SDCCmain.c 2011-12-04 14:01:09.673564200 +0100
|
4688 |
|
|
@@ -340,6 +340,9 @@
|
4689 |
|
|
#if !OPT_DISABLE_HC08
|
4690 |
|
|
&hc08_port,
|
4691 |
|
|
#endif
|
4692 |
|
|
+#if !OPT_DISABLE_PBLAZE
|
4693 |
|
|
+ &pblaze_port,
|
4694 |
|
|
+#endif
|
4695 |
|
|
};
|
4696 |
|
|
|
4697 |
|
|
#define NUM_PORTS (sizeof(_ports)/sizeof(_ports[0]))
|
4698 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/Makefile.in sdcc-src-3.1.0-pblaze/src/json/Makefile.in
|
4699 |
|
|
--- sdcc-src-3.1.0/src/json/Makefile.in 1970-01-01 01:00:00.000000000 +0100
|
4700 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/Makefile.in 2011-02-07 20:04:44.000000000 +0100
|
4701 |
|
|
@@ -0,0 +1,8 @@
|
4702 |
|
|
+VPATH = @srcdir@
|
4703 |
|
|
+srcdir = @srcdir@
|
4704 |
|
|
+top_builddir = @top_builddir@
|
4705 |
|
|
+top_srcdir = @top_srcdir@
|
4706 |
|
|
+
|
4707 |
|
|
+# Make all in this directory
|
4708 |
|
|
+include $(srcdir)/../port.mk
|
4709 |
|
|
+
|
4710 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/device.h sdcc-src-3.1.0-pblaze/src/json/device.h
|
4711 |
|
|
--- sdcc-src-3.1.0/src/json/device.h 1970-01-01 01:00:00.000000000 +0100
|
4712 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/device.h 2011-02-07 20:04:44.000000000 +0100
|
4713 |
|
|
@@ -0,0 +1,61 @@
|
4714 |
|
|
+/*-------------------------------------------------------------------------
|
4715 |
|
|
+
|
4716 |
|
|
+ Json
|
4717 |
|
|
+
|
4718 |
|
|
+ device.c - Accomodates subtle variations in JSON devices
|
4719 |
|
|
+
|
4720 |
|
|
+ Written By - Scott Dattalo scott@dattalo.com
|
4721 |
|
|
+
|
4722 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
4723 |
|
|
+ under the terms of the GNU General Public License as published by the
|
4724 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
4725 |
|
|
+ later version.
|
4726 |
|
|
+
|
4727 |
|
|
+ This program is distributed in the hope that it will be useful,
|
4728 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
4729 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
4730 |
|
|
+ GNU General Public License for more details.
|
4731 |
|
|
+
|
4732 |
|
|
+ You should have received a copy of the GNU General Public License
|
4733 |
|
|
+ along with this program; if not, write to the Free Software
|
4734 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
4735 |
|
|
+-------------------------------------------------------------------------*/
|
4736 |
|
|
+
|
4737 |
|
|
+/*
|
4738 |
|
|
+ PIC device abstraction
|
4739 |
|
|
+
|
4740 |
|
|
+ There are dozens of variations of PIC microcontrollers. This include
|
4741 |
|
|
+ file attempts to abstract those differences so that SDCC can easily
|
4742 |
|
|
+ deal with them.
|
4743 |
|
|
+*/
|
4744 |
|
|
+
|
4745 |
|
|
+#ifndef __JSON_DEVICE_H__
|
4746 |
|
|
+#define __JSON_DEVICE_H__
|
4747 |
|
|
+
|
4748 |
|
|
+
|
4749 |
|
|
+#define PROCESSOR_NAMES 4
|
4750 |
|
|
+/* Processor unique attributes */
|
4751 |
|
|
+
|
4752 |
|
|
+typedef struct JSON_device {
|
4753 |
|
|
+ char *name[PROCESSOR_NAMES]; /* aliases for the processor name */
|
4754 |
|
|
+ /* RAMsize *must* be the first item to copy for 'using' */
|
4755 |
|
|
+ int RAMsize; /* size of Data RAM - VR 031120 */
|
4756 |
|
|
+ int acsSplitOfs; /* access bank split offset */
|
4757 |
|
|
+// configWordsInfo_t cwInfo; /* configuration words info */
|
4758 |
|
|
+// idBytesInfo_t idInfo; /* ID Locations info */
|
4759 |
|
|
+ /* next *must* be the first field NOT being copied via 'using' */
|
4760 |
|
|
+ struct JSON_device *next; /* linked list */
|
4761 |
|
|
+} JSON_device;
|
4762 |
|
|
+
|
4763 |
|
|
+extern JSON_device *picoBlaze;
|
4764 |
|
|
+
|
4765 |
|
|
+typedef struct {
|
4766 |
|
|
+ int json_flag; // JSON flag if to do the dump of iCodes in JSON format
|
4767 |
|
|
+ char *json_dumpfile; // name of the JSON dump file
|
4768 |
|
|
+} json_options_t;
|
4769 |
|
|
+
|
4770 |
|
|
+extern json_options_t json_options;
|
4771 |
|
|
+
|
4772 |
|
|
+
|
4773 |
|
|
+#endif /* __JSON_DEVICE_H__ */
|
4774 |
|
|
+
|
4775 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/gen.c sdcc-src-3.1.0-pblaze/src/json/gen.c
|
4776 |
|
|
--- sdcc-src-3.1.0/src/json/gen.c 1970-01-01 01:00:00.000000000 +0100
|
4777 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/gen.c 2011-02-07 20:04:48.000000000 +0100
|
4778 |
|
|
@@ -0,0 +1,1193 @@
|
4779 |
|
|
+/*-------------------------------------------------------------------------
|
4780 |
|
|
+ gen.c - source file for code generation into JSON
|
4781 |
|
|
+
|
4782 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
4783 |
|
|
+ under the terms of the GNU General Public License as published by the
|
4784 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
4785 |
|
|
+ later version.
|
4786 |
|
|
+
|
4787 |
|
|
+ This program is distributed in the hope that it will be useful,
|
4788 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
4789 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
4790 |
|
|
+ GNU General Public License for more details.
|
4791 |
|
|
+
|
4792 |
|
|
+ You should have received a copy of the GNU General Public License
|
4793 |
|
|
+ along with this program; if not, write to the Free Software
|
4794 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
4795 |
|
|
+
|
4796 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
4797 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
4798 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
4799 |
|
|
+
|
4800 |
|
|
+
|
4801 |
|
|
+-------------------------------------------------------------------------*/
|
4802 |
|
|
+
|
4803 |
|
|
+#define D(x) do if (options.verboseAsm) {x;} while(0)
|
4804 |
|
|
+
|
4805 |
|
|
+#include <stdio.h>
|
4806 |
|
|
+#include <stdlib.h>
|
4807 |
|
|
+#include <string.h>
|
4808 |
|
|
+#include <ctype.h>
|
4809 |
|
|
+#include "SDCCglobl.h"
|
4810 |
|
|
+#include "newalloc.h"
|
4811 |
|
|
+
|
4812 |
|
|
+#include "common.h"
|
4813 |
|
|
+#include "SDCCpeeph.h"
|
4814 |
|
|
+#include "ralloc.h"
|
4815 |
|
|
+#include "gen.h"
|
4816 |
|
|
+
|
4817 |
|
|
+#include "json/json.h"
|
4818 |
|
|
+
|
4819 |
|
|
+extern int allocInfo;
|
4820 |
|
|
+
|
4821 |
|
|
+// unsigned fJSONReturnSize = 4; /* shared with ralloc.c */
|
4822 |
|
|
+
|
4823 |
|
|
+static struct {
|
4824 |
|
|
+ short xPushed;
|
4825 |
|
|
+ short zPushed;
|
4826 |
|
|
+ short accInUse;
|
4827 |
|
|
+ short inLine;
|
4828 |
|
|
+ short debugLine;
|
4829 |
|
|
+ short nRegsSaved;
|
4830 |
|
|
+ set *sendSet;
|
4831 |
|
|
+} _G;
|
4832 |
|
|
+
|
4833 |
|
|
+extern int json_ptrRegReq;
|
4834 |
|
|
+extern int json_nRegs;
|
4835 |
|
|
+extern struct dbuf_s *codeOutBuf;
|
4836 |
|
|
+
|
4837 |
|
|
+
|
4838 |
|
|
+static lineNode *lineHead = NULL;
|
4839 |
|
|
+static lineNode *lineCurr = NULL;
|
4840 |
|
|
+
|
4841 |
|
|
+#define LSB 0
|
4842 |
|
|
+#define MSB16 1
|
4843 |
|
|
+#define MSB24 2
|
4844 |
|
|
+#define MSB32 3
|
4845 |
|
|
+
|
4846 |
|
|
+/*-----------------------------------------------------------------*/
|
4847 |
|
|
+/* emitcode - writes the code into a file */
|
4848 |
|
|
+/*-----------------------------------------------------------------*/
|
4849 |
|
|
+static void
|
4850 |
|
|
+emitcode (char *inst, char *fmt, ...)
|
4851 |
|
|
+{
|
4852 |
|
|
+ va_list ap;
|
4853 |
|
|
+ char lb[INITIAL_INLINEASM];
|
4854 |
|
|
+ char *lbp = lb;
|
4855 |
|
|
+
|
4856 |
|
|
+ va_start (ap, fmt);
|
4857 |
|
|
+
|
4858 |
|
|
+ if (inst && *inst) {
|
4859 |
|
|
+ if (fmt && *fmt)
|
4860 |
|
|
+ sprintf (lb, "%s\t", inst);
|
4861 |
|
|
+ else
|
4862 |
|
|
+ sprintf (lb, "%s", inst);
|
4863 |
|
|
+ vsprintf (lb + (strlen (lb)), fmt, ap);
|
4864 |
|
|
+ }
|
4865 |
|
|
+ else
|
4866 |
|
|
+ vsprintf (lb, fmt, ap);
|
4867 |
|
|
+
|
4868 |
|
|
+ while (isspace ((unsigned char)*lbp))
|
4869 |
|
|
+ lbp++;
|
4870 |
|
|
+
|
4871 |
|
|
+ if (lbp && *lbp)
|
4872 |
|
|
+ lineCurr = (lineCurr ?
|
4873 |
|
|
+ connectLine (lineCurr, newLineNode (lb)) :
|
4874 |
|
|
+ (lineHead = newLineNode (lb)));
|
4875 |
|
|
+ lineCurr->isInline = _G.inLine;
|
4876 |
|
|
+ lineCurr->isDebug = _G.debugLine;
|
4877 |
|
|
+ va_end (ap);
|
4878 |
|
|
+}
|
4879 |
|
|
+
|
4880 |
|
|
+/*-----------------------------------------------------------------*/
|
4881 |
|
|
+/* json_emitDebuggerSymbol - associate the current code location */
|
4882 |
|
|
+/* with a debugger symbol */
|
4883 |
|
|
+/*-----------------------------------------------------------------*/
|
4884 |
|
|
+void
|
4885 |
|
|
+json_emitDebuggerSymbol (const char * debugSym)
|
4886 |
|
|
+{
|
4887 |
|
|
+ _G.debugLine = 1;
|
4888 |
|
|
+ emitcode ("", "%s ==.", debugSym);
|
4889 |
|
|
+ _G.debugLine = 0;
|
4890 |
|
|
+}
|
4891 |
|
|
+
|
4892 |
|
|
+
|
4893 |
|
|
+/*-----------------------------------------------------------------*/
|
4894 |
|
|
+/* newAsmop - creates a new asmOp */
|
4895 |
|
|
+/*-----------------------------------------------------------------*/
|
4896 |
|
|
+static asmop *
|
4897 |
|
|
+newAsmop (short type)
|
4898 |
|
|
+{
|
4899 |
|
|
+ asmop *aop;
|
4900 |
|
|
+
|
4901 |
|
|
+ aop = Safe_calloc (1, sizeof (asmop));
|
4902 |
|
|
+ aop->type = type;
|
4903 |
|
|
+ return aop;
|
4904 |
|
|
+}
|
4905 |
|
|
+
|
4906 |
|
|
+/*-----------------------------------------------------------------*/
|
4907 |
|
|
+/* pointerCode - returns the code for a pointer type */
|
4908 |
|
|
+/*-----------------------------------------------------------------*/
|
4909 |
|
|
+static int
|
4910 |
|
|
+pointerCode (sym_link * etype)
|
4911 |
|
|
+{
|
4912 |
|
|
+
|
4913 |
|
|
+ return PTR_TYPE (SPEC_OCLS (etype));
|
4914 |
|
|
+
|
4915 |
|
|
+}
|
4916 |
|
|
+
|
4917 |
|
|
+
|
4918 |
|
|
+/*-----------------------------------------------------------------*/
|
4919 |
|
|
+/* regsInCommon - two operands have some registers in common */
|
4920 |
|
|
+/*-----------------------------------------------------------------*/
|
4921 |
|
|
+static bool
|
4922 |
|
|
+regsInCommon (operand * op1, operand * op2)
|
4923 |
|
|
+{
|
4924 |
|
|
+ symbol *sym1, *sym2;
|
4925 |
|
|
+ int i;
|
4926 |
|
|
+
|
4927 |
|
|
+ /* if they have registers in common */
|
4928 |
|
|
+ if (!IS_SYMOP (op1) || !IS_SYMOP (op2))
|
4929 |
|
|
+ return FALSE;
|
4930 |
|
|
+
|
4931 |
|
|
+ sym1 = OP_SYMBOL (op1);
|
4932 |
|
|
+ sym2 = OP_SYMBOL (op2);
|
4933 |
|
|
+
|
4934 |
|
|
+ if (sym1->nRegs == 0 || sym2->nRegs == 0)
|
4935 |
|
|
+ return FALSE;
|
4936 |
|
|
+
|
4937 |
|
|
+ for (i = 0; i < sym1->nRegs; i++) {
|
4938 |
|
|
+ int j;
|
4939 |
|
|
+ if (!sym1->regs[i])
|
4940 |
|
|
+ continue;
|
4941 |
|
|
+
|
4942 |
|
|
+ for (j = 0; j < sym2->nRegs; j++) {
|
4943 |
|
|
+ if (!sym2->regs[j])
|
4944 |
|
|
+ continue;
|
4945 |
|
|
+
|
4946 |
|
|
+ if (sym2->regs[j] == sym1->regs[i])
|
4947 |
|
|
+ return TRUE;
|
4948 |
|
|
+ }
|
4949 |
|
|
+ }
|
4950 |
|
|
+
|
4951 |
|
|
+ return FALSE;
|
4952 |
|
|
+}
|
4953 |
|
|
+
|
4954 |
|
|
+/*-----------------------------------------------------------------*/
|
4955 |
|
|
+/* operandsEqu - equivalent */
|
4956 |
|
|
+/*-----------------------------------------------------------------*/
|
4957 |
|
|
+static bool
|
4958 |
|
|
+operandsEqu (operand * op1, operand * op2)
|
4959 |
|
|
+{
|
4960 |
|
|
+ symbol *sym1, *sym2;
|
4961 |
|
|
+
|
4962 |
|
|
+ /* if they not symbols */
|
4963 |
|
|
+ if (!IS_SYMOP (op1) || !IS_SYMOP (op2))
|
4964 |
|
|
+ return FALSE;
|
4965 |
|
|
+
|
4966 |
|
|
+ sym1 = OP_SYMBOL (op1);
|
4967 |
|
|
+ sym2 = OP_SYMBOL (op2);
|
4968 |
|
|
+
|
4969 |
|
|
+ /* if they are the same */
|
4970 |
|
|
+ if (sym1 == sym2)
|
4971 |
|
|
+ return TRUE;
|
4972 |
|
|
+
|
4973 |
|
|
+ if (strcmp (sym1->rname, sym2->rname) == 0)
|
4974 |
|
|
+ return TRUE;
|
4975 |
|
|
+
|
4976 |
|
|
+
|
4977 |
|
|
+ /* if left is a tmp & right is not */
|
4978 |
|
|
+ if (IS_ITEMP (op1) &&
|
4979 |
|
|
+ !IS_ITEMP (op2) && sym1->isspilt && (sym1->usl.spillLoc == sym2))
|
4980 |
|
|
+ return TRUE;
|
4981 |
|
|
+
|
4982 |
|
|
+ if (IS_ITEMP (op2) &&
|
4983 |
|
|
+ !IS_ITEMP (op1) &&
|
4984 |
|
|
+ sym2->isspilt && sym1->level > 0 && (sym2->usl.spillLoc == sym1))
|
4985 |
|
|
+ return TRUE;
|
4986 |
|
|
+
|
4987 |
|
|
+ return FALSE;
|
4988 |
|
|
+}
|
4989 |
|
|
+
|
4990 |
|
|
+
|
4991 |
|
|
+/*-----------------------------------------------------------------*/
|
4992 |
|
|
+/* aopOp - allocates an asmop for an operand : */
|
4993 |
|
|
+/*-----------------------------------------------------------------*/
|
4994 |
|
|
+static void
|
4995 |
|
|
+aopOp (operand * op, iCode * ic, bool result)
|
4996 |
|
|
+{
|
4997 |
|
|
+ asmop *aop;
|
4998 |
|
|
+ symbol *sym;
|
4999 |
|
|
+ int i;
|
5000 |
|
|
+
|
5001 |
|
|
+ if (!op)
|
5002 |
|
|
+ return;
|
5003 |
|
|
+
|
5004 |
|
|
+ /* if this a literal */
|
5005 |
|
|
+ if (IS_OP_LITERAL (op)) {
|
5006 |
|
|
+ op->aop = aop = newAsmop (AOP_LIT);
|
5007 |
|
|
+ aop->aopu.aop_lit = op->operand.valOperand;
|
5008 |
|
|
+ aop->size = getSize (operandType (op));
|
5009 |
|
|
+ return;
|
5010 |
|
|
+ }
|
5011 |
|
|
+
|
5012 |
|
|
+ /* if already has a asmop then continue */
|
5013 |
|
|
+ if (op->aop)
|
5014 |
|
|
+ return;
|
5015 |
|
|
+
|
5016 |
|
|
+ /* must be load into a register */
|
5017 |
|
|
+ sym->aop = op->aop = aop = newAsmop (AOP_REG);
|
5018 |
|
|
+ aop->size = sym->nRegs;
|
5019 |
|
|
+ //getReg (op, aop);
|
5020 |
|
|
+
|
5021 |
|
|
+}
|
5022 |
|
|
+
|
5023 |
|
|
+/*-----------------------------------------------------------------*/
|
5024 |
|
|
+/* freeAsmop - free up the asmop given to an operand */
|
5025 |
|
|
+/*----------------------------------------------------------------*/
|
5026 |
|
|
+static void
|
5027 |
|
|
+freeAsmop (operand * op, asmop * aaop, iCode * ic)
|
5028 |
|
|
+{
|
5029 |
|
|
+ asmop *aop;
|
5030 |
|
|
+
|
5031 |
|
|
+ if (!op)
|
5032 |
|
|
+ aop = aaop;
|
5033 |
|
|
+ else
|
5034 |
|
|
+ aop = op->aop;
|
5035 |
|
|
+
|
5036 |
|
|
+ if (!aop)
|
5037 |
|
|
+ return;
|
5038 |
|
|
+
|
5039 |
|
|
+ if (op) {
|
5040 |
|
|
+ op->aop = NULL;
|
5041 |
|
|
+ }
|
5042 |
|
|
+}
|
5043 |
|
|
+
|
5044 |
|
|
+
|
5045 |
|
|
+
|
5046 |
|
|
+/*-----------------------------------------------------------------*/
|
5047 |
|
|
+/* genNotFloat - generates not for float operations */
|
5048 |
|
|
+/*-----------------------------------------------------------------*/
|
5049 |
|
|
+static void
|
5050 |
|
|
+genNotFloat (operand * op, operand * res)
|
5051 |
|
|
+{
|
5052 |
|
|
+
|
5053 |
|
|
+}
|
5054 |
|
|
+
|
5055 |
|
|
+/*-----------------------------------------------------------------*/
|
5056 |
|
|
+/* genNot - generate code for ! operation */
|
5057 |
|
|
+/*-----------------------------------------------------------------*/
|
5058 |
|
|
+static void
|
5059 |
|
|
+genNot (iCode * ic)
|
5060 |
|
|
+{
|
5061 |
|
|
+
|
5062 |
|
|
+}
|
5063 |
|
|
+
|
5064 |
|
|
+
|
5065 |
|
|
+/*-----------------------------------------------------------------*/
|
5066 |
|
|
+/* genCpl - generate code for complement */
|
5067 |
|
|
+/*-----------------------------------------------------------------*/
|
5068 |
|
|
+static void
|
5069 |
|
|
+genCpl (iCode * ic)
|
5070 |
|
|
+{
|
5071 |
|
|
+
|
5072 |
|
|
+}
|
5073 |
|
|
+
|
5074 |
|
|
+/*-----------------------------------------------------------------*/
|
5075 |
|
|
+/* genUminusFloat - unary minus for floating points */
|
5076 |
|
|
+/*-----------------------------------------------------------------*/
|
5077 |
|
|
+static void
|
5078 |
|
|
+genUminusFloat (operand * op, operand * result)
|
5079 |
|
|
+{
|
5080 |
|
|
+
|
5081 |
|
|
+}
|
5082 |
|
|
+
|
5083 |
|
|
+/*-----------------------------------------------------------------*/
|
5084 |
|
|
+/* genUminus - unary minus code generation */
|
5085 |
|
|
+/*-----------------------------------------------------------------*/
|
5086 |
|
|
+static void
|
5087 |
|
|
+genUminus (iCode * ic)
|
5088 |
|
|
+{
|
5089 |
|
|
+
|
5090 |
|
|
+}
|
5091 |
|
|
+
|
5092 |
|
|
+/*-----------------------------------------------------------------*/
|
5093 |
|
|
+/* genIpush - genrate code for pushing this gets a little complex */
|
5094 |
|
|
+/*-----------------------------------------------------------------*/
|
5095 |
|
|
+static void
|
5096 |
|
|
+genIpush (iCode * ic)
|
5097 |
|
|
+{
|
5098 |
|
|
+
|
5099 |
|
|
+}
|
5100 |
|
|
+
|
5101 |
|
|
+/*-----------------------------------------------------------------*/
|
5102 |
|
|
+/* genIpop - recover the registers: can happen only for spilling */
|
5103 |
|
|
+/*-----------------------------------------------------------------*/
|
5104 |
|
|
+static void
|
5105 |
|
|
+genIpop (iCode * ic)
|
5106 |
|
|
+{
|
5107 |
|
|
+
|
5108 |
|
|
+}
|
5109 |
|
|
+
|
5110 |
|
|
+/*-----------------------------------------------------------------*/
|
5111 |
|
|
+/* genCall - generates a call statement */
|
5112 |
|
|
+/*-----------------------------------------------------------------*/
|
5113 |
|
|
+static void
|
5114 |
|
|
+genCall (iCode * ic)
|
5115 |
|
|
+{
|
5116 |
|
|
+
|
5117 |
|
|
+
|
5118 |
|
|
+}
|
5119 |
|
|
+
|
5120 |
|
|
+/*-----------------------------------------------------------------*/
|
5121 |
|
|
+/* genPcall - generates a call by pointer statement */
|
5122 |
|
|
+/*-----------------------------------------------------------------*/
|
5123 |
|
|
+static void
|
5124 |
|
|
+genPcall (iCode * ic)
|
5125 |
|
|
+{
|
5126 |
|
|
+
|
5127 |
|
|
+}
|
5128 |
|
|
+
|
5129 |
|
|
+
|
5130 |
|
|
+/*-----------------------------------------------------------------*/
|
5131 |
|
|
+/* genFunction - generated code for function entry */
|
5132 |
|
|
+/*-----------------------------------------------------------------*/
|
5133 |
|
|
+static void
|
5134 |
|
|
+genFunction (iCode * ic)
|
5135 |
|
|
+{
|
5136 |
|
|
+
|
5137 |
|
|
+}
|
5138 |
|
|
+
|
5139 |
|
|
+/*-----------------------------------------------------------------*/
|
5140 |
|
|
+/* genEndFunction - generates epilogue for functions */
|
5141 |
|
|
+/*-----------------------------------------------------------------*/
|
5142 |
|
|
+static void
|
5143 |
|
|
+genEndFunction (iCode * ic)
|
5144 |
|
|
+{
|
5145 |
|
|
+
|
5146 |
|
|
+
|
5147 |
|
|
+}
|
5148 |
|
|
+
|
5149 |
|
|
+/*-----------------------------------------------------------------*/
|
5150 |
|
|
+/* genRet - generate code for return statement */
|
5151 |
|
|
+/*-----------------------------------------------------------------*/
|
5152 |
|
|
+static void
|
5153 |
|
|
+genRet (iCode * ic)
|
5154 |
|
|
+{
|
5155 |
|
|
+
|
5156 |
|
|
+}
|
5157 |
|
|
+
|
5158 |
|
|
+/*-----------------------------------------------------------------*/
|
5159 |
|
|
+/* genLabel - generates a label */
|
5160 |
|
|
+/*-----------------------------------------------------------------*/
|
5161 |
|
|
+static void
|
5162 |
|
|
+genLabel (iCode * ic)
|
5163 |
|
|
+{
|
5164 |
|
|
+ /* special case never generate */
|
5165 |
|
|
+ if (IC_LABEL (ic) == entryLabel)
|
5166 |
|
|
+ return;
|
5167 |
|
|
+
|
5168 |
|
|
+ emitcode ("", "L%05d:", IC_LABEL (ic)->key);
|
5169 |
|
|
+}
|
5170 |
|
|
+
|
5171 |
|
|
+/*-----------------------------------------------------------------*/
|
5172 |
|
|
+/* genGoto - generates a ljmp */
|
5173 |
|
|
+/*-----------------------------------------------------------------*/
|
5174 |
|
|
+static void
|
5175 |
|
|
+genGoto (iCode * ic)
|
5176 |
|
|
+{
|
5177 |
|
|
+
|
5178 |
|
|
+}
|
5179 |
|
|
+
|
5180 |
|
|
+/*-----------------------------------------------------------------*/
|
5181 |
|
|
+/* genPlusIncr :- does addition with increment if possible */
|
5182 |
|
|
+/*-----------------------------------------------------------------*/
|
5183 |
|
|
+static bool
|
5184 |
|
|
+genPlusIncr (iCode * ic)
|
5185 |
|
|
+{
|
5186 |
|
|
+return FALSE;
|
5187 |
|
|
+}
|
5188 |
|
|
+
|
5189 |
|
|
+
|
5190 |
|
|
+/*-----------------------------------------------------------------*/
|
5191 |
|
|
+/* genPlus - generates code for addition */
|
5192 |
|
|
+/*-----------------------------------------------------------------*/
|
5193 |
|
|
+static void
|
5194 |
|
|
+genPlus (iCode * ic)
|
5195 |
|
|
+{
|
5196 |
|
|
+
|
5197 |
|
|
+
|
5198 |
|
|
+ emitcode ("add", "%d, %d",4,5 );
|
5199 |
|
|
+}
|
5200 |
|
|
+
|
5201 |
|
|
+/*-----------------------------------------------------------------*/
|
5202 |
|
|
+/* genMinusDec :- does subtraction with deccrement if possible */
|
5203 |
|
|
+/*-----------------------------------------------------------------*/
|
5204 |
|
|
+static bool
|
5205 |
|
|
+genMinusDec (iCode * ic)
|
5206 |
|
|
+{
|
5207 |
|
|
+
|
5208 |
|
|
+return FALSE;
|
5209 |
|
|
+}
|
5210 |
|
|
+
|
5211 |
|
|
+/*-----------------------------------------------------------------*/
|
5212 |
|
|
+/* genMinus - generates code for subtraction */
|
5213 |
|
|
+/*-----------------------------------------------------------------*/
|
5214 |
|
|
+static void
|
5215 |
|
|
+genMinus (iCode * ic)
|
5216 |
|
|
+{
|
5217 |
|
|
+
|
5218 |
|
|
+}
|
5219 |
|
|
+
|
5220 |
|
|
+/*-----------------------------------------------------------------*/
|
5221 |
|
|
+/* genMultOneByte : 8 bit multiplication & division */
|
5222 |
|
|
+/*-----------------------------------------------------------------*/
|
5223 |
|
|
+static void
|
5224 |
|
|
+genMultOneByte (operand * left, operand * right, operand * result)
|
5225 |
|
|
+{
|
5226 |
|
|
+
|
5227 |
|
|
+}
|
5228 |
|
|
+
|
5229 |
|
|
+/*-----------------------------------------------------------------*/
|
5230 |
|
|
+/* genMult - generates code for multiplication */
|
5231 |
|
|
+/*-----------------------------------------------------------------*/
|
5232 |
|
|
+static void
|
5233 |
|
|
+genMult (iCode * ic)
|
5234 |
|
|
+{
|
5235 |
|
|
+
|
5236 |
|
|
+}
|
5237 |
|
|
+
|
5238 |
|
|
+/*-----------------------------------------------------------------*/
|
5239 |
|
|
+/* genDiv - generates code for division */
|
5240 |
|
|
+/*-----------------------------------------------------------------*/
|
5241 |
|
|
+static void
|
5242 |
|
|
+genDiv (iCode * ic)
|
5243 |
|
|
+{
|
5244 |
|
|
+ /* should have been converted to function call */
|
5245 |
|
|
+ assert (0);
|
5246 |
|
|
+}
|
5247 |
|
|
+
|
5248 |
|
|
+/*-----------------------------------------------------------------*/
|
5249 |
|
|
+/* genMod - generates code for division */
|
5250 |
|
|
+/*-----------------------------------------------------------------*/
|
5251 |
|
|
+static void
|
5252 |
|
|
+genMod (iCode * ic)
|
5253 |
|
|
+{
|
5254 |
|
|
+ /* should have been converted to function call */
|
5255 |
|
|
+ assert (0);
|
5256 |
|
|
+
|
5257 |
|
|
+}
|
5258 |
|
|
+
|
5259 |
|
|
+enum {
|
5260 |
|
|
+ PBLAZE_EQ = 0,
|
5261 |
|
|
+ PBLAZE_NE,
|
5262 |
|
|
+ PBLAZE_LT,
|
5263 |
|
|
+ PBLAZE_GE
|
5264 |
|
|
+};
|
5265 |
|
|
+
|
5266 |
|
|
+/*-----------------------------------------------------------------*/
|
5267 |
|
|
+/* revpblazecnd - reverse a conditional for pblaze */
|
5268 |
|
|
+/*-----------------------------------------------------------------*/
|
5269 |
|
|
+static int
|
5270 |
|
|
+revpblazecnd (int type)
|
5271 |
|
|
+{
|
5272 |
|
|
+ static struct {
|
5273 |
|
|
+ int type, rtype;
|
5274 |
|
|
+ } rar[] = {
|
5275 |
|
|
+ {
|
5276 |
|
|
+ PBLAZE_EQ, PBLAZE_NE}
|
5277 |
|
|
+ , {
|
5278 |
|
|
+ PBLAZE_LT, PBLAZE_GE}
|
5279 |
|
|
+ };
|
5280 |
|
|
+ int i;
|
5281 |
|
|
+
|
5282 |
|
|
+ for (i = 0; i < (sizeof (rar) / sizeof (rar[0])); i++) {
|
5283 |
|
|
+ if (rar[i].type == type)
|
5284 |
|
|
+ return rar[i].rtype;
|
5285 |
|
|
+ if (rar[i].rtype == type)
|
5286 |
|
|
+ return rar[i].type;
|
5287 |
|
|
+ }
|
5288 |
|
|
+ assert (0); /* cannot happen */
|
5289 |
|
|
+ return 0; /* makes the compiler happy */
|
5290 |
|
|
+}
|
5291 |
|
|
+
|
5292 |
|
|
+
|
5293 |
|
|
+/*-----------------------------------------------------------------*/
|
5294 |
|
|
+/* genBranch - generate the branch instruction */
|
5295 |
|
|
+/*-----------------------------------------------------------------*/
|
5296 |
|
|
+static void
|
5297 |
|
|
+genBranch (iCode * ifx, int br_type, int sign)
|
5298 |
|
|
+{
|
5299 |
|
|
+
|
5300 |
|
|
+}
|
5301 |
|
|
+
|
5302 |
|
|
+/*-----------------------------------------------------------------*/
|
5303 |
|
|
+/* genCmp - compare & jump */
|
5304 |
|
|
+/*-----------------------------------------------------------------*/
|
5305 |
|
|
+static void
|
5306 |
|
|
+genCmp (iCode * ic, iCode * ifx, int br_type)
|
5307 |
|
|
+{
|
5308 |
|
|
+
|
5309 |
|
|
+}
|
5310 |
|
|
+
|
5311 |
|
|
+/*-----------------------------------------------------------------*/
|
5312 |
|
|
+/* genCmpGt :- greater than comparison */
|
5313 |
|
|
+/*-----------------------------------------------------------------*/
|
5314 |
|
|
+static void
|
5315 |
|
|
+genCmpGt (iCode * ic, iCode * ifx)
|
5316 |
|
|
+{
|
5317 |
|
|
+
|
5318 |
|
|
+}
|
5319 |
|
|
+
|
5320 |
|
|
+/*-----------------------------------------------------------------*/
|
5321 |
|
|
+/* genCmpLt - less than comparisons */
|
5322 |
|
|
+/*-----------------------------------------------------------------*/
|
5323 |
|
|
+static void
|
5324 |
|
|
+genCmpLt (iCode * ic, iCode * ifx)
|
5325 |
|
|
+{
|
5326 |
|
|
+
|
5327 |
|
|
+}
|
5328 |
|
|
+
|
5329 |
|
|
+/*-----------------------------------------------------------------*/
|
5330 |
|
|
+/* genCmpEq - generates code for equal to */
|
5331 |
|
|
+/*-----------------------------------------------------------------*/
|
5332 |
|
|
+static void
|
5333 |
|
|
+genCmpEq (iCode * ic, iCode * ifx)
|
5334 |
|
|
+{
|
5335 |
|
|
+
|
5336 |
|
|
+}
|
5337 |
|
|
+
|
5338 |
|
|
+/*-----------------------------------------------------------------*/
|
5339 |
|
|
+/* genCmpNe - generates code for not equal to */
|
5340 |
|
|
+/*-----------------------------------------------------------------*/
|
5341 |
|
|
+static void
|
5342 |
|
|
+genCmpNe (iCode * ic, iCode * ifx)
|
5343 |
|
|
+{
|
5344 |
|
|
+
|
5345 |
|
|
+}
|
5346 |
|
|
+
|
5347 |
|
|
+/*-----------------------------------------------------------------*/
|
5348 |
|
|
+/* genCmpGe - generates code for greater than equal to */
|
5349 |
|
|
+/*-----------------------------------------------------------------*/
|
5350 |
|
|
+static void
|
5351 |
|
|
+genCmpGe (iCode * ic, iCode * ifx)
|
5352 |
|
|
+{
|
5353 |
|
|
+
|
5354 |
|
|
+}
|
5355 |
|
|
+
|
5356 |
|
|
+/*-----------------------------------------------------------------*/
|
5357 |
|
|
+/* genCmpLe - generates code for less than equal to */
|
5358 |
|
|
+/*-----------------------------------------------------------------*/
|
5359 |
|
|
+static void
|
5360 |
|
|
+genCmpLe (iCode * ic, iCode * ifx)
|
5361 |
|
|
+{
|
5362 |
|
|
+
|
5363 |
|
|
+}
|
5364 |
|
|
+
|
5365 |
|
|
+/*-----------------------------------------------------------------*/
|
5366 |
|
|
+/* ifxForOp - returns the icode containing the ifx for operand */
|
5367 |
|
|
+/*-----------------------------------------------------------------*/
|
5368 |
|
|
+static iCode *
|
5369 |
|
|
+ifxForOp (operand * op, iCode * ic)
|
5370 |
|
|
+{
|
5371 |
|
|
+ /* if true symbol then needs to be assigned */
|
5372 |
|
|
+ if (IS_TRUE_SYMOP (op))
|
5373 |
|
|
+ return NULL;
|
5374 |
|
|
+
|
5375 |
|
|
+ /* if this has register type condition and
|
5376 |
|
|
+ the next instruction is ifx with the same operand
|
5377 |
|
|
+ and live to of the operand is upto the ifx only then */
|
5378 |
|
|
+ if (ic->next &&
|
5379 |
|
|
+ ic->next->op == IFX &&
|
5380 |
|
|
+ IC_COND (ic->next)->key == op->key &&
|
5381 |
|
|
+ OP_SYMBOL (op)->liveTo <= ic->next->seq) return ic->next;
|
5382 |
|
|
+
|
5383 |
|
|
+ return NULL;
|
5384 |
|
|
+}
|
5385 |
|
|
+
|
5386 |
|
|
+/*-----------------------------------------------------------------*/
|
5387 |
|
|
+/* genAndOp - for && operation */
|
5388 |
|
|
+/*-----------------------------------------------------------------*/
|
5389 |
|
|
+static void
|
5390 |
|
|
+genAndOp (iCode * ic)
|
5391 |
|
|
+{
|
5392 |
|
|
+
|
5393 |
|
|
+}
|
5394 |
|
|
+
|
5395 |
|
|
+
|
5396 |
|
|
+/*-----------------------------------------------------------------*/
|
5397 |
|
|
+/* genOrOp - for || operation */
|
5398 |
|
|
+/*-----------------------------------------------------------------*/
|
5399 |
|
|
+static void
|
5400 |
|
|
+genOrOp (iCode * ic)
|
5401 |
|
|
+{
|
5402 |
|
|
+
|
5403 |
|
|
+}
|
5404 |
|
|
+
|
5405 |
|
|
+/*-----------------------------------------------------------------*/
|
5406 |
|
|
+/* genBitWise - generate bitwise operations */
|
5407 |
|
|
+/*-----------------------------------------------------------------*/
|
5408 |
|
|
+static void
|
5409 |
|
|
+genBitWise (iCode * ic, iCode * ifx, int bitop)
|
5410 |
|
|
+{
|
5411 |
|
|
+
|
5412 |
|
|
+}
|
5413 |
|
|
+
|
5414 |
|
|
+/*-----------------------------------------------------------------*/
|
5415 |
|
|
+/* genAnd - code for and */
|
5416 |
|
|
+/*-----------------------------------------------------------------*/
|
5417 |
|
|
+static void
|
5418 |
|
|
+genAnd (iCode * ic, iCode * ifx)
|
5419 |
|
|
+{
|
5420 |
|
|
+
|
5421 |
|
|
+}
|
5422 |
|
|
+
|
5423 |
|
|
+/*-----------------------------------------------------------------*/
|
5424 |
|
|
+/* genOr - code for or */
|
5425 |
|
|
+/*-----------------------------------------------------------------*/
|
5426 |
|
|
+static void
|
5427 |
|
|
+genOr (iCode * ic, iCode * ifx)
|
5428 |
|
|
+{
|
5429 |
|
|
+
|
5430 |
|
|
+}
|
5431 |
|
|
+
|
5432 |
|
|
+/*-----------------------------------------------------------------*/
|
5433 |
|
|
+/* genXor - code for xclusive or */
|
5434 |
|
|
+/*-----------------------------------------------------------------*/
|
5435 |
|
|
+static void
|
5436 |
|
|
+genXor (iCode * ic, iCode * ifx)
|
5437 |
|
|
+{
|
5438 |
|
|
+
|
5439 |
|
|
+}
|
5440 |
|
|
+
|
5441 |
|
|
+/*-----------------------------------------------------------------*/
|
5442 |
|
|
+/* genInline - write the inline code out */
|
5443 |
|
|
+/*-----------------------------------------------------------------*/
|
5444 |
|
|
+static void
|
5445 |
|
|
+genInline (iCode * ic)
|
5446 |
|
|
+{
|
5447 |
|
|
+
|
5448 |
|
|
+}
|
5449 |
|
|
+
|
5450 |
|
|
+/*-----------------------------------------------------------------*/
|
5451 |
|
|
+/* genRotC - rotate right/left with carry , lr = 1 rotate right */
|
5452 |
|
|
+/*-----------------------------------------------------------------*/
|
5453 |
|
|
+static void
|
5454 |
|
|
+genRotC (iCode * ic, int lr)
|
5455 |
|
|
+{
|
5456 |
|
|
+
|
5457 |
|
|
+}
|
5458 |
|
|
+
|
5459 |
|
|
+/*-----------------------------------------------------------------*/
|
5460 |
|
|
+/* genRRC - rotate right with carry */
|
5461 |
|
|
+/*-----------------------------------------------------------------*/
|
5462 |
|
|
+static void
|
5463 |
|
|
+genRRC (iCode * ic)
|
5464 |
|
|
+{
|
5465 |
|
|
+
|
5466 |
|
|
+}
|
5467 |
|
|
+
|
5468 |
|
|
+/*-----------------------------------------------------------------*/
|
5469 |
|
|
+/* genRLC - generate code for rotate left with carry */
|
5470 |
|
|
+/*-----------------------------------------------------------------*/
|
5471 |
|
|
+static void
|
5472 |
|
|
+genRLC (iCode * ic)
|
5473 |
|
|
+{
|
5474 |
|
|
+
|
5475 |
|
|
+}
|
5476 |
|
|
+
|
5477 |
|
|
+/*-----------------------------------------------------------------*/
|
5478 |
|
|
+/* genGetHbit - generates code get highest order bit */
|
5479 |
|
|
+/*-----------------------------------------------------------------*/
|
5480 |
|
|
+static void
|
5481 |
|
|
+genGetHbit (iCode * ic)
|
5482 |
|
|
+{
|
5483 |
|
|
+
|
5484 |
|
|
+}
|
5485 |
|
|
+
|
5486 |
|
|
+/*-----------------------------------------------------------------*/
|
5487 |
|
|
+/* genShiftLeftLit - shift left by a known amount */
|
5488 |
|
|
+/*-----------------------------------------------------------------*/
|
5489 |
|
|
+static void
|
5490 |
|
|
+genShiftLeftLit (iCode * ic)
|
5491 |
|
|
+{
|
5492 |
|
|
+
|
5493 |
|
|
+}
|
5494 |
|
|
+
|
5495 |
|
|
+/*-----------------------------------------------------------------*/
|
5496 |
|
|
+/* genLeftShift - generates code for left shifting */
|
5497 |
|
|
+/*-----------------------------------------------------------------*/
|
5498 |
|
|
+static void
|
5499 |
|
|
+genLeftShift (iCode * ic)
|
5500 |
|
|
+{
|
5501 |
|
|
+
|
5502 |
|
|
+}
|
5503 |
|
|
+
|
5504 |
|
|
+/*-----------------------------------------------------------------*/
|
5505 |
|
|
+/* genShiftRightLit - generate for right shift with known count */
|
5506 |
|
|
+/*-----------------------------------------------------------------*/
|
5507 |
|
|
+static void
|
5508 |
|
|
+genShiftRightLit (iCode * ic)
|
5509 |
|
|
+{
|
5510 |
|
|
+
|
5511 |
|
|
+}
|
5512 |
|
|
+
|
5513 |
|
|
+/*-----------------------------------------------------------------*/
|
5514 |
|
|
+/* genRightShift - generate code for right shifting */
|
5515 |
|
|
+/*-----------------------------------------------------------------*/
|
5516 |
|
|
+static void
|
5517 |
|
|
+genRightShift (iCode * ic)
|
5518 |
|
|
+{
|
5519 |
|
|
+
|
5520 |
|
|
+}
|
5521 |
|
|
+
|
5522 |
|
|
+/*-----------------------------------------------------------------*/
|
5523 |
|
|
+/* RRsh - shift right rn by known count */
|
5524 |
|
|
+/*-----------------------------------------------------------------*/
|
5525 |
|
|
+static void
|
5526 |
|
|
+RRsh (int shCount,int reg)
|
5527 |
|
|
+{
|
5528 |
|
|
+
|
5529 |
|
|
+}
|
5530 |
|
|
+
|
5531 |
|
|
+/*-----------------------------------------------------------------*/
|
5532 |
|
|
+/* RLsh - shift left rn by known count */
|
5533 |
|
|
+/*-----------------------------------------------------------------*/
|
5534 |
|
|
+static void
|
5535 |
|
|
+RLsh (int shCount, int reg)
|
5536 |
|
|
+{
|
5537 |
|
|
+
|
5538 |
|
|
+}
|
5539 |
|
|
+
|
5540 |
|
|
+/*-----------------------------------------------------------------*/
|
5541 |
|
|
+/* genUnpackBits - generates code for unpacking bits */
|
5542 |
|
|
+/*-----------------------------------------------------------------*/
|
5543 |
|
|
+static void
|
5544 |
|
|
+genUnpackBits (operand * result, char *rname, int ptype)
|
5545 |
|
|
+{
|
5546 |
|
|
+
|
5547 |
|
|
+}
|
5548 |
|
|
+
|
5549 |
|
|
+/*-----------------------------------------------------------------*/
|
5550 |
|
|
+/* genDataPointerGet - generates code when ptr offset is known */
|
5551 |
|
|
+/*-----------------------------------------------------------------*/
|
5552 |
|
|
+static void
|
5553 |
|
|
+genDataPointerGet (operand * left, operand * result, iCode * ic)
|
5554 |
|
|
+{
|
5555 |
|
|
+
|
5556 |
|
|
+}
|
5557 |
|
|
+
|
5558 |
|
|
+/*-----------------------------------------------------------------*/
|
5559 |
|
|
+/* genNearPointerGet - emitcode for near pointer fetch */
|
5560 |
|
|
+/*-----------------------------------------------------------------*/
|
5561 |
|
|
+static void
|
5562 |
|
|
+genMemPointerGet (operand * left, operand * result, iCode * ic, iCode *pi)
|
5563 |
|
|
+{
|
5564 |
|
|
+
|
5565 |
|
|
+}
|
5566 |
|
|
+
|
5567 |
|
|
+/*-----------------------------------------------------------------*/
|
5568 |
|
|
+/* genCodePointerGet - gget value from code space */
|
5569 |
|
|
+/*-----------------------------------------------------------------*/
|
5570 |
|
|
+static void
|
5571 |
|
|
+genCodePointerGet (operand * left, operand * result, iCode * ic, iCode *pi)
|
5572 |
|
|
+{
|
5573 |
|
|
+
|
5574 |
|
|
+
|
5575 |
|
|
+}
|
5576 |
|
|
+
|
5577 |
|
|
+/*-----------------------------------------------------------------*/
|
5578 |
|
|
+/* genPointerGet - generate code for pointer get */
|
5579 |
|
|
+/*-----------------------------------------------------------------*/
|
5580 |
|
|
+static void
|
5581 |
|
|
+genPointerGet (iCode * ic, iCode *pi)
|
5582 |
|
|
+{
|
5583 |
|
|
+
|
5584 |
|
|
+}
|
5585 |
|
|
+
|
5586 |
|
|
+/*-----------------------------------------------------------------*/
|
5587 |
|
|
+/* genPackBits - generates code for packed bit storage */
|
5588 |
|
|
+/*-----------------------------------------------------------------*/
|
5589 |
|
|
+static void
|
5590 |
|
|
+genPackBits (sym_link * etype,
|
5591 |
|
|
+ operand * right,
|
5592 |
|
|
+ char *rname, int p_type)
|
5593 |
|
|
+{
|
5594 |
|
|
+
|
5595 |
|
|
+}
|
5596 |
|
|
+
|
5597 |
|
|
+/*-----------------------------------------------------------------*/
|
5598 |
|
|
+/* genDataPointerSet - remat pointer to data space */
|
5599 |
|
|
+/*-----------------------------------------------------------------*/
|
5600 |
|
|
+static void
|
5601 |
|
|
+genDataPointerSet (operand * right, operand * result, iCode * ic)
|
5602 |
|
|
+{
|
5603 |
|
|
+
|
5604 |
|
|
+}
|
5605 |
|
|
+
|
5606 |
|
|
+/*-----------------------------------------------------------------*/
|
5607 |
|
|
+/* genNearPointerSet - emitcode for near pointer put */
|
5608 |
|
|
+/*-----------------------------------------------------------------*/
|
5609 |
|
|
+static void
|
5610 |
|
|
+genMemPointerSet (operand * right, operand * result, iCode * ic, iCode *pi)
|
5611 |
|
|
+{
|
5612 |
|
|
+
|
5613 |
|
|
+}
|
5614 |
|
|
+
|
5615 |
|
|
+/*-----------------------------------------------------------------*/
|
5616 |
|
|
+/* genGenPointerSet - set value from generic pointer space */
|
5617 |
|
|
+/*-----------------------------------------------------------------*/
|
5618 |
|
|
+static void
|
5619 |
|
|
+genGenPointerSet (operand * right, operand * result, iCode * ic, iCode *pi)
|
5620 |
|
|
+{
|
5621 |
|
|
+
|
5622 |
|
|
+}
|
5623 |
|
|
+
|
5624 |
|
|
+/*-----------------------------------------------------------------*/
|
5625 |
|
|
+/* genPointerSet - stores the value into a pointer location */
|
5626 |
|
|
+/*-----------------------------------------------------------------*/
|
5627 |
|
|
+static void
|
5628 |
|
|
+genPointerSet (iCode * ic, iCode *pi)
|
5629 |
|
|
+{
|
5630 |
|
|
+
|
5631 |
|
|
+}
|
5632 |
|
|
+
|
5633 |
|
|
+/*-----------------------------------------------------------------*/
|
5634 |
|
|
+/* genIfx - generate code for Ifx statement */
|
5635 |
|
|
+/*-----------------------------------------------------------------*/
|
5636 |
|
|
+static void
|
5637 |
|
|
+genIfx (iCode * ic, iCode * popIc)
|
5638 |
|
|
+{
|
5639 |
|
|
+
|
5640 |
|
|
+}
|
5641 |
|
|
+
|
5642 |
|
|
+/*-----------------------------------------------------------------*/
|
5643 |
|
|
+/* genAddrOf - generates code for address of */
|
5644 |
|
|
+/*-----------------------------------------------------------------*/
|
5645 |
|
|
+static void
|
5646 |
|
|
+genAddrOf (iCode * ic)
|
5647 |
|
|
+{
|
5648 |
|
|
+
|
5649 |
|
|
+}
|
5650 |
|
|
+
|
5651 |
|
|
+/*-----------------------------------------------------------------*/
|
5652 |
|
|
+/* genFarFarAssign - assignment when both are in far space */
|
5653 |
|
|
+/*-----------------------------------------------------------------*/
|
5654 |
|
|
+static void
|
5655 |
|
|
+genFarFarAssign (operand * result, operand * right, iCode * ic)
|
5656 |
|
|
+{
|
5657 |
|
|
+
|
5658 |
|
|
+
|
5659 |
|
|
+}
|
5660 |
|
|
+
|
5661 |
|
|
+/*-----------------------------------------------------------------*/
|
5662 |
|
|
+/* genAssign - generate code for assignment */
|
5663 |
|
|
+/*-----------------------------------------------------------------*/
|
5664 |
|
|
+static void
|
5665 |
|
|
+genAssign (iCode * ic)
|
5666 |
|
|
+{
|
5667 |
|
|
+ operand *result, *right;
|
5668 |
|
|
+ int size, offset;
|
5669 |
|
|
+ unsigned long lit = 0L;
|
5670 |
|
|
+ int i;
|
5671 |
|
|
+
|
5672 |
|
|
+ D(emitcode (";", "genAssign"));
|
5673 |
|
|
+
|
5674 |
|
|
+ result = IC_RESULT (ic);
|
5675 |
|
|
+ right = IC_RIGHT (ic);
|
5676 |
|
|
+
|
5677 |
|
|
+
|
5678 |
|
|
+ // TODO: all options
|
5679 |
|
|
+ /* right side is a literal value */
|
5680 |
|
|
+ if (IS_OP_LITERAL (right)) {
|
5681 |
|
|
+ value *aop_lit;
|
5682 |
|
|
+
|
5683 |
|
|
+ aop_lit = right->operand.valOperand;
|
5684 |
|
|
+
|
5685 |
|
|
+ /* get value and size */
|
5686 |
|
|
+ lit = ulFromVal (aop_lit);
|
5687 |
|
|
+ size = getSize ( operandType (right) );
|
5688 |
|
|
+
|
5689 |
|
|
+
|
5690 |
|
|
+ /* left side is a symbol - register */
|
5691 |
|
|
+ if( OP_SYMBOL(result) ) {
|
5692 |
|
|
+
|
5693 |
|
|
+ OP_SYMBOL(result)->nRegs = size;
|
5694 |
|
|
+
|
5695 |
|
|
+ /* assign registers */
|
5696 |
|
|
+ assignReg (result);
|
5697 |
|
|
+
|
5698 |
|
|
+
|
5699 |
|
|
+ for(i = 0; i<size; i++) {
|
5700 |
|
|
+ emitcode ("load", "%s, %02x", OP_SYMBOL(result)->regs[i]->name , (unsigned int) ((lit >> (i * 8)) & 0x0FFL) );
|
5701 |
|
|
+
|
5702 |
|
|
+ }
|
5703 |
|
|
+
|
5704 |
|
|
+
|
5705 |
|
|
+ }
|
5706 |
|
|
+
|
5707 |
|
|
+ // printf("ic:%d\tsize:%d\n",ic->key,size);
|
5708 |
|
|
+
|
5709 |
|
|
+
|
5710 |
|
|
+
|
5711 |
|
|
+ }
|
5712 |
|
|
+
|
5713 |
|
|
+}
|
5714 |
|
|
+
|
5715 |
|
|
+/*-----------------------------------------------------------------*/
|
5716 |
|
|
+/* genJumpTab - genrates code for jump table */
|
5717 |
|
|
+/*-----------------------------------------------------------------*/
|
5718 |
|
|
+static void
|
5719 |
|
|
+genJumpTab (iCode * ic)
|
5720 |
|
|
+{
|
5721 |
|
|
+
|
5722 |
|
|
+
|
5723 |
|
|
+}
|
5724 |
|
|
+
|
5725 |
|
|
+/*-----------------------------------------------------------------*/
|
5726 |
|
|
+/* genCast - gen code for casting */
|
5727 |
|
|
+/*-----------------------------------------------------------------*/
|
5728 |
|
|
+static void
|
5729 |
|
|
+genCast (iCode * ic)
|
5730 |
|
|
+{
|
5731 |
|
|
+
|
5732 |
|
|
+
|
5733 |
|
|
+}
|
5734 |
|
|
+
|
5735 |
|
|
+/*-----------------------------------------------------------------*/
|
5736 |
|
|
+/* genReceive - generate code for a receive iCode */
|
5737 |
|
|
+/*-----------------------------------------------------------------*/
|
5738 |
|
|
+static void
|
5739 |
|
|
+genReceive (iCode * ic)
|
5740 |
|
|
+{
|
5741 |
|
|
+
|
5742 |
|
|
+}
|
5743 |
|
|
+
|
5744 |
|
|
+/*-----------------------------------------------------------------*/
|
5745 |
|
|
+/* genDummyRead - generate code for dummy read of volatiles */
|
5746 |
|
|
+/*-----------------------------------------------------------------*/
|
5747 |
|
|
+static void
|
5748 |
|
|
+genDummyRead (iCode * ic)
|
5749 |
|
|
+{
|
5750 |
|
|
+ emitcode ("; genDummyRead","");
|
5751 |
|
|
+ emitcode ("; not implemented","");
|
5752 |
|
|
+
|
5753 |
|
|
+ ic = ic;
|
5754 |
|
|
+}
|
5755 |
|
|
+
|
5756 |
|
|
+/*-----------------------------------------------------------------*/
|
5757 |
|
|
+/* gen51Code - generate code for 8051 based controllers */
|
5758 |
|
|
+/*-----------------------------------------------------------------*/
|
5759 |
|
|
+void
|
5760 |
|
|
+genJSONCode (iCode * lic)
|
5761 |
|
|
+{
|
5762 |
|
|
+ iCode *ic;
|
5763 |
|
|
+ int cln = 0;
|
5764 |
|
|
+
|
5765 |
|
|
+
|
5766 |
|
|
+ for (ic = lic; ic; ic = ic->next) {
|
5767 |
|
|
+
|
5768 |
|
|
+ if( IS_ARITHMETIC_OP(ic) ) {
|
5769 |
|
|
+
|
5770 |
|
|
+ operand *left = IC_LEFT (ic);
|
5771 |
|
|
+ if( OP_SYMBOL(left) ) {
|
5772 |
|
|
+ printf("name:%s\n", left->operand.symOperand->rname );
|
5773 |
|
|
+ }
|
5774 |
|
|
+
|
5775 |
|
|
+ }
|
5776 |
|
|
+ // printf("oper:%d\n", ic->op);
|
5777 |
|
|
+
|
5778 |
|
|
+ if (cln != ic->lineno) {
|
5779 |
|
|
+ if (options.debug) {
|
5780 |
|
|
+ debugFile->writeCLine (ic);
|
5781 |
|
|
+ }
|
5782 |
|
|
+ emitcode (";", "%s %d", ic->filename, ic->lineno);
|
5783 |
|
|
+ cln = ic->lineno;
|
5784 |
|
|
+ }
|
5785 |
|
|
+
|
5786 |
|
|
+ /* depending on the operation */
|
5787 |
|
|
+ switch (ic->op) {
|
5788 |
|
|
+ case '!':
|
5789 |
|
|
+ genNot (ic);
|
5790 |
|
|
+ break;
|
5791 |
|
|
+
|
5792 |
|
|
+ case '~':
|
5793 |
|
|
+ genCpl (ic);
|
5794 |
|
|
+ break;
|
5795 |
|
|
+
|
5796 |
|
|
+ case UNARYMINUS:
|
5797 |
|
|
+ genUminus (ic);
|
5798 |
|
|
+ break;
|
5799 |
|
|
+
|
5800 |
|
|
+ case IPUSH:
|
5801 |
|
|
+ genIpush (ic);
|
5802 |
|
|
+ break;
|
5803 |
|
|
+
|
5804 |
|
|
+ case IPOP:
|
5805 |
|
|
+ genIpop (ic);
|
5806 |
|
|
+ break;
|
5807 |
|
|
+
|
5808 |
|
|
+ case CALL:
|
5809 |
|
|
+ genCall (ic);
|
5810 |
|
|
+ break;
|
5811 |
|
|
+
|
5812 |
|
|
+ case PCALL:
|
5813 |
|
|
+ genPcall (ic);
|
5814 |
|
|
+ break;
|
5815 |
|
|
+
|
5816 |
|
|
+ case FUNCTION:
|
5817 |
|
|
+ genFunction (ic);
|
5818 |
|
|
+ break;
|
5819 |
|
|
+
|
5820 |
|
|
+ case ENDFUNCTION:
|
5821 |
|
|
+ genEndFunction (ic);
|
5822 |
|
|
+ break;
|
5823 |
|
|
+
|
5824 |
|
|
+ case RETURN:
|
5825 |
|
|
+ genRet (ic);
|
5826 |
|
|
+ break;
|
5827 |
|
|
+
|
5828 |
|
|
+ case LABEL:
|
5829 |
|
|
+ genLabel (ic);
|
5830 |
|
|
+ break;
|
5831 |
|
|
+
|
5832 |
|
|
+ case GOTO:
|
5833 |
|
|
+ genGoto (ic);
|
5834 |
|
|
+ break;
|
5835 |
|
|
+
|
5836 |
|
|
+ case '+':
|
5837 |
|
|
+ genPlus (ic);
|
5838 |
|
|
+ break;
|
5839 |
|
|
+
|
5840 |
|
|
+ case '-':
|
5841 |
|
|
+ genMinus (ic);
|
5842 |
|
|
+ break;
|
5843 |
|
|
+
|
5844 |
|
|
+ case '*':
|
5845 |
|
|
+ genMult (ic);
|
5846 |
|
|
+ break;
|
5847 |
|
|
+
|
5848 |
|
|
+ case '/':
|
5849 |
|
|
+ genDiv (ic);
|
5850 |
|
|
+ break;
|
5851 |
|
|
+
|
5852 |
|
|
+ case '%':
|
5853 |
|
|
+ genMod (ic);
|
5854 |
|
|
+ break;
|
5855 |
|
|
+
|
5856 |
|
|
+ case '>':
|
5857 |
|
|
+ genCmpGt (ic, ifxForOp (IC_RESULT (ic), ic));
|
5858 |
|
|
+ break;
|
5859 |
|
|
+
|
5860 |
|
|
+ case '<':
|
5861 |
|
|
+ genCmpLt (ic, ifxForOp (IC_RESULT (ic), ic));
|
5862 |
|
|
+ break;
|
5863 |
|
|
+
|
5864 |
|
|
+ case LE_OP:
|
5865 |
|
|
+ genCmpLe (ic, ifxForOp (IC_RESULT (ic), ic));
|
5866 |
|
|
+ break;
|
5867 |
|
|
+
|
5868 |
|
|
+ case GE_OP:
|
5869 |
|
|
+ genCmpGe (ic, ifxForOp (IC_RESULT (ic), ic));
|
5870 |
|
|
+ break;
|
5871 |
|
|
+
|
5872 |
|
|
+ case NE_OP:
|
5873 |
|
|
+ genCmpNe (ic, ifxForOp (IC_RESULT (ic), ic));
|
5874 |
|
|
+ break;
|
5875 |
|
|
+
|
5876 |
|
|
+ case EQ_OP:
|
5877 |
|
|
+ genCmpEq (ic, ifxForOp (IC_RESULT (ic), ic));
|
5878 |
|
|
+ break;
|
5879 |
|
|
+
|
5880 |
|
|
+ case AND_OP:
|
5881 |
|
|
+ genAndOp (ic);
|
5882 |
|
|
+ break;
|
5883 |
|
|
+
|
5884 |
|
|
+ case OR_OP:
|
5885 |
|
|
+ genOrOp (ic);
|
5886 |
|
|
+ break;
|
5887 |
|
|
+
|
5888 |
|
|
+ case '^':
|
5889 |
|
|
+ genXor (ic, ifxForOp (IC_RESULT (ic), ic));
|
5890 |
|
|
+ break;
|
5891 |
|
|
+
|
5892 |
|
|
+ case '|':
|
5893 |
|
|
+ genOr (ic, ifxForOp (IC_RESULT (ic), ic));
|
5894 |
|
|
+ break;
|
5895 |
|
|
+
|
5896 |
|
|
+ case BITWISEAND:
|
5897 |
|
|
+ genAnd (ic, ifxForOp (IC_RESULT (ic), ic));
|
5898 |
|
|
+ break;
|
5899 |
|
|
+
|
5900 |
|
|
+ case INLINEASM:
|
5901 |
|
|
+ genInline (ic);
|
5902 |
|
|
+ break;
|
5903 |
|
|
+
|
5904 |
|
|
+ case RRC:
|
5905 |
|
|
+ genRRC (ic);
|
5906 |
|
|
+ break;
|
5907 |
|
|
+
|
5908 |
|
|
+ case RLC:
|
5909 |
|
|
+ genRLC (ic);
|
5910 |
|
|
+ break;
|
5911 |
|
|
+
|
5912 |
|
|
+ case GETHBIT:
|
5913 |
|
|
+ genGetHbit (ic);
|
5914 |
|
|
+ break;
|
5915 |
|
|
+
|
5916 |
|
|
+ case LEFT_OP:
|
5917 |
|
|
+ genLeftShift (ic);
|
5918 |
|
|
+ break;
|
5919 |
|
|
+
|
5920 |
|
|
+ case RIGHT_OP:
|
5921 |
|
|
+ genRightShift (ic);
|
5922 |
|
|
+ break;
|
5923 |
|
|
+
|
5924 |
|
|
+ case '=':
|
5925 |
|
|
+ genAssign (ic);
|
5926 |
|
|
+ break;
|
5927 |
|
|
+
|
5928 |
|
|
+ case IFX:
|
5929 |
|
|
+ genIfx (ic, NULL);
|
5930 |
|
|
+ break;
|
5931 |
|
|
+
|
5932 |
|
|
+ case ADDRESS_OF:
|
5933 |
|
|
+ genAddrOf (ic);
|
5934 |
|
|
+ break;
|
5935 |
|
|
+
|
5936 |
|
|
+ case JUMPTABLE:
|
5937 |
|
|
+ genJumpTab (ic);
|
5938 |
|
|
+ break;
|
5939 |
|
|
+
|
5940 |
|
|
+ case CAST:
|
5941 |
|
|
+ genCast (ic);
|
5942 |
|
|
+ break;
|
5943 |
|
|
+
|
5944 |
|
|
+ case RECEIVE:
|
5945 |
|
|
+ genReceive (ic);
|
5946 |
|
|
+ break;
|
5947 |
|
|
+
|
5948 |
|
|
+ case SEND:
|
5949 |
|
|
+ addSet (&_G.sendSet, ic);
|
5950 |
|
|
+ break;
|
5951 |
|
|
+
|
5952 |
|
|
+ case DUMMY_READ_VOLATILE:
|
5953 |
|
|
+ genDummyRead (ic);
|
5954 |
|
|
+ break;
|
5955 |
|
|
+
|
5956 |
|
|
+ default:
|
5957 |
|
|
+ ic = ic;
|
5958 |
|
|
+ }
|
5959 |
|
|
+ }
|
5960 |
|
|
+
|
5961 |
|
|
+
|
5962 |
|
|
+ /* now we are ready to call the
|
5963 |
|
|
+ peep hole optimizer
|
5964 |
|
|
+ if (!options.nopeep)
|
5965 |
|
|
+ peepHole (&lineHead);
|
5966 |
|
|
+
|
5967 |
|
|
+ */
|
5968 |
|
|
+ /* now do the actual printing */
|
5969 |
|
|
+ printLine (lineHead, codeOutBuf);
|
5970 |
|
|
+ return;
|
5971 |
|
|
+}
|
5972 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/gen.h sdcc-src-3.1.0-pblaze/src/json/gen.h
|
5973 |
|
|
--- sdcc-src-3.1.0/src/json/gen.h 1970-01-01 01:00:00.000000000 +0100
|
5974 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/gen.h 2011-02-07 20:04:44.000000000 +0100
|
5975 |
|
|
@@ -0,0 +1,59 @@
|
5976 |
|
|
+/*-------------------------------------------------------------------------
|
5977 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
5978 |
|
|
+ under the terms of the GNU General Public License as published by the
|
5979 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
5980 |
|
|
+ later version.
|
5981 |
|
|
+
|
5982 |
|
|
+ This program is distributed in the hope that it will be useful,
|
5983 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
5984 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
5985 |
|
|
+ GNU General Public License for more details.
|
5986 |
|
|
+
|
5987 |
|
|
+ You should have received a copy of the GNU General Public License
|
5988 |
|
|
+ along with this program; if not, write to the Free Software
|
5989 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
5990 |
|
|
+
|
5991 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
5992 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
5993 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
5994 |
|
|
+-------------------------------------------------------------------------*/
|
5995 |
|
|
+
|
5996 |
|
|
+#ifndef SDCCGEN_JSON_H
|
5997 |
|
|
+#define SDCCGEN_JSON_H
|
5998 |
|
|
+
|
5999 |
|
|
+enum
|
6000 |
|
|
+ {
|
6001 |
|
|
+ AOP_LIT = 1,
|
6002 |
|
|
+ AOP_REG, AOP_DIR,
|
6003 |
|
|
+ AOP_STK,AOP_STR
|
6004 |
|
|
+ };
|
6005 |
|
|
+
|
6006 |
|
|
+/* type asmop : a homogenised type for
|
6007 |
|
|
+ all the different spaces an operand can be
|
6008 |
|
|
+ in */
|
6009 |
|
|
+typedef struct asmop
|
6010 |
|
|
+ {
|
6011 |
|
|
+
|
6012 |
|
|
+ short type; /* can have values
|
6013 |
|
|
+ AOP_LIT - operand is a literal value
|
6014 |
|
|
+ AOP_REG - must be loaded into a register
|
6015 |
|
|
+ AOP_DIR - direct just a name
|
6016 |
|
|
+
|
6017 |
|
|
+ */
|
6018 |
|
|
+ short coff; /* current offset */
|
6019 |
|
|
+ short size; /* total size */
|
6020 |
|
|
+ unsigned freed:1; /* already freed */
|
6021 |
|
|
+ union
|
6022 |
|
|
+ {
|
6023 |
|
|
+ value *aop_lit; /* if literal */
|
6024 |
|
|
+ regs *aop_reg[4]; /* array of registers */
|
6025 |
|
|
+ char *aop_dir; /* if direct */
|
6026 |
|
|
+ }
|
6027 |
|
|
+ aopu;
|
6028 |
|
|
+ }
|
6029 |
|
|
+asmop;
|
6030 |
|
|
+
|
6031 |
|
|
+void genJSONCode (iCode *);
|
6032 |
|
|
+void json_emitDebuggerSymbol (const char *);
|
6033 |
|
|
+
|
6034 |
|
|
+#endif
|
6035 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/AUTHORS sdcc-src-3.1.0-pblaze/src/json/json/AUTHORS
|
6036 |
|
|
--- sdcc-src-3.1.0/src/json/json/AUTHORS 1970-01-01 01:00:00.000000000 +0100
|
6037 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/AUTHORS 2011-02-07 20:04:46.000000000 +0100
|
6038 |
|
|
@@ -0,0 +1,2 @@
|
6039 |
|
|
+Michael Clark <michael@metaparadigm.com>
|
6040 |
|
|
+C. Watford (christopher.watford@gmail.com)
|
6041 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/COPYING sdcc-src-3.1.0-pblaze/src/json/json/COPYING
|
6042 |
|
|
--- sdcc-src-3.1.0/src/json/json/COPYING 1970-01-01 01:00:00.000000000 +0100
|
6043 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/COPYING 2011-02-07 20:04:46.000000000 +0100
|
6044 |
|
|
@@ -0,0 +1,19 @@
|
6045 |
|
|
+Copyright (c) 2004, 2005 Metaparadigm Pte Ltd
|
6046 |
|
|
+
|
6047 |
|
|
+Permission is hereby granted, free of charge, to any person obtaining a
|
6048 |
|
|
+copy of this software and associated documentation files (the "Software"),
|
6049 |
|
|
+to deal in the Software without restriction, including without limitation
|
6050 |
|
|
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
6051 |
|
|
+and/or sell copies of the Software, and to permit persons to whom the
|
6052 |
|
|
+Software is furnished to do so, subject to the following conditions:
|
6053 |
|
|
+
|
6054 |
|
|
+The above copyright notice and this permission notice shall be included
|
6055 |
|
|
+in all copies or substantial portions of the Software.
|
6056 |
|
|
+
|
6057 |
|
|
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
6058 |
|
|
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
6059 |
|
|
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
6060 |
|
|
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
6061 |
|
|
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
6062 |
|
|
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
6063 |
|
|
+SOFTWARE.
|
6064 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/arraylist.c sdcc-src-3.1.0-pblaze/src/json/json/arraylist.c
|
6065 |
|
|
--- sdcc-src-3.1.0/src/json/json/arraylist.c 1970-01-01 01:00:00.000000000 +0100
|
6066 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/arraylist.c 2011-02-07 20:04:46.000000000 +0100
|
6067 |
|
|
@@ -0,0 +1,93 @@
|
6068 |
|
|
+/*
|
6069 |
|
|
+ * $Id: arraylist.c,v 1.4 2006/01/26 02:16:28 mclark Exp $
|
6070 |
|
|
+ *
|
6071 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
6072 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
6073 |
|
|
+ *
|
6074 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
6075 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
6076 |
|
|
+ *
|
6077 |
|
|
+ */
|
6078 |
|
|
+
|
6079 |
|
|
+#include "config.h"
|
6080 |
|
|
+
|
6081 |
|
|
+#if STDC_HEADERS
|
6082 |
|
|
+# include <stdlib.h>
|
6083 |
|
|
+# include <string.h>
|
6084 |
|
|
+#endif /* STDC_HEADERS */
|
6085 |
|
|
+
|
6086 |
|
|
+#if HAVE_STRINGS_H
|
6087 |
|
|
+# include <strings.h>
|
6088 |
|
|
+#endif /* HAVE_STRINGS_H */
|
6089 |
|
|
+
|
6090 |
|
|
+#include "bits.h"
|
6091 |
|
|
+#include "arraylist.h"
|
6092 |
|
|
+
|
6093 |
|
|
+struct array_list*
|
6094 |
|
|
+array_list_new(array_list_free_fn *free_fn)
|
6095 |
|
|
+{
|
6096 |
|
|
+ struct array_list *this;
|
6097 |
|
|
+
|
6098 |
|
|
+ if(!(this = calloc(1, sizeof(struct array_list)))) return NULL;
|
6099 |
|
|
+ this->size = ARRAY_LIST_DEFAULT_SIZE;
|
6100 |
|
|
+ this->length = 0;
|
6101 |
|
|
+ this->free_fn = free_fn;
|
6102 |
|
|
+ if(!(this->array = calloc(sizeof(void*), this->size))) {
|
6103 |
|
|
+ free(this);
|
6104 |
|
|
+ return NULL;
|
6105 |
|
|
+ }
|
6106 |
|
|
+ return this;
|
6107 |
|
|
+}
|
6108 |
|
|
+
|
6109 |
|
|
+extern void
|
6110 |
|
|
+array_list_free(struct array_list *this)
|
6111 |
|
|
+{
|
6112 |
|
|
+ int i;
|
6113 |
|
|
+ for(i = 0; i < this->length; i++)
|
6114 |
|
|
+ if(this->array[i]) this->free_fn(this->array[i]);
|
6115 |
|
|
+ free(this->array);
|
6116 |
|
|
+ free(this);
|
6117 |
|
|
+}
|
6118 |
|
|
+
|
6119 |
|
|
+void*
|
6120 |
|
|
+array_list_get_idx(struct array_list *this, int i)
|
6121 |
|
|
+{
|
6122 |
|
|
+ if(i >= this->length) return NULL;
|
6123 |
|
|
+ return this->array[i];
|
6124 |
|
|
+}
|
6125 |
|
|
+
|
6126 |
|
|
+static int array_list_expand_internal(struct array_list *this, int max)
|
6127 |
|
|
+{
|
6128 |
|
|
+ void *t;
|
6129 |
|
|
+ int new_size;
|
6130 |
|
|
+
|
6131 |
|
|
+ if(max < this->size) return 0;
|
6132 |
|
|
+ new_size = max(this->size << 1, max);
|
6133 |
|
|
+ if(!(t = realloc(this->array, new_size*sizeof(void*)))) return -1;
|
6134 |
|
|
+ this->array = t;
|
6135 |
|
|
+ (void)memset(this->array + this->size, 0, (new_size-this->size)*sizeof(void*));
|
6136 |
|
|
+ this->size = new_size;
|
6137 |
|
|
+ return 0;
|
6138 |
|
|
+}
|
6139 |
|
|
+
|
6140 |
|
|
+int
|
6141 |
|
|
+array_list_put_idx(struct array_list *this, int idx, void *data)
|
6142 |
|
|
+{
|
6143 |
|
|
+ if(array_list_expand_internal(this, idx)) return -1;
|
6144 |
|
|
+ if(this->array[idx]) this->free_fn(this->array[idx]);
|
6145 |
|
|
+ this->array[idx] = data;
|
6146 |
|
|
+ if(this->length <= idx) this->length = idx + 1;
|
6147 |
|
|
+ return 0;
|
6148 |
|
|
+}
|
6149 |
|
|
+
|
6150 |
|
|
+int
|
6151 |
|
|
+array_list_add(struct array_list *this, void *data)
|
6152 |
|
|
+{
|
6153 |
|
|
+ return array_list_put_idx(this, this->length, data);
|
6154 |
|
|
+}
|
6155 |
|
|
+
|
6156 |
|
|
+int
|
6157 |
|
|
+array_list_length(struct array_list *this)
|
6158 |
|
|
+{
|
6159 |
|
|
+ return this->length;
|
6160 |
|
|
+}
|
6161 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/arraylist.h sdcc-src-3.1.0-pblaze/src/json/json/arraylist.h
|
6162 |
|
|
--- sdcc-src-3.1.0/src/json/json/arraylist.h 1970-01-01 01:00:00.000000000 +0100
|
6163 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/arraylist.h 2011-02-07 20:04:46.000000000 +0100
|
6164 |
|
|
@@ -0,0 +1,45 @@
|
6165 |
|
|
+/*
|
6166 |
|
|
+ * $Id: arraylist.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
|
6167 |
|
|
+ *
|
6168 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
6169 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
6170 |
|
|
+ *
|
6171 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
6172 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
6173 |
|
|
+ *
|
6174 |
|
|
+ */
|
6175 |
|
|
+
|
6176 |
|
|
+#ifndef _arraylist_h_
|
6177 |
|
|
+#define _arraylist_h_
|
6178 |
|
|
+
|
6179 |
|
|
+#define ARRAY_LIST_DEFAULT_SIZE 32
|
6180 |
|
|
+
|
6181 |
|
|
+typedef void (array_list_free_fn) (void *data);
|
6182 |
|
|
+
|
6183 |
|
|
+struct array_list
|
6184 |
|
|
+{
|
6185 |
|
|
+ void **array;
|
6186 |
|
|
+ int length;
|
6187 |
|
|
+ int size;
|
6188 |
|
|
+ array_list_free_fn *free_fn;
|
6189 |
|
|
+};
|
6190 |
|
|
+
|
6191 |
|
|
+extern struct array_list*
|
6192 |
|
|
+array_list_new(array_list_free_fn *free_fn);
|
6193 |
|
|
+
|
6194 |
|
|
+extern void
|
6195 |
|
|
+array_list_free(struct array_list *al);
|
6196 |
|
|
+
|
6197 |
|
|
+extern void*
|
6198 |
|
|
+array_list_get_idx(struct array_list *al, int i);
|
6199 |
|
|
+
|
6200 |
|
|
+extern int
|
6201 |
|
|
+array_list_put_idx(struct array_list *al, int i, void *data);
|
6202 |
|
|
+
|
6203 |
|
|
+extern int
|
6204 |
|
|
+array_list_add(struct array_list *al, void *data);
|
6205 |
|
|
+
|
6206 |
|
|
+extern int
|
6207 |
|
|
+array_list_length(struct array_list *al);
|
6208 |
|
|
+
|
6209 |
|
|
+#endif
|
6210 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/bits.h sdcc-src-3.1.0-pblaze/src/json/json/bits.h
|
6211 |
|
|
--- sdcc-src-3.1.0/src/json/json/bits.h 1970-01-01 01:00:00.000000000 +0100
|
6212 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/bits.h 2011-02-07 20:04:46.000000000 +0100
|
6213 |
|
|
@@ -0,0 +1,27 @@
|
6214 |
|
|
+/*
|
6215 |
|
|
+ * $Id: bits.h,v 1.10 2006/01/30 23:07:57 mclark Exp $
|
6216 |
|
|
+ *
|
6217 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
6218 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
6219 |
|
|
+ *
|
6220 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
6221 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
6222 |
|
|
+ *
|
6223 |
|
|
+ */
|
6224 |
|
|
+
|
6225 |
|
|
+#ifndef _bits_h_
|
6226 |
|
|
+#define _bits_h_
|
6227 |
|
|
+
|
6228 |
|
|
+#ifndef min
|
6229 |
|
|
+//#define min(a,b) ((a) < (b) ? (a) : (b))
|
6230 |
|
|
+#endif
|
6231 |
|
|
+
|
6232 |
|
|
+#ifndef max
|
6233 |
|
|
+//#define max(a,b) ((a) > (b) ? (a) : (b))
|
6234 |
|
|
+#endif
|
6235 |
|
|
+
|
6236 |
|
|
+#define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
|
6237 |
|
|
+#define error_ptr(error) ((void*)error)
|
6238 |
|
|
+#define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L)
|
6239 |
|
|
+
|
6240 |
|
|
+#endif
|
6241 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/config.h sdcc-src-3.1.0-pblaze/src/json/json/config.h
|
6242 |
|
|
--- sdcc-src-3.1.0/src/json/json/config.h 1970-01-01 01:00:00.000000000 +0100
|
6243 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/config.h 2011-02-07 20:04:46.000000000 +0100
|
6244 |
|
|
@@ -0,0 +1,94 @@
|
6245 |
|
|
+/*
|
6246 |
|
|
+ * $Id: config.h.win32,v 1.2 2006/01/26 02:16:28 mclark Exp $
|
6247 |
|
|
+ *
|
6248 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
6249 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
6250 |
|
|
+ *
|
6251 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
6252 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
6253 |
|
|
+ *
|
6254 |
|
|
+ */
|
6255 |
|
|
+
|
6256 |
|
|
+/* config.h.win32 Generated by configure. */
|
6257 |
|
|
+
|
6258 |
|
|
+#define PACKAGE_STRING "JSON C Library 0.2"
|
6259 |
|
|
+#define PACKAGE_BUGREPORT "michael@metaparadigm.com"
|
6260 |
|
|
+#define PACKAGE_NAME "JSON C Library"
|
6261 |
|
|
+#define PACKAGE_TARNAME "json-c"
|
6262 |
|
|
+#define PACKAGE_VERSION "0.2"
|
6263 |
|
|
+
|
6264 |
|
|
+/* config.h.in. Generated from configure.ac by autoheader. */
|
6265 |
|
|
+
|
6266 |
|
|
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
6267 |
|
|
+/* #undef HAVE_DOPRNT */
|
6268 |
|
|
+
|
6269 |
|
|
+/* Define to 1 if you have the <fcntl.h> header file. */
|
6270 |
|
|
+#define HAVE_FCNTL_H 1
|
6271 |
|
|
+
|
6272 |
|
|
+/* Define to 1 if you have the <inttypes.h> header file. */
|
6273 |
|
|
+#define HAVE_INTTYPES_H 1
|
6274 |
|
|
+
|
6275 |
|
|
+/* Define to 1 if you have the <limits.h> header file. */
|
6276 |
|
|
+#define HAVE_LIMITS_H 1
|
6277 |
|
|
+
|
6278 |
|
|
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
6279 |
|
|
+ to 0 otherwise. */
|
6280 |
|
|
+#define HAVE_MALLOC 1
|
6281 |
|
|
+
|
6282 |
|
|
+/* Define to 1 if you have the <memory.h> header file. */
|
6283 |
|
|
+#define HAVE_MEMORY_H 1
|
6284 |
|
|
+
|
6285 |
|
|
+/* Define to 1 if you have the `open' function. */
|
6286 |
|
|
+#undef HAVE_OPEN
|
6287 |
|
|
+
|
6288 |
|
|
+/* Define to 1 if your system has a GNU libc compatible `realloc' function,
|
6289 |
|
|
+ and to 0 otherwise. */
|
6290 |
|
|
+#define HAVE_REALLOC 1
|
6291 |
|
|
+
|
6292 |
|
|
+/* Define to 1 if you have the <stdint.h> header file. */
|
6293 |
|
|
+#define HAVE_STDINT_H 1
|
6294 |
|
|
+
|
6295 |
|
|
+/* Define to 1 if you have the <stdlib.h> header file. */
|
6296 |
|
|
+#define HAVE_STDLIB_H 1
|
6297 |
|
|
+
|
6298 |
|
|
+/* Define to 1 if you have the `strdup' function. */
|
6299 |
|
|
+#undef HAVE_STRNDUP
|
6300 |
|
|
+
|
6301 |
|
|
+/* Define to 1 if you have the <stdarg.h> header file. */
|
6302 |
|
|
+#define HAVE_STDARG_H 1
|
6303 |
|
|
+
|
6304 |
|
|
+/* Define to 1 if you have the `strerror' function. */
|
6305 |
|
|
+#define HAVE_STRERROR 1
|
6306 |
|
|
+
|
6307 |
|
|
+/* Define to 1 if you have the <strings.h> header file. */
|
6308 |
|
|
+#undef HAVE_STRINGS_H
|
6309 |
|
|
+
|
6310 |
|
|
+/* Define to 1 if you have the <string.h> header file. */
|
6311 |
|
|
+#define HAVE_STRING_H 1
|
6312 |
|
|
+
|
6313 |
|
|
+/* Define to 1 if you have the <syslog.h> header file. */
|
6314 |
|
|
+#undef HAVE_SYSLOG_H
|
6315 |
|
|
+
|
6316 |
|
|
+/* Define to 1 if you have the <sys/param.h> header file. */
|
6317 |
|
|
+#undef HAVE_SYS_PARAM_H
|
6318 |
|
|
+
|
6319 |
|
|
+/* Define to 1 if you have the <sys/stat.h> header file. */
|
6320 |
|
|
+#define HAVE_SYS_STAT_H 1
|
6321 |
|
|
+
|
6322 |
|
|
+/* Define to 1 if you have the <sys/types.h> header file. */
|
6323 |
|
|
+#define HAVE_SYS_TYPES_H 1
|
6324 |
|
|
+
|
6325 |
|
|
+/* Define to 1 if you have the <unistd.h> header file. */
|
6326 |
|
|
+#undef HAVE_UNISTD_H
|
6327 |
|
|
+
|
6328 |
|
|
+/* Define to 1 if you have the `vprintf' function. */
|
6329 |
|
|
+#undef HAVE_VPRINTF
|
6330 |
|
|
+
|
6331 |
|
|
+/* Define to 1 if you have the `vsyslog' function. */
|
6332 |
|
|
+#undef HAVE_VSYSLOG
|
6333 |
|
|
+
|
6334 |
|
|
+/* Define to 1 if you have the `strncasecmp' function. */
|
6335 |
|
|
+#undef HAVE_STRNCASECMP
|
6336 |
|
|
+
|
6337 |
|
|
+/* Define to 1 if you have the ANSI C header files. */
|
6338 |
|
|
+#define STDC_HEADERS 1
|
6339 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/debug.c sdcc-src-3.1.0-pblaze/src/json/json/debug.c
|
6340 |
|
|
--- sdcc-src-3.1.0/src/json/json/debug.c 1970-01-01 01:00:00.000000000 +0100
|
6341 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/debug.c 2011-02-07 20:04:46.000000000 +0100
|
6342 |
|
|
@@ -0,0 +1,98 @@
|
6343 |
|
|
+/*
|
6344 |
|
|
+ * $Id: debug.c,v 1.5 2006/01/26 02:16:28 mclark Exp $
|
6345 |
|
|
+ *
|
6346 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
6347 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
6348 |
|
|
+ *
|
6349 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
6350 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
6351 |
|
|
+ *
|
6352 |
|
|
+ */
|
6353 |
|
|
+
|
6354 |
|
|
+#include "config.h"
|
6355 |
|
|
+
|
6356 |
|
|
+#include <stdio.h>
|
6357 |
|
|
+#include <stdlib.h>
|
6358 |
|
|
+#include <string.h>
|
6359 |
|
|
+#include <stdarg.h>
|
6360 |
|
|
+
|
6361 |
|
|
+#if HAVE_SYSLOG_H
|
6362 |
|
|
+# include <syslog.h>
|
6363 |
|
|
+#endif /* HAVE_SYSLOG_H */
|
6364 |
|
|
+
|
6365 |
|
|
+#if HAVE_UNISTD_H
|
6366 |
|
|
+# include <unistd.h>
|
6367 |
|
|
+#endif /* HAVE_UNISTD_H */
|
6368 |
|
|
+
|
6369 |
|
|
+#if HAVE_SYS_PARAM_H
|
6370 |
|
|
+#include <sys/param.h>
|
6371 |
|
|
+#endif /* HAVE_SYS_PARAM_H */
|
6372 |
|
|
+
|
6373 |
|
|
+#include "debug.h"
|
6374 |
|
|
+
|
6375 |
|
|
+static int _syslog = 0;
|
6376 |
|
|
+static int _debug = 0;
|
6377 |
|
|
+
|
6378 |
|
|
+void mc_set_debug(int debug) { _debug = debug; }
|
6379 |
|
|
+int mc_get_debug() { return _debug; }
|
6380 |
|
|
+
|
6381 |
|
|
+extern void mc_set_syslog(int syslog)
|
6382 |
|
|
+{
|
6383 |
|
|
+ _syslog = syslog;
|
6384 |
|
|
+}
|
6385 |
|
|
+
|
6386 |
|
|
+void mc_abort(const char *msg, ...)
|
6387 |
|
|
+{
|
6388 |
|
|
+ va_list ap;
|
6389 |
|
|
+ va_start(ap, msg);
|
6390 |
|
|
+#if HAVE_VSYSLOG
|
6391 |
|
|
+ if(_syslog) {
|
6392 |
|
|
+ vsyslog(LOG_ERR, msg, ap);
|
6393 |
|
|
+ } else
|
6394 |
|
|
+#endif
|
6395 |
|
|
+ vprintf(msg, ap);
|
6396 |
|
|
+ va_end(ap);
|
6397 |
|
|
+ exit(1);
|
6398 |
|
|
+}
|
6399 |
|
|
+
|
6400 |
|
|
+
|
6401 |
|
|
+void mc_debug(const char *msg, ...)
|
6402 |
|
|
+{
|
6403 |
|
|
+ va_list ap;
|
6404 |
|
|
+ if(_debug) {
|
6405 |
|
|
+ va_start(ap, msg);
|
6406 |
|
|
+#if HAVE_VSYSLOG
|
6407 |
|
|
+ if(_syslog) {
|
6408 |
|
|
+ vsyslog(LOG_DEBUG, msg, ap);
|
6409 |
|
|
+ } else
|
6410 |
|
|
+#endif
|
6411 |
|
|
+ vprintf(msg, ap);
|
6412 |
|
|
+ va_end(ap);
|
6413 |
|
|
+ }
|
6414 |
|
|
+}
|
6415 |
|
|
+
|
6416 |
|
|
+void mc_error(const char *msg, ...)
|
6417 |
|
|
+{
|
6418 |
|
|
+ va_list ap;
|
6419 |
|
|
+ va_start(ap, msg);
|
6420 |
|
|
+#if HAVE_VSYSLOG
|
6421 |
|
|
+ if(_syslog) {
|
6422 |
|
|
+ vsyslog(LOG_ERR, msg, ap);
|
6423 |
|
|
+ } else
|
6424 |
|
|
+#endif
|
6425 |
|
|
+ vfprintf(stderr, msg, ap);
|
6426 |
|
|
+ va_end(ap);
|
6427 |
|
|
+}
|
6428 |
|
|
+
|
6429 |
|
|
+void mc_info(const char *msg, ...)
|
6430 |
|
|
+{
|
6431 |
|
|
+ va_list ap;
|
6432 |
|
|
+ va_start(ap, msg);
|
6433 |
|
|
+#if HAVE_VSYSLOG
|
6434 |
|
|
+ if(_syslog) {
|
6435 |
|
|
+ vsyslog(LOG_INFO, msg, ap);
|
6436 |
|
|
+ } else
|
6437 |
|
|
+#endif
|
6438 |
|
|
+ vfprintf(stderr, msg, ap);
|
6439 |
|
|
+ va_end(ap);
|
6440 |
|
|
+}
|
6441 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/debug.h sdcc-src-3.1.0-pblaze/src/json/json/debug.h
|
6442 |
|
|
--- sdcc-src-3.1.0/src/json/json/debug.h 1970-01-01 01:00:00.000000000 +0100
|
6443 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/debug.h 2011-02-07 20:04:46.000000000 +0100
|
6444 |
|
|
@@ -0,0 +1,42 @@
|
6445 |
|
|
+/*
|
6446 |
|
|
+ * $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $
|
6447 |
|
|
+ *
|
6448 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
6449 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
6450 |
|
|
+ *
|
6451 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
6452 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
6453 |
|
|
+ *
|
6454 |
|
|
+ */
|
6455 |
|
|
+
|
6456 |
|
|
+#ifndef _DEBUG_H_
|
6457 |
|
|
+#define _DEBUG_H_
|
6458 |
|
|
+
|
6459 |
|
|
+extern void mc_set_debug(int debug);
|
6460 |
|
|
+extern int mc_get_debug(void);
|
6461 |
|
|
+
|
6462 |
|
|
+extern void mc_set_syslog(int syslog);
|
6463 |
|
|
+extern void mc_abort(const char *msg, ...);
|
6464 |
|
|
+extern void mc_debug(const char *msg, ...);
|
6465 |
|
|
+extern void mc_error(const char *msg, ...);
|
6466 |
|
|
+extern void mc_info(const char *msg, ...);
|
6467 |
|
|
+
|
6468 |
|
|
+#ifdef MC_MAINTAINER_MODE
|
6469 |
|
|
+#define MC_SET_DEBUG(x) mc_set_debug(x)
|
6470 |
|
|
+#define MC_GET_DEBUG() mc_get_debug()
|
6471 |
|
|
+#define MC_SET_SYSLOG(x) mc_set_syslog(x)
|
6472 |
|
|
+#define MC_ABORT(x, ...) mc_abort(x, ##__VA_ARGS__)
|
6473 |
|
|
+#define MC_DEBUG(x, ...) mc_debug(x, ##__VA_ARGS__)
|
6474 |
|
|
+#define MC_ERROR(x, ...) mc_error(x, ##__VA_ARGS__)
|
6475 |
|
|
+#define MC_INFO(x, ...) mc_info(x, ##__VA_ARGS__)
|
6476 |
|
|
+#else
|
6477 |
|
|
+#define MC_SET_DEBUG(x) if (0) mc_set_debug(x)
|
6478 |
|
|
+#define MC_GET_DEBUG() (0)
|
6479 |
|
|
+#define MC_SET_SYSLOG(x) if (0) mc_set_syslog(x)
|
6480 |
|
|
+#define MC_ABORT(x, ...) if (0) mc_abort(x, ##__VA_ARGS__)
|
6481 |
|
|
+#define MC_DEBUG(x, ...) if (0) mc_debug(x, ##__VA_ARGS__)
|
6482 |
|
|
+#define MC_ERROR(x, ...) if (0) mc_error(x, ##__VA_ARGS__)
|
6483 |
|
|
+#define MC_INFO(x, ...) if (0) mc_info(x, ##__VA_ARGS__)
|
6484 |
|
|
+#endif
|
6485 |
|
|
+
|
6486 |
|
|
+#endif
|
6487 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/json.h sdcc-src-3.1.0-pblaze/src/json/json/json.h
|
6488 |
|
|
--- sdcc-src-3.1.0/src/json/json/json.h 1970-01-01 01:00:00.000000000 +0100
|
6489 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/json.h 2011-02-07 20:04:46.000000000 +0100
|
6490 |
|
|
@@ -0,0 +1,31 @@
|
6491 |
|
|
+/*
|
6492 |
|
|
+ * $Id: json.h,v 1.6 2006/01/26 02:16:28 mclark Exp $
|
6493 |
|
|
+ *
|
6494 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
6495 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
6496 |
|
|
+ *
|
6497 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
6498 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
6499 |
|
|
+ *
|
6500 |
|
|
+ */
|
6501 |
|
|
+
|
6502 |
|
|
+#ifndef _json_h_
|
6503 |
|
|
+#define _json_h_
|
6504 |
|
|
+
|
6505 |
|
|
+#ifdef __cplusplus
|
6506 |
|
|
+extern "C" {
|
6507 |
|
|
+#endif
|
6508 |
|
|
+
|
6509 |
|
|
+#include "bits.h"
|
6510 |
|
|
+#include "debug.h"
|
6511 |
|
|
+#include "linkhash.h"
|
6512 |
|
|
+#include "arraylist.h"
|
6513 |
|
|
+#include "json_util.h"
|
6514 |
|
|
+#include "json_object.h"
|
6515 |
|
|
+#include "json_tokener.h"
|
6516 |
|
|
+
|
6517 |
|
|
+#ifdef __cplusplus
|
6518 |
|
|
+}
|
6519 |
|
|
+#endif
|
6520 |
|
|
+
|
6521 |
|
|
+#endif
|
6522 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/json_object.c sdcc-src-3.1.0-pblaze/src/json/json/json_object.c
|
6523 |
|
|
--- sdcc-src-3.1.0/src/json/json/json_object.c 1970-01-01 01:00:00.000000000 +0100
|
6524 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/json_object.c 2011-02-07 20:04:46.000000000 +0100
|
6525 |
|
|
@@ -0,0 +1,569 @@
|
6526 |
|
|
+/*
|
6527 |
|
|
+ * $Id: json_object.c,v 1.17 2006/07/25 03:24:50 mclark Exp $
|
6528 |
|
|
+ *
|
6529 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
6530 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
6531 |
|
|
+ *
|
6532 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
6533 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
6534 |
|
|
+ *
|
6535 |
|
|
+ */
|
6536 |
|
|
+
|
6537 |
|
|
+#include "config.h"
|
6538 |
|
|
+
|
6539 |
|
|
+#include <stdio.h>
|
6540 |
|
|
+#include <stdlib.h>
|
6541 |
|
|
+#include <stddef.h>
|
6542 |
|
|
+#include <string.h>
|
6543 |
|
|
+
|
6544 |
|
|
+#include "debug.h"
|
6545 |
|
|
+#include "printbuf.h"
|
6546 |
|
|
+#include "linkhash.h"
|
6547 |
|
|
+#include "arraylist.h"
|
6548 |
|
|
+#include "json_object.h"
|
6549 |
|
|
+#include "json_object_private.h"
|
6550 |
|
|
+#include "json_tokener.h"
|
6551 |
|
|
+
|
6552 |
|
|
+#include "SDCCglobl.h"
|
6553 |
|
|
+
|
6554 |
|
|
+#if !HAVE_STRNDUP
|
6555 |
|
|
+ char* strndup(const char* str, size_t n);
|
6556 |
|
|
+#endif /* !HAVE_STRNDUP */
|
6557 |
|
|
+
|
6558 |
|
|
+#define REFCOUNT_DEBUG 1
|
6559 |
|
|
+
|
6560 |
|
|
+const char *json_number_chars = "0123456789.+-eE";
|
6561 |
|
|
+const char *json_hex_chars = "0123456789abcdef";
|
6562 |
|
|
+int indent = TRUE; // indent enable
|
6563 |
|
|
+int indentDeep = 0; // contain actual deep during the string generation
|
6564 |
|
|
+int indentStep = 4; // one tabulator equals to 4 spaces
|
6565 |
|
|
+int carRet = FALSE; // insert the return character in front of the opening bracket { or [ ?
|
6566 |
|
|
+
|
6567 |
|
|
+#ifdef REFCOUNT_DEBUG
|
6568 |
|
|
+static const char* json_type_name[] = {
|
6569 |
|
|
+ "null",
|
6570 |
|
|
+ "boolean",
|
6571 |
|
|
+ "double",
|
6572 |
|
|
+ "int",
|
6573 |
|
|
+ "object",
|
6574 |
|
|
+ "array",
|
6575 |
|
|
+ "string",
|
6576 |
|
|
+};
|
6577 |
|
|
+#endif /* REFCOUNT_DEBUG */
|
6578 |
|
|
+
|
6579 |
|
|
+static void json_object_generic_delete(struct json_object* this);
|
6580 |
|
|
+static struct json_object* json_object_new(enum json_type o_type);
|
6581 |
|
|
+
|
6582 |
|
|
+
|
6583 |
|
|
+/* ref count debugging */
|
6584 |
|
|
+
|
6585 |
|
|
+#ifdef REFCOUNT_DEBUG
|
6586 |
|
|
+
|
6587 |
|
|
+static struct lh_table *json_object_table;
|
6588 |
|
|
+
|
6589 |
|
|
+//static void json_object_init(void) __attribute__ ((constructor));
|
6590 |
|
|
+/*extern*/ static void json_object_init(void) {
|
6591 |
|
|
+ MC_DEBUG("json_object_init: creating object table\n");
|
6592 |
|
|
+ json_object_table = lh_kptr_table_new(128, "json_object_table", NULL);
|
6593 |
|
|
+}
|
6594 |
|
|
+
|
6595 |
|
|
+//static void json_object_fini(void) __attribute__ ((destructor));
|
6596 |
|
|
+/*extern*/ static void json_object_fini(void) {
|
6597 |
|
|
+ struct lh_entry *ent;
|
6598 |
|
|
+ if(MC_GET_DEBUG()) {
|
6599 |
|
|
+ if (json_object_table->count) {
|
6600 |
|
|
+ MC_DEBUG("json_object_fini: %d referenced objects at exit\n",
|
6601 |
|
|
+ json_object_table->count);
|
6602 |
|
|
+ lh_foreach(json_object_table, ent) {
|
6603 |
|
|
+ struct json_object* obj = (struct json_object*)ent->v;
|
6604 |
|
|
+ MC_DEBUG("\t%s:%p\n", json_type_name[obj->o_type], obj);
|
6605 |
|
|
+ }
|
6606 |
|
|
+ }
|
6607 |
|
|
+ }
|
6608 |
|
|
+ MC_DEBUG("json_object_fini: freeing object table\n");
|
6609 |
|
|
+ lh_table_free(json_object_table);
|
6610 |
|
|
+}
|
6611 |
|
|
+#endif /* REFCOUNT_DEBUG */
|
6612 |
|
|
+
|
6613 |
|
|
+
|
6614 |
|
|
+/* string escaping */
|
6615 |
|
|
+
|
6616 |
|
|
+static int json_escape_str(struct printbuf *pb, char *str)
|
6617 |
|
|
+{
|
6618 |
|
|
+ int pos = 0, start_offset = 0;
|
6619 |
|
|
+ unsigned char c;
|
6620 |
|
|
+ do {
|
6621 |
|
|
+ c = str[pos];
|
6622 |
|
|
+ switch(c) {
|
6623 |
|
|
+ case '\0':
|
6624 |
|
|
+ break;
|
6625 |
|
|
+ case '\b':
|
6626 |
|
|
+ case '\n':
|
6627 |
|
|
+ case '\r':
|
6628 |
|
|
+ case '\t':
|
6629 |
|
|
+ case '"':
|
6630 |
|
|
+ case '\\':
|
6631 |
|
|
+ case '/':
|
6632 |
|
|
+ if(pos - start_offset > 0)
|
6633 |
|
|
+ printbuf_memappend(pb, str + start_offset, pos - start_offset);
|
6634 |
|
|
+ if(c == '\b') printbuf_memappend(pb, "\\b", 2);
|
6635 |
|
|
+ else if(c == '\n') printbuf_memappend(pb, "\\n", 2);
|
6636 |
|
|
+ else if(c == '\r') printbuf_memappend(pb, "\\r", 2);
|
6637 |
|
|
+ else if(c == '\t') printbuf_memappend(pb, "\\t", 2);
|
6638 |
|
|
+ else if(c == '"') printbuf_memappend(pb, "\\\"", 2);
|
6639 |
|
|
+ else if(c == '\\') printbuf_memappend(pb, "\\\\", 2);
|
6640 |
|
|
+ else if(c == '/') printbuf_memappend(pb, "\\/", 2);
|
6641 |
|
|
+ start_offset = ++pos;
|
6642 |
|
|
+ break;
|
6643 |
|
|
+ default:
|
6644 |
|
|
+ if(c < ' ') {
|
6645 |
|
|
+ if(pos - start_offset > 0)
|
6646 |
|
|
+ printbuf_memappend(pb, str + start_offset, pos - start_offset);
|
6647 |
|
|
+ sprintbuf(pb, "\\u00%c%c",
|
6648 |
|
|
+ json_hex_chars[c >> 4],
|
6649 |
|
|
+ json_hex_chars[c & 0xf]);
|
6650 |
|
|
+ start_offset = ++pos;
|
6651 |
|
|
+ } else pos++;
|
6652 |
|
|
+ }
|
6653 |
|
|
+ } while(c);
|
6654 |
|
|
+ if(pos - start_offset > 0)
|
6655 |
|
|
+ printbuf_memappend(pb, str + start_offset, pos - start_offset);
|
6656 |
|
|
+ return 0;
|
6657 |
|
|
+}
|
6658 |
|
|
+
|
6659 |
|
|
+
|
6660 |
|
|
+/* reference counting */
|
6661 |
|
|
+
|
6662 |
|
|
+extern struct json_object* json_object_get(struct json_object *this)
|
6663 |
|
|
+{
|
6664 |
|
|
+ if(this) {
|
6665 |
|
|
+ this->_ref_count++;
|
6666 |
|
|
+ }
|
6667 |
|
|
+ return this;
|
6668 |
|
|
+}
|
6669 |
|
|
+
|
6670 |
|
|
+extern void json_object_put(struct json_object *this)
|
6671 |
|
|
+{
|
6672 |
|
|
+ if(this) {
|
6673 |
|
|
+ this->_ref_count--;
|
6674 |
|
|
+ if(!this->_ref_count) this->_delete(this);
|
6675 |
|
|
+ }
|
6676 |
|
|
+}
|
6677 |
|
|
+
|
6678 |
|
|
+
|
6679 |
|
|
+/* generic object construction and destruction parts */
|
6680 |
|
|
+
|
6681 |
|
|
+static void json_object_generic_delete(struct json_object* this)
|
6682 |
|
|
+{
|
6683 |
|
|
+#ifdef REFCOUNT_DEBUG
|
6684 |
|
|
+ MC_DEBUG("json_object_delete_%s: %p\n",
|
6685 |
|
|
+ json_type_name[this->o_type], this);
|
6686 |
|
|
+ lh_table_delete(json_object_table, this);
|
6687 |
|
|
+#endif /* REFCOUNT_DEBUG */
|
6688 |
|
|
+ printbuf_free(this->_pb);
|
6689 |
|
|
+ free(this);
|
6690 |
|
|
+}
|
6691 |
|
|
+
|
6692 |
|
|
+static struct json_object* json_object_new(enum json_type o_type)
|
6693 |
|
|
+{
|
6694 |
|
|
+ struct json_object *this = calloc(sizeof(struct json_object), 1);
|
6695 |
|
|
+ if(!this) return NULL;
|
6696 |
|
|
+ this->o_type = o_type;
|
6697 |
|
|
+ this->_ref_count = 1;
|
6698 |
|
|
+ this->_delete = &json_object_generic_delete;
|
6699 |
|
|
+#ifdef REFCOUNT_DEBUG
|
6700 |
|
|
+ if (json_object_table == NULL)
|
6701 |
|
|
+ json_object_table = lh_kptr_table_new(128, "json_object_table", NULL);
|
6702 |
|
|
+ lh_table_insert(json_object_table, this, this);
|
6703 |
|
|
+ MC_DEBUG("json_object_new_%s: %p\n", json_type_name[this->o_type], this);
|
6704 |
|
|
+#endif /* REFCOUNT_DEBUG */
|
6705 |
|
|
+ return this;
|
6706 |
|
|
+}
|
6707 |
|
|
+
|
6708 |
|
|
+
|
6709 |
|
|
+/* type checking functions */
|
6710 |
|
|
+
|
6711 |
|
|
+int json_object_is_type(struct json_object *this, enum json_type type)
|
6712 |
|
|
+{
|
6713 |
|
|
+ return (this->o_type == type);
|
6714 |
|
|
+}
|
6715 |
|
|
+
|
6716 |
|
|
+enum json_type json_object_get_type(struct json_object *this)
|
6717 |
|
|
+{
|
6718 |
|
|
+ return this->o_type;
|
6719 |
|
|
+}
|
6720 |
|
|
+
|
6721 |
|
|
+
|
6722 |
|
|
+/* json_object_to_json_string */
|
6723 |
|
|
+
|
6724 |
|
|
+const char* json_object_to_json_string(struct json_object *this)
|
6725 |
|
|
+{
|
6726 |
|
|
+ if(!this) return "null";
|
6727 |
|
|
+ if(!this->_pb) {
|
6728 |
|
|
+ if(!(this->_pb = printbuf_new())) return NULL;
|
6729 |
|
|
+ } else {
|
6730 |
|
|
+ printbuf_reset(this->_pb);
|
6731 |
|
|
+ }
|
6732 |
|
|
+ if(this->_to_json_string(this, this->_pb) < 0) return NULL;
|
6733 |
|
|
+ return this->_pb->buf;
|
6734 |
|
|
+}
|
6735 |
|
|
+
|
6736 |
|
|
+
|
6737 |
|
|
+/* json_object_object */
|
6738 |
|
|
+
|
6739 |
|
|
+static int json_object_object_to_json_string(struct json_object* this,
|
6740 |
|
|
+ struct printbuf *pb)
|
6741 |
|
|
+{
|
6742 |
|
|
+ int i=0, j=0;
|
6743 |
|
|
+ struct json_object_iter iter;
|
6744 |
|
|
+
|
6745 |
|
|
+ if(indent)
|
6746 |
|
|
+ {
|
6747 |
|
|
+ // sprintbuf(pb, "\n");
|
6748 |
|
|
+ // for(j=0;j<indentStep*indentDeep;j++)
|
6749 |
|
|
+ //sprintbuf(pb, " ");
|
6750 |
|
|
+ }
|
6751 |
|
|
+ sprintbuf(pb, "{");
|
6752 |
|
|
+
|
6753 |
|
|
+ indentDeep++;
|
6754 |
|
|
+
|
6755 |
|
|
+ /* CAW: scope operator to make ANSI correctness */
|
6756 |
|
|
+ /* CAW: switched to json_object_object_foreachC which uses an iterator struct */
|
6757 |
|
|
+ json_object_object_foreachC(this, iter) {
|
6758 |
|
|
+ if(i) sprintbuf(pb, ",");
|
6759 |
|
|
+ if(indent) sprintbuf(pb, "\n");
|
6760 |
|
|
+ if(indent)
|
6761 |
|
|
+ for(j=0;j<indentStep*indentDeep-1;j++)
|
6762 |
|
|
+ sprintbuf(pb, " ");
|
6763 |
|
|
+ sprintbuf(pb, " \"");
|
6764 |
|
|
+ json_escape_str(pb, iter.key);
|
6765 |
|
|
+ sprintbuf(pb, "\": ");
|
6766 |
|
|
+ if(iter.val == NULL) sprintbuf(pb, "null");
|
6767 |
|
|
+ else
|
6768 |
|
|
+ {
|
6769 |
|
|
+ iter.val->_to_json_string(iter.val, pb);
|
6770 |
|
|
+ //if (json_object_get_type(iter.val) == json_type_object)
|
6771 |
|
|
+ //{
|
6772 |
|
|
+
|
6773 |
|
|
+ //}
|
6774 |
|
|
+ //else if (json_object_get_type(iter.val) == json_type_array)
|
6775 |
|
|
+ //{
|
6776 |
|
|
+
|
6777 |
|
|
+ //}
|
6778 |
|
|
+ }
|
6779 |
|
|
+ i++;
|
6780 |
|
|
+ }
|
6781 |
|
|
+
|
6782 |
|
|
+ indentDeep--;
|
6783 |
|
|
+ if(indent)
|
6784 |
|
|
+ {
|
6785 |
|
|
+ sprintbuf(pb, "\n");
|
6786 |
|
|
+ for(j=0;j<indentStep*indentDeep;j++)
|
6787 |
|
|
+ sprintbuf(pb, " ");
|
6788 |
|
|
+ }
|
6789 |
|
|
+ else
|
6790 |
|
|
+ {
|
6791 |
|
|
+ sprintbuf(pb, " ");
|
6792 |
|
|
+ }
|
6793 |
|
|
+ return sprintbuf(pb, "}");
|
6794 |
|
|
+}
|
6795 |
|
|
+
|
6796 |
|
|
+static void json_object_lh_entry_free(struct lh_entry *ent)
|
6797 |
|
|
+{
|
6798 |
|
|
+ free(ent->k);
|
6799 |
|
|
+ json_object_put((struct json_object*)ent->v);
|
6800 |
|
|
+}
|
6801 |
|
|
+
|
6802 |
|
|
+static void json_object_object_delete(struct json_object* this)
|
6803 |
|
|
+{
|
6804 |
|
|
+ lh_table_free(this->o.c_object);
|
6805 |
|
|
+ json_object_generic_delete(this);
|
6806 |
|
|
+}
|
6807 |
|
|
+
|
6808 |
|
|
+struct json_object* json_object_new_object()
|
6809 |
|
|
+{
|
6810 |
|
|
+ struct json_object *this = json_object_new(json_type_object);
|
6811 |
|
|
+ if(!this) return NULL;
|
6812 |
|
|
+ this->_delete = &json_object_object_delete;
|
6813 |
|
|
+ this->_to_json_string = &json_object_object_to_json_string;
|
6814 |
|
|
+ this->o.c_object = lh_kchar_table_new(JSON_OBJECT_DEF_HASH_ENTIRES,
|
6815 |
|
|
+ NULL, &json_object_lh_entry_free);
|
6816 |
|
|
+ return this;
|
6817 |
|
|
+}
|
6818 |
|
|
+
|
6819 |
|
|
+struct lh_table* json_object_get_object(struct json_object *this)
|
6820 |
|
|
+{
|
6821 |
|
|
+ if(!this) return NULL;
|
6822 |
|
|
+ switch(this->o_type) {
|
6823 |
|
|
+ case json_type_object:
|
6824 |
|
|
+ return this->o.c_object;
|
6825 |
|
|
+ default:
|
6826 |
|
|
+ return NULL;
|
6827 |
|
|
+ }
|
6828 |
|
|
+}
|
6829 |
|
|
+
|
6830 |
|
|
+void json_object_object_add(struct json_object* this, const char *key,
|
6831 |
|
|
+ struct json_object *val)
|
6832 |
|
|
+{
|
6833 |
|
|
+ lh_table_delete(this->o.c_object, key);
|
6834 |
|
|
+ lh_table_insert(this->o.c_object, strdup(key), val);
|
6835 |
|
|
+}
|
6836 |
|
|
+
|
6837 |
|
|
+struct json_object* json_object_object_get(struct json_object* this, const char *key)
|
6838 |
|
|
+{
|
6839 |
|
|
+ return (struct json_object*) lh_table_lookup(this->o.c_object, key);
|
6840 |
|
|
+}
|
6841 |
|
|
+
|
6842 |
|
|
+void json_object_object_del(struct json_object* this, const char *key)
|
6843 |
|
|
+{
|
6844 |
|
|
+ lh_table_delete(this->o.c_object, key);
|
6845 |
|
|
+}
|
6846 |
|
|
+
|
6847 |
|
|
+
|
6848 |
|
|
+/* json_object_boolean */
|
6849 |
|
|
+
|
6850 |
|
|
+static int json_object_boolean_to_json_string(struct json_object* this,
|
6851 |
|
|
+ struct printbuf *pb)
|
6852 |
|
|
+{
|
6853 |
|
|
+ if(this->o.c_boolean) return sprintbuf(pb, "true");
|
6854 |
|
|
+ else return sprintbuf(pb, "false");
|
6855 |
|
|
+}
|
6856 |
|
|
+
|
6857 |
|
|
+struct json_object* json_object_new_boolean(boolean b)
|
6858 |
|
|
+{
|
6859 |
|
|
+ struct json_object *this = json_object_new(json_type_boolean);
|
6860 |
|
|
+ if(!this) return NULL;
|
6861 |
|
|
+ this->_to_json_string = &json_object_boolean_to_json_string;
|
6862 |
|
|
+ this->o.c_boolean = b;
|
6863 |
|
|
+ return this;
|
6864 |
|
|
+}
|
6865 |
|
|
+
|
6866 |
|
|
+boolean json_object_get_boolean(struct json_object *this)
|
6867 |
|
|
+{
|
6868 |
|
|
+ if(!this) return FALSE;
|
6869 |
|
|
+ switch(this->o_type) {
|
6870 |
|
|
+ case json_type_boolean:
|
6871 |
|
|
+ return this->o.c_boolean;
|
6872 |
|
|
+ case json_type_int:
|
6873 |
|
|
+ return (this->o.c_int != 0);
|
6874 |
|
|
+ case json_type_double:
|
6875 |
|
|
+ return (this->o.c_double != 0);
|
6876 |
|
|
+ case json_type_string:
|
6877 |
|
|
+ if(strlen(this->o.c_string)) return TRUE;
|
6878 |
|
|
+ default:
|
6879 |
|
|
+ return TRUE;
|
6880 |
|
|
+ }
|
6881 |
|
|
+}
|
6882 |
|
|
+
|
6883 |
|
|
+
|
6884 |
|
|
+/* json_object_int */
|
6885 |
|
|
+
|
6886 |
|
|
+static int json_object_int_to_json_string(struct json_object* this,
|
6887 |
|
|
+ struct printbuf *pb)
|
6888 |
|
|
+{
|
6889 |
|
|
+ return sprintbuf(pb, "%d", this->o.c_int);
|
6890 |
|
|
+}
|
6891 |
|
|
+
|
6892 |
|
|
+struct json_object* json_object_new_int(int i)
|
6893 |
|
|
+{
|
6894 |
|
|
+ struct json_object *this = json_object_new(json_type_int);
|
6895 |
|
|
+ if(!this) return NULL;
|
6896 |
|
|
+ this->_to_json_string = &json_object_int_to_json_string;
|
6897 |
|
|
+ this->o.c_int = i;
|
6898 |
|
|
+ return this;
|
6899 |
|
|
+}
|
6900 |
|
|
+
|
6901 |
|
|
+int json_object_get_int(struct json_object *this)
|
6902 |
|
|
+{
|
6903 |
|
|
+ int cint;
|
6904 |
|
|
+
|
6905 |
|
|
+ if(!this) return 0;
|
6906 |
|
|
+ switch(this->o_type) {
|
6907 |
|
|
+ case json_type_int:
|
6908 |
|
|
+ return this->o.c_int;
|
6909 |
|
|
+ case json_type_double:
|
6910 |
|
|
+ return (int)this->o.c_double;
|
6911 |
|
|
+ case json_type_boolean:
|
6912 |
|
|
+ return this->o.c_boolean;
|
6913 |
|
|
+ case json_type_string:
|
6914 |
|
|
+ if(sscanf(this->o.c_string, "%d", &cint) == 1) return cint;
|
6915 |
|
|
+ default:
|
6916 |
|
|
+ return 0;
|
6917 |
|
|
+ }
|
6918 |
|
|
+}
|
6919 |
|
|
+
|
6920 |
|
|
+
|
6921 |
|
|
+/* json_object_double */
|
6922 |
|
|
+
|
6923 |
|
|
+static int json_object_double_to_json_string(struct json_object* this,
|
6924 |
|
|
+ struct printbuf *pb)
|
6925 |
|
|
+{
|
6926 |
|
|
+ return sprintbuf(pb, "%lf", this->o.c_double);
|
6927 |
|
|
+}
|
6928 |
|
|
+
|
6929 |
|
|
+struct json_object* json_object_new_double(double d)
|
6930 |
|
|
+{
|
6931 |
|
|
+ struct json_object *this = json_object_new(json_type_double);
|
6932 |
|
|
+ if(!this) return NULL;
|
6933 |
|
|
+ this->_to_json_string = &json_object_double_to_json_string;
|
6934 |
|
|
+ this->o.c_double = d;
|
6935 |
|
|
+ return this;
|
6936 |
|
|
+}
|
6937 |
|
|
+
|
6938 |
|
|
+double json_object_get_double(struct json_object *this)
|
6939 |
|
|
+{
|
6940 |
|
|
+ double cdouble;
|
6941 |
|
|
+
|
6942 |
|
|
+ if(!this) return 0.0;
|
6943 |
|
|
+ switch(this->o_type) {
|
6944 |
|
|
+ case json_type_double:
|
6945 |
|
|
+ return this->o.c_double;
|
6946 |
|
|
+ case json_type_int:
|
6947 |
|
|
+ return this->o.c_int;
|
6948 |
|
|
+ case json_type_boolean:
|
6949 |
|
|
+ return this->o.c_boolean;
|
6950 |
|
|
+ case json_type_string:
|
6951 |
|
|
+ if(sscanf(this->o.c_string, "%lf", &cdouble) == 1) return cdouble;
|
6952 |
|
|
+ default:
|
6953 |
|
|
+ return 0.0;
|
6954 |
|
|
+ }
|
6955 |
|
|
+}
|
6956 |
|
|
+
|
6957 |
|
|
+
|
6958 |
|
|
+/* json_object_string */
|
6959 |
|
|
+
|
6960 |
|
|
+static int json_object_string_to_json_string(struct json_object* this,
|
6961 |
|
|
+ struct printbuf *pb)
|
6962 |
|
|
+{
|
6963 |
|
|
+ sprintbuf(pb, "\"");
|
6964 |
|
|
+ json_escape_str(pb, this->o.c_string);
|
6965 |
|
|
+ sprintbuf(pb, "\"");
|
6966 |
|
|
+ return 0;
|
6967 |
|
|
+}
|
6968 |
|
|
+
|
6969 |
|
|
+static void json_object_string_delete(struct json_object* this)
|
6970 |
|
|
+{
|
6971 |
|
|
+ free(this->o.c_string);
|
6972 |
|
|
+ json_object_generic_delete(this);
|
6973 |
|
|
+}
|
6974 |
|
|
+
|
6975 |
|
|
+struct json_object* json_object_new_string(const char *s)
|
6976 |
|
|
+{
|
6977 |
|
|
+ struct json_object *this = json_object_new(json_type_string);
|
6978 |
|
|
+ if(!this) return NULL;
|
6979 |
|
|
+ this->_delete = &json_object_string_delete;
|
6980 |
|
|
+ this->_to_json_string = &json_object_string_to_json_string;
|
6981 |
|
|
+ this->o.c_string = strdup(s);
|
6982 |
|
|
+ return this;
|
6983 |
|
|
+}
|
6984 |
|
|
+
|
6985 |
|
|
+struct json_object* json_object_new_string_len(const char *s, int len)
|
6986 |
|
|
+{
|
6987 |
|
|
+ struct json_object *this = json_object_new(json_type_string);
|
6988 |
|
|
+ if(!this) return NULL;
|
6989 |
|
|
+ this->_delete = &json_object_string_delete;
|
6990 |
|
|
+ this->_to_json_string = &json_object_string_to_json_string;
|
6991 |
|
|
+ this->o.c_string = strndup(s, len);
|
6992 |
|
|
+ return this;
|
6993 |
|
|
+}
|
6994 |
|
|
+
|
6995 |
|
|
+const char* json_object_get_string(struct json_object *this)
|
6996 |
|
|
+{
|
6997 |
|
|
+ if(!this) return NULL;
|
6998 |
|
|
+ switch(this->o_type) {
|
6999 |
|
|
+ case json_type_string:
|
7000 |
|
|
+ return this->o.c_string;
|
7001 |
|
|
+ default:
|
7002 |
|
|
+ return json_object_to_json_string(this);
|
7003 |
|
|
+ }
|
7004 |
|
|
+}
|
7005 |
|
|
+
|
7006 |
|
|
+
|
7007 |
|
|
+/* json_object_array */
|
7008 |
|
|
+
|
7009 |
|
|
+static int json_object_array_to_json_string(struct json_object* this,
|
7010 |
|
|
+ struct printbuf *pb)
|
7011 |
|
|
+{
|
7012 |
|
|
+ int i,j;
|
7013 |
|
|
+ sprintbuf(pb, "[");
|
7014 |
|
|
+ indentDeep++;
|
7015 |
|
|
+ for(i=0; i < json_object_array_length(this); i++) {
|
7016 |
|
|
+ struct json_object *val;
|
7017 |
|
|
+ if(i) { sprintbuf(pb, ", "); }
|
7018 |
|
|
+ else { sprintbuf(pb, " "); }
|
7019 |
|
|
+ if(indent)
|
7020 |
|
|
+ {
|
7021 |
|
|
+ sprintbuf(pb, "\n");
|
7022 |
|
|
+ for(j=0;j<indentDeep*indentStep;j++)
|
7023 |
|
|
+ sprintbuf(pb, " ");
|
7024 |
|
|
+ }
|
7025 |
|
|
+ val = json_object_array_get_idx(this, i);
|
7026 |
|
|
+ if(val == NULL) { sprintbuf(pb, "null"); }
|
7027 |
|
|
+ else { val->_to_json_string(val, pb); }
|
7028 |
|
|
+ }
|
7029 |
|
|
+ indentDeep--;
|
7030 |
|
|
+ if(indent)
|
7031 |
|
|
+ {
|
7032 |
|
|
+ sprintbuf(pb, "\n");
|
7033 |
|
|
+ for(j=0;j<indentDeep*indentStep;j++)
|
7034 |
|
|
+ sprintbuf(pb, " ");
|
7035 |
|
|
+ }
|
7036 |
|
|
+ else
|
7037 |
|
|
+ sprintbuf(pb, " ");
|
7038 |
|
|
+ return sprintbuf(pb, "]");
|
7039 |
|
|
+}
|
7040 |
|
|
+
|
7041 |
|
|
+static void json_object_array_entry_free(void *data)
|
7042 |
|
|
+{
|
7043 |
|
|
+ json_object_put((struct json_object*)data);
|
7044 |
|
|
+}
|
7045 |
|
|
+
|
7046 |
|
|
+static void json_object_array_delete(struct json_object* this)
|
7047 |
|
|
+{
|
7048 |
|
|
+ array_list_free(this->o.c_array);
|
7049 |
|
|
+ json_object_generic_delete(this);
|
7050 |
|
|
+}
|
7051 |
|
|
+
|
7052 |
|
|
+struct json_object* json_object_new_array()
|
7053 |
|
|
+{
|
7054 |
|
|
+ struct json_object *this = json_object_new(json_type_array);
|
7055 |
|
|
+ if(!this) return NULL;
|
7056 |
|
|
+ this->_delete = &json_object_array_delete;
|
7057 |
|
|
+ this->_to_json_string = &json_object_array_to_json_string;
|
7058 |
|
|
+ this->o.c_array = array_list_new(&json_object_array_entry_free);
|
7059 |
|
|
+ return this;
|
7060 |
|
|
+}
|
7061 |
|
|
+
|
7062 |
|
|
+struct array_list* json_object_get_array(struct json_object *this)
|
7063 |
|
|
+{
|
7064 |
|
|
+ if(!this) return NULL;
|
7065 |
|
|
+ switch(this->o_type) {
|
7066 |
|
|
+ case json_type_array:
|
7067 |
|
|
+ return this->o.c_array;
|
7068 |
|
|
+ default:
|
7069 |
|
|
+ return NULL;
|
7070 |
|
|
+ }
|
7071 |
|
|
+}
|
7072 |
|
|
+
|
7073 |
|
|
+int json_object_array_length(struct json_object *this)
|
7074 |
|
|
+{
|
7075 |
|
|
+ return array_list_length(this->o.c_array);
|
7076 |
|
|
+}
|
7077 |
|
|
+
|
7078 |
|
|
+int json_object_array_add(struct json_object *this,struct json_object *val)
|
7079 |
|
|
+{
|
7080 |
|
|
+ return array_list_add(this->o.c_array, val);
|
7081 |
|
|
+}
|
7082 |
|
|
+
|
7083 |
|
|
+int json_object_array_put_idx(struct json_object *this, int idx,
|
7084 |
|
|
+ struct json_object *val)
|
7085 |
|
|
+{
|
7086 |
|
|
+ return array_list_put_idx(this->o.c_array, idx, val);
|
7087 |
|
|
+}
|
7088 |
|
|
+
|
7089 |
|
|
+struct json_object* json_object_array_get_idx(struct json_object *this,
|
7090 |
|
|
+ int idx)
|
7091 |
|
|
+{
|
7092 |
|
|
+ return (struct json_object*)array_list_get_idx(this->o.c_array, idx);
|
7093 |
|
|
+}
|
7094 |
|
|
+
|
7095 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/json_object.h sdcc-src-3.1.0-pblaze/src/json/json/json_object.h
|
7096 |
|
|
--- sdcc-src-3.1.0/src/json/json/json_object.h 1970-01-01 01:00:00.000000000 +0100
|
7097 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/json_object.h 2011-02-07 20:04:46.000000000 +0100
|
7098 |
|
|
@@ -0,0 +1,316 @@
|
7099 |
|
|
+/*
|
7100 |
|
|
+ * $Id: json_object.h,v 1.12 2006/01/30 23:07:57 mclark Exp $
|
7101 |
|
|
+ *
|
7102 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
7103 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
7104 |
|
|
+ *
|
7105 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
7106 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
7107 |
|
|
+ *
|
7108 |
|
|
+ */
|
7109 |
|
|
+
|
7110 |
|
|
+#ifndef _json_object_h_
|
7111 |
|
|
+#define _json_object_h_
|
7112 |
|
|
+
|
7113 |
|
|
+#define JSON_OBJECT_DEF_HASH_ENTIRES 16
|
7114 |
|
|
+
|
7115 |
|
|
+//#undef FALSE
|
7116 |
|
|
+//#define FALSE ((boolean)0)
|
7117 |
|
|
+
|
7118 |
|
|
+//#undef TRUE
|
7119 |
|
|
+//#define TRUE ((boolean)1)
|
7120 |
|
|
+
|
7121 |
|
|
+extern const char *json_number_chars;
|
7122 |
|
|
+extern const char *json_hex_chars;
|
7123 |
|
|
+extern int indent;
|
7124 |
|
|
+extern int indentDeep;
|
7125 |
|
|
+extern int indentStep;
|
7126 |
|
|
+
|
7127 |
|
|
+/* forward structure definitions */
|
7128 |
|
|
+
|
7129 |
|
|
+typedef int boolean;
|
7130 |
|
|
+struct printbuf;
|
7131 |
|
|
+struct lh_table;
|
7132 |
|
|
+struct array_list;
|
7133 |
|
|
+struct json_object;
|
7134 |
|
|
+struct json_object_iter;
|
7135 |
|
|
+
|
7136 |
|
|
+/* supported object types */
|
7137 |
|
|
+
|
7138 |
|
|
+enum json_type {
|
7139 |
|
|
+ json_type_null,
|
7140 |
|
|
+ json_type_boolean,
|
7141 |
|
|
+ json_type_double,
|
7142 |
|
|
+ json_type_int,
|
7143 |
|
|
+ json_type_object,
|
7144 |
|
|
+ json_type_array,
|
7145 |
|
|
+ json_type_string
|
7146 |
|
|
+};
|
7147 |
|
|
+
|
7148 |
|
|
+//static void json_object_init(void);
|
7149 |
|
|
+//static void json_object_fini(void);
|
7150 |
|
|
+
|
7151 |
|
|
+/* reference counting functions */
|
7152 |
|
|
+
|
7153 |
|
|
+/**
|
7154 |
|
|
+ * Increment the reference count of json_object
|
7155 |
|
|
+ * @param obj the json_object instance
|
7156 |
|
|
+ */
|
7157 |
|
|
+extern struct json_object* json_object_get(struct json_object *obj);
|
7158 |
|
|
+
|
7159 |
|
|
+/**
|
7160 |
|
|
+ * Decrement the reference count of json_object and free if it reaches zero
|
7161 |
|
|
+ * @param obj the json_object instance
|
7162 |
|
|
+ */
|
7163 |
|
|
+extern void json_object_put(struct json_object *obj);
|
7164 |
|
|
+
|
7165 |
|
|
+
|
7166 |
|
|
+/**
|
7167 |
|
|
+ * Check if the json_object is of a given type
|
7168 |
|
|
+ * @param obj the json_object instance
|
7169 |
|
|
+ * @param type one of:
|
7170 |
|
|
+ json_type_boolean,
|
7171 |
|
|
+ json_type_double,
|
7172 |
|
|
+ json_type_int,
|
7173 |
|
|
+ json_type_object,
|
7174 |
|
|
+ json_type_array,
|
7175 |
|
|
+ json_type_string,
|
7176 |
|
|
+ */
|
7177 |
|
|
+extern int json_object_is_type(struct json_object *obj, enum json_type type);
|
7178 |
|
|
+
|
7179 |
|
|
+/**
|
7180 |
|
|
+ * Get the type of the json_object
|
7181 |
|
|
+ * @param obj the json_object instance
|
7182 |
|
|
+ * @returns type being one of:
|
7183 |
|
|
+ json_type_boolean,
|
7184 |
|
|
+ json_type_double,
|
7185 |
|
|
+ json_type_int,
|
7186 |
|
|
+ json_type_object,
|
7187 |
|
|
+ json_type_array,
|
7188 |
|
|
+ json_type_string,
|
7189 |
|
|
+ */
|
7190 |
|
|
+extern enum json_type json_object_get_type(struct json_object *obj);
|
7191 |
|
|
+
|
7192 |
|
|
+
|
7193 |
|
|
+/** Stringify object to json format
|
7194 |
|
|
+ * @param obj the json_object instance
|
7195 |
|
|
+ * @returns a string in JSON format
|
7196 |
|
|
+ */
|
7197 |
|
|
+extern const char* json_object_to_json_string(struct json_object *obj);
|
7198 |
|
|
+
|
7199 |
|
|
+
|
7200 |
|
|
+/* object type methods */
|
7201 |
|
|
+
|
7202 |
|
|
+/** Create a new empty object
|
7203 |
|
|
+ * @returns a json_object of type json_type_object
|
7204 |
|
|
+ */
|
7205 |
|
|
+extern struct json_object* json_object_new_object(void);
|
7206 |
|
|
+
|
7207 |
|
|
+/** Get the hashtable of a json_object of type json_type_object
|
7208 |
|
|
+ * @param obj the json_object instance
|
7209 |
|
|
+ * @returns a linkhash
|
7210 |
|
|
+ */
|
7211 |
|
|
+extern struct lh_table* json_object_get_object(struct json_object *obj);
|
7212 |
|
|
+
|
7213 |
|
|
+/** Add an object field to a json_object of type json_type_object
|
7214 |
|
|
+ *
|
7215 |
|
|
+ * The reference count will *not* be incremented. This is to make adding
|
7216 |
|
|
+ * fields to objects in code more compact. If you want to retain a reference
|
7217 |
|
|
+ * to an added object you must wrap the passed object with json_object_get
|
7218 |
|
|
+ *
|
7219 |
|
|
+ * @param obj the json_object instance
|
7220 |
|
|
+ * @param key the object field name (a private copy will be duplicated)
|
7221 |
|
|
+ * @param val a json_object or NULL member to associate with the given field
|
7222 |
|
|
+ */
|
7223 |
|
|
+extern void json_object_object_add(struct json_object* obj, const char *key,
|
7224 |
|
|
+ struct json_object *val);
|
7225 |
|
|
+
|
7226 |
|
|
+/** Get the json_object associate with a given object field
|
7227 |
|
|
+ * @param obj the json_object instance
|
7228 |
|
|
+ * @param key the object field name
|
7229 |
|
|
+ * @returns the json_object associated with the given field name
|
7230 |
|
|
+ */
|
7231 |
|
|
+extern struct json_object* json_object_object_get(struct json_object* obj,
|
7232 |
|
|
+ const char *key);
|
7233 |
|
|
+
|
7234 |
|
|
+/** Delete the given json_object field
|
7235 |
|
|
+ *
|
7236 |
|
|
+ * The reference count will be decremented for the deleted object
|
7237 |
|
|
+ *
|
7238 |
|
|
+ * @param obj the json_object instance
|
7239 |
|
|
+ * @param key the object field name
|
7240 |
|
|
+ */
|
7241 |
|
|
+extern void json_object_object_del(struct json_object* obj, const char *key);
|
7242 |
|
|
+
|
7243 |
|
|
+/** Iterate through all keys and values of an object
|
7244 |
|
|
+ * @param obj the json_object instance
|
7245 |
|
|
+ * @param key the local name for the char* key variable defined in the body
|
7246 |
|
|
+ * @param val the local name for the json_object* object variable defined in the body
|
7247 |
|
|
+ */
|
7248 |
|
|
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
7249 |
|
|
+
|
7250 |
|
|
+# define json_object_object_foreach(obj,key,val) \
|
7251 |
|
|
+ char *key; struct json_object *val; \
|
7252 |
|
|
+ for(struct lh_entry *entry = json_object_get_object(obj)->head; ({ if(entry) { key = (char*)entry->k; val = (struct json_object*)entry->v; } ; entry; }); entry = entry->next )
|
7253 |
|
|
+
|
7254 |
|
|
+#else /* ANSI C or MSC */
|
7255 |
|
|
+
|
7256 |
|
|
+#define json_object_object_foreach(obj,key,val) \
|
7257 |
|
|
+ char *key; struct json_object *val; struct lh_entry *entry; \
|
7258 |
|
|
+ for(entry = json_object_get_object(obj)->head; (entry ? (key = (char*)entry->k, val = (struct json_object*)entry->v, entry) : 0); entry = entry->next)
|
7259 |
|
|
+
|
7260 |
|
|
+#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) */
|
7261 |
|
|
+
|
7262 |
|
|
+/** Iterate through all keys and values of an object (ANSI C Safe)
|
7263 |
|
|
+ * @param obj the json_object instance
|
7264 |
|
|
+ * @param iter the object iterator
|
7265 |
|
|
+ */
|
7266 |
|
|
+#define json_object_object_foreachC(obj,iter) \
|
7267 |
|
|
+ for(iter.entry = json_object_get_object(obj)->head; (iter.entry ? (iter.key = (char*)iter.entry->k, iter.val = (struct json_object*)iter.entry->v, iter.entry) : 0); iter.entry = iter.entry->next)
|
7268 |
|
|
+
|
7269 |
|
|
+/* Array type methods */
|
7270 |
|
|
+
|
7271 |
|
|
+/** Create a new empty json_object of type json_type_array
|
7272 |
|
|
+ * @returns a json_object of type json_type_array
|
7273 |
|
|
+ */
|
7274 |
|
|
+extern struct json_object* json_object_new_array(void);
|
7275 |
|
|
+
|
7276 |
|
|
+/** Get the arraylist of a json_object of type json_type_array
|
7277 |
|
|
+ * @param obj the json_object instance
|
7278 |
|
|
+ * @returns an arraylist
|
7279 |
|
|
+ */
|
7280 |
|
|
+extern struct array_list* json_object_get_array(struct json_object *obj);
|
7281 |
|
|
+
|
7282 |
|
|
+/** Get the length of a json_object of type json_type_array
|
7283 |
|
|
+ * @param obj the json_object instance
|
7284 |
|
|
+ * @returns an int
|
7285 |
|
|
+ */
|
7286 |
|
|
+extern int json_object_array_length(struct json_object *obj);
|
7287 |
|
|
+
|
7288 |
|
|
+/** Add an element to the end of a json_object of type json_type_array
|
7289 |
|
|
+ *
|
7290 |
|
|
+ * The reference count will *not* be incremented. This is to make adding
|
7291 |
|
|
+ * fields to objects in code more compact. If you want to retain a reference
|
7292 |
|
|
+ * to an added object you must wrap the passed object with json_object_get
|
7293 |
|
|
+ *
|
7294 |
|
|
+ * @param obj the json_object instance
|
7295 |
|
|
+ * @param val the json_object to be added
|
7296 |
|
|
+ */
|
7297 |
|
|
+extern int json_object_array_add(struct json_object *obj,
|
7298 |
|
|
+ struct json_object *val);
|
7299 |
|
|
+
|
7300 |
|
|
+/** Insert or replace an element at a specified index in an array (a json_object of type json_type_array)
|
7301 |
|
|
+ *
|
7302 |
|
|
+ * The reference count will *not* be incremented. This is to make adding
|
7303 |
|
|
+ * fields to objects in code more compact. If you want to retain a reference
|
7304 |
|
|
+ * to an added object you must wrap the passed object with json_object_get
|
7305 |
|
|
+ *
|
7306 |
|
|
+ * The reference count of a replaced object will be decremented.
|
7307 |
|
|
+ *
|
7308 |
|
|
+ * The array size will be automatically be expanded to the size of the
|
7309 |
|
|
+ * index if the index is larger than the current size.
|
7310 |
|
|
+ *
|
7311 |
|
|
+ * @param obj the json_object instance
|
7312 |
|
|
+ * @param idx the index to insert the element at
|
7313 |
|
|
+ * @param val the json_object to be added
|
7314 |
|
|
+ */
|
7315 |
|
|
+extern int json_object_array_put_idx(struct json_object *obj, int idx,
|
7316 |
|
|
+ struct json_object *val);
|
7317 |
|
|
+
|
7318 |
|
|
+/** Get the element at specificed index of the array (a json_object of type json_type_array)
|
7319 |
|
|
+ * @param obj the json_object instance
|
7320 |
|
|
+ * @param idx the index to get the element at
|
7321 |
|
|
+ * @returns the json_object at the specified index (or NULL)
|
7322 |
|
|
+ */
|
7323 |
|
|
+extern struct json_object* json_object_array_get_idx(struct json_object *obj,
|
7324 |
|
|
+ int idx);
|
7325 |
|
|
+
|
7326 |
|
|
+/* boolean type methods */
|
7327 |
|
|
+
|
7328 |
|
|
+/** Create a new empty json_object of type json_type_boolean
|
7329 |
|
|
+ * @param b a boolean TRUE or FALSE (0 or 1)
|
7330 |
|
|
+ * @returns a json_object of type json_type_boolean
|
7331 |
|
|
+ */
|
7332 |
|
|
+extern struct json_object* json_object_new_boolean(boolean b);
|
7333 |
|
|
+
|
7334 |
|
|
+/** Get the boolean value of a json_object
|
7335 |
|
|
+ *
|
7336 |
|
|
+ * The type is coerced to a boolean if the passed object is not a boolean.
|
7337 |
|
|
+ * integer and double objects will return FALSE if there value is zero
|
7338 |
|
|
+ * or TRUE otherwise. If the passed object is a string it will return
|
7339 |
|
|
+ * TRUE if it has a non zero length. If any other object type is passed
|
7340 |
|
|
+ * TRUE will be returned if the object is not NULL.
|
7341 |
|
|
+ *
|
7342 |
|
|
+ * @param obj the json_object instance
|
7343 |
|
|
+ * @returns a boolean
|
7344 |
|
|
+ */
|
7345 |
|
|
+extern boolean json_object_get_boolean(struct json_object *obj);
|
7346 |
|
|
+
|
7347 |
|
|
+
|
7348 |
|
|
+/* int type methods */
|
7349 |
|
|
+
|
7350 |
|
|
+/** Create a new empty json_object of type json_type_int
|
7351 |
|
|
+ * @param i the integer
|
7352 |
|
|
+ * @returns a json_object of type json_type_int
|
7353 |
|
|
+ */
|
7354 |
|
|
+extern struct json_object* json_object_new_int(int i);
|
7355 |
|
|
+
|
7356 |
|
|
+/** Get the int value of a json_object
|
7357 |
|
|
+ *
|
7358 |
|
|
+ * The type is coerced to a int if the passed object is not a int.
|
7359 |
|
|
+ * double objects will return their integer conversion. Strings will be
|
7360 |
|
|
+ * parsed as an integer. If no conversion exists then 0 is returned.
|
7361 |
|
|
+ *
|
7362 |
|
|
+ * @param obj the json_object instance
|
7363 |
|
|
+ * @returns an int
|
7364 |
|
|
+ */
|
7365 |
|
|
+extern int json_object_get_int(struct json_object *obj);
|
7366 |
|
|
+
|
7367 |
|
|
+
|
7368 |
|
|
+/* double type methods */
|
7369 |
|
|
+
|
7370 |
|
|
+/** Create a new empty json_object of type json_type_double
|
7371 |
|
|
+ * @param d the double
|
7372 |
|
|
+ * @returns a json_object of type json_type_double
|
7373 |
|
|
+ */
|
7374 |
|
|
+extern struct json_object* json_object_new_double(double d);
|
7375 |
|
|
+
|
7376 |
|
|
+/** Get the double value of a json_object
|
7377 |
|
|
+ *
|
7378 |
|
|
+ * The type is coerced to a double if the passed object is not a double.
|
7379 |
|
|
+ * integer objects will return their dboule conversion. Strings will be
|
7380 |
|
|
+ * parsed as a double. If no conversion exists then 0.0 is returned.
|
7381 |
|
|
+ *
|
7382 |
|
|
+ * @param obj the json_object instance
|
7383 |
|
|
+ * @returns an double
|
7384 |
|
|
+ */
|
7385 |
|
|
+extern double json_object_get_double(struct json_object *obj);
|
7386 |
|
|
+
|
7387 |
|
|
+
|
7388 |
|
|
+/* string type methods */
|
7389 |
|
|
+
|
7390 |
|
|
+/** Create a new empty json_object of type json_type_string
|
7391 |
|
|
+ *
|
7392 |
|
|
+ * A copy of the string is made and the memory is managed by the json_object
|
7393 |
|
|
+ *
|
7394 |
|
|
+ * @param s the string
|
7395 |
|
|
+ * @returns a json_object of type json_type_string
|
7396 |
|
|
+ */
|
7397 |
|
|
+extern struct json_object* json_object_new_string(const char *s);
|
7398 |
|
|
+
|
7399 |
|
|
+extern struct json_object* json_object_new_string_len(const char *s, int len);
|
7400 |
|
|
+
|
7401 |
|
|
+/** Get the string value of a json_object
|
7402 |
|
|
+ *
|
7403 |
|
|
+ * If the passed object is not of type json_type_string then the JSON
|
7404 |
|
|
+ * representation of the object is returned.
|
7405 |
|
|
+ *
|
7406 |
|
|
+ * The returned string memory is managed by the json_object and will
|
7407 |
|
|
+ * be freed when the reference count of the json_object drops to zero.
|
7408 |
|
|
+ *
|
7409 |
|
|
+ * @param obj the json_object instance
|
7410 |
|
|
+ * @returns a string
|
7411 |
|
|
+ */
|
7412 |
|
|
+extern const char* json_object_get_string(struct json_object *obj);
|
7413 |
|
|
+
|
7414 |
|
|
+#endif
|
7415 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/json_object_private.h sdcc-src-3.1.0-pblaze/src/json/json/json_object_private.h
|
7416 |
|
|
--- sdcc-src-3.1.0/src/json/json/json_object_private.h 1970-01-01 01:00:00.000000000 +0100
|
7417 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/json_object_private.h 2011-02-07 20:04:44.000000000 +0100
|
7418 |
|
|
@@ -0,0 +1,44 @@
|
7419 |
|
|
+/*
|
7420 |
|
|
+ * $Id: json_object_private.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
|
7421 |
|
|
+ *
|
7422 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
7423 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
7424 |
|
|
+ *
|
7425 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
7426 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
7427 |
|
|
+ *
|
7428 |
|
|
+ */
|
7429 |
|
|
+
|
7430 |
|
|
+#ifndef _json_object_private_h_
|
7431 |
|
|
+#define _json_object_private_h_
|
7432 |
|
|
+
|
7433 |
|
|
+typedef void (json_object_delete_fn)(struct json_object *o);
|
7434 |
|
|
+typedef int (json_object_to_json_string_fn)(struct json_object *o,
|
7435 |
|
|
+ struct printbuf *pb);
|
7436 |
|
|
+
|
7437 |
|
|
+struct json_object
|
7438 |
|
|
+{
|
7439 |
|
|
+ enum json_type o_type;
|
7440 |
|
|
+ json_object_delete_fn *_delete;
|
7441 |
|
|
+ json_object_to_json_string_fn *_to_json_string;
|
7442 |
|
|
+ int _ref_count;
|
7443 |
|
|
+ struct printbuf *_pb;
|
7444 |
|
|
+ union data {
|
7445 |
|
|
+ boolean c_boolean;
|
7446 |
|
|
+ double c_double;
|
7447 |
|
|
+ int c_int;
|
7448 |
|
|
+ struct lh_table *c_object;
|
7449 |
|
|
+ struct array_list *c_array;
|
7450 |
|
|
+ char *c_string;
|
7451 |
|
|
+ } o;
|
7452 |
|
|
+};
|
7453 |
|
|
+
|
7454 |
|
|
+/* CAW: added for ANSI C iteration correctness */
|
7455 |
|
|
+struct json_object_iter
|
7456 |
|
|
+{
|
7457 |
|
|
+ char *key;
|
7458 |
|
|
+ struct json_object *val;
|
7459 |
|
|
+ struct lh_entry *entry;
|
7460 |
|
|
+};
|
7461 |
|
|
+
|
7462 |
|
|
+#endif
|
7463 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/json_tokener.c sdcc-src-3.1.0-pblaze/src/json/json/json_tokener.c
|
7464 |
|
|
--- sdcc-src-3.1.0/src/json/json/json_tokener.c 1970-01-01 01:00:00.000000000 +0100
|
7465 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/json_tokener.c 2011-02-07 20:04:46.000000000 +0100
|
7466 |
|
|
@@ -0,0 +1,517 @@
|
7467 |
|
|
+/*
|
7468 |
|
|
+ * $Id: json_tokener.c,v 1.20 2006/07/25 03:24:50 mclark Exp $
|
7469 |
|
|
+ *
|
7470 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
7471 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
7472 |
|
|
+ *
|
7473 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
7474 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
7475 |
|
|
+ *
|
7476 |
|
|
+ */
|
7477 |
|
|
+
|
7478 |
|
|
+#include "config.h"
|
7479 |
|
|
+
|
7480 |
|
|
+#include <stdio.h>
|
7481 |
|
|
+#include <stdlib.h>
|
7482 |
|
|
+#include <stddef.h>
|
7483 |
|
|
+#include <ctype.h>
|
7484 |
|
|
+#include <string.h>
|
7485 |
|
|
+
|
7486 |
|
|
+#include "bits.h"
|
7487 |
|
|
+#include "debug.h"
|
7488 |
|
|
+#include "printbuf.h"
|
7489 |
|
|
+#include "arraylist.h"
|
7490 |
|
|
+#include "json_object.h"
|
7491 |
|
|
+#include "json_tokener.h"
|
7492 |
|
|
+
|
7493 |
|
|
+
|
7494 |
|
|
+#if !HAVE_STRNCASECMP && defined(_MSC_VER)
|
7495 |
|
|
+ /* MSC has the version as _strnicmp */
|
7496 |
|
|
+# define strncasecmp _strnicmp
|
7497 |
|
|
+#elif !HAVE_STRNCASECMP
|
7498 |
|
|
+# error You do not have strncasecmp on your system.
|
7499 |
|
|
+#endif /* HAVE_STRNCASECMP */
|
7500 |
|
|
+
|
7501 |
|
|
+
|
7502 |
|
|
+static const char* json_null_str = "null";
|
7503 |
|
|
+static const char* json_true_str = "true";
|
7504 |
|
|
+static const char* json_false_str = "false";
|
7505 |
|
|
+
|
7506 |
|
|
+const char* json_tokener_errors[] = {
|
7507 |
|
|
+ "success",
|
7508 |
|
|
+ "continue",
|
7509 |
|
|
+ "nesting to deep",
|
7510 |
|
|
+ "unexpected end of data",
|
7511 |
|
|
+ "unexpected character",
|
7512 |
|
|
+ "null expected",
|
7513 |
|
|
+ "boolean expected",
|
7514 |
|
|
+ "number expected",
|
7515 |
|
|
+ "array value separator ',' expected",
|
7516 |
|
|
+ "quoted object property name expected",
|
7517 |
|
|
+ "object property name separator ':' expected",
|
7518 |
|
|
+ "object value separator ',' expected",
|
7519 |
|
|
+ "invalid string sequence",
|
7520 |
|
|
+ "expected comment",
|
7521 |
|
|
+};
|
7522 |
|
|
+
|
7523 |
|
|
+
|
7524 |
|
|
+struct json_tokener* json_tokener_new()
|
7525 |
|
|
+{
|
7526 |
|
|
+ struct json_tokener *tok = calloc(1, sizeof(struct json_tokener));
|
7527 |
|
|
+ tok->pb = printbuf_new();
|
7528 |
|
|
+ json_tokener_reset(tok);
|
7529 |
|
|
+ return tok;
|
7530 |
|
|
+}
|
7531 |
|
|
+
|
7532 |
|
|
+void json_tokener_free(struct json_tokener *tok)
|
7533 |
|
|
+{
|
7534 |
|
|
+ json_tokener_reset(tok);
|
7535 |
|
|
+ if(tok) printbuf_free(tok->pb);
|
7536 |
|
|
+ free(tok);
|
7537 |
|
|
+}
|
7538 |
|
|
+
|
7539 |
|
|
+static void json_tokener_reset_level(struct json_tokener *tok, int depth)
|
7540 |
|
|
+{
|
7541 |
|
|
+ tok->stack[depth].state = json_tokener_state_eatws;
|
7542 |
|
|
+ tok->stack[depth].saved_state = json_tokener_state_start;
|
7543 |
|
|
+ json_object_put(tok->stack[depth].current);
|
7544 |
|
|
+ tok->stack[depth].current = NULL;
|
7545 |
|
|
+ free(tok->stack[depth].obj_field_name);
|
7546 |
|
|
+ tok->stack[depth].obj_field_name = NULL;
|
7547 |
|
|
+}
|
7548 |
|
|
+
|
7549 |
|
|
+void json_tokener_reset(struct json_tokener *tok)
|
7550 |
|
|
+{
|
7551 |
|
|
+ int i;
|
7552 |
|
|
+ for(i = tok->depth; i >= 0; i--)
|
7553 |
|
|
+ json_tokener_reset_level(tok, i);
|
7554 |
|
|
+ tok->depth = 0;
|
7555 |
|
|
+ tok->err = json_tokener_success;
|
7556 |
|
|
+}
|
7557 |
|
|
+
|
7558 |
|
|
+struct json_object* json_tokener_parse(char *str)
|
7559 |
|
|
+{
|
7560 |
|
|
+ struct json_tokener* tok;
|
7561 |
|
|
+ struct json_object* obj;
|
7562 |
|
|
+
|
7563 |
|
|
+ tok = json_tokener_new();
|
7564 |
|
|
+ obj = json_tokener_parse_ex(tok, str, -1);
|
7565 |
|
|
+ if(tok->err != json_tokener_success)
|
7566 |
|
|
+ obj = error_ptr(-tok->err);
|
7567 |
|
|
+ json_tokener_free(tok);
|
7568 |
|
|
+ return obj;
|
7569 |
|
|
+}
|
7570 |
|
|
+
|
7571 |
|
|
+
|
7572 |
|
|
+#if !HAVE_STRNDUP
|
7573 |
|
|
+/* CAW: compliant version of strndup() */
|
7574 |
|
|
+char* strndup(const char* str, size_t n)
|
7575 |
|
|
+{
|
7576 |
|
|
+ if(str) {
|
7577 |
|
|
+ size_t len = strlen(str);
|
7578 |
|
|
+ size_t nn = min(len,n);
|
7579 |
|
|
+ char* s = (char*)malloc(sizeof(char) * (nn + 1));
|
7580 |
|
|
+
|
7581 |
|
|
+ if(s) {
|
7582 |
|
|
+ memcpy(s, str, nn);
|
7583 |
|
|
+ s[nn] = '\0';
|
7584 |
|
|
+ }
|
7585 |
|
|
+
|
7586 |
|
|
+ return s;
|
7587 |
|
|
+ }
|
7588 |
|
|
+
|
7589 |
|
|
+ return NULL;
|
7590 |
|
|
+}
|
7591 |
|
|
+#endif
|
7592 |
|
|
+
|
7593 |
|
|
+
|
7594 |
|
|
+#define state tok->stack[tok->depth].state
|
7595 |
|
|
+#define saved_state tok->stack[tok->depth].saved_state
|
7596 |
|
|
+#define current tok->stack[tok->depth].current
|
7597 |
|
|
+#define obj_field_name tok->stack[tok->depth].obj_field_name
|
7598 |
|
|
+
|
7599 |
|
|
+struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
7600 |
|
|
+ char *str, int len)
|
7601 |
|
|
+{
|
7602 |
|
|
+ struct json_object *obj = NULL;
|
7603 |
|
|
+ char c;
|
7604 |
|
|
+
|
7605 |
|
|
+ tok->char_offset = 0;
|
7606 |
|
|
+ tok->err = json_tokener_success;
|
7607 |
|
|
+
|
7608 |
|
|
+ do {
|
7609 |
|
|
+ if(tok->char_offset == len) {
|
7610 |
|
|
+ if(tok->depth == 0 && state == json_tokener_state_eatws &&
|
7611 |
|
|
+ saved_state == json_tokener_state_finish)
|
7612 |
|
|
+ tok->err = json_tokener_success;
|
7613 |
|
|
+ else
|
7614 |
|
|
+ tok->err = json_tokener_continue;
|
7615 |
|
|
+ goto out;
|
7616 |
|
|
+ }
|
7617 |
|
|
+
|
7618 |
|
|
+ c = *str;
|
7619 |
|
|
+ redo_char:
|
7620 |
|
|
+ switch(state) {
|
7621 |
|
|
+
|
7622 |
|
|
+ case json_tokener_state_eatws:
|
7623 |
|
|
+ if(isspace(c)) {
|
7624 |
|
|
+ /* okay */
|
7625 |
|
|
+ } else if(c == '/') {
|
7626 |
|
|
+ printbuf_reset(tok->pb);
|
7627 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7628 |
|
|
+ state = json_tokener_state_comment_start;
|
7629 |
|
|
+ } else {
|
7630 |
|
|
+ state = saved_state;
|
7631 |
|
|
+ goto redo_char;
|
7632 |
|
|
+ }
|
7633 |
|
|
+ break;
|
7634 |
|
|
+
|
7635 |
|
|
+ case json_tokener_state_start:
|
7636 |
|
|
+ switch(c) {
|
7637 |
|
|
+ case '{':
|
7638 |
|
|
+ state = json_tokener_state_eatws;
|
7639 |
|
|
+ saved_state = json_tokener_state_object_field_start;
|
7640 |
|
|
+ current = json_object_new_object();
|
7641 |
|
|
+ break;
|
7642 |
|
|
+ case '[':
|
7643 |
|
|
+ state = json_tokener_state_eatws;
|
7644 |
|
|
+ saved_state = json_tokener_state_array;
|
7645 |
|
|
+ current = json_object_new_array();
|
7646 |
|
|
+ break;
|
7647 |
|
|
+ case 'N':
|
7648 |
|
|
+ case 'n':
|
7649 |
|
|
+ state = json_tokener_state_null;
|
7650 |
|
|
+ printbuf_reset(tok->pb);
|
7651 |
|
|
+ tok->st_pos = 0;
|
7652 |
|
|
+ goto redo_char;
|
7653 |
|
|
+ case '"':
|
7654 |
|
|
+ case '\'':
|
7655 |
|
|
+ state = json_tokener_state_string;
|
7656 |
|
|
+ printbuf_reset(tok->pb);
|
7657 |
|
|
+ tok->quote_char = c;
|
7658 |
|
|
+ break;
|
7659 |
|
|
+ case 'T':
|
7660 |
|
|
+ case 't':
|
7661 |
|
|
+ case 'F':
|
7662 |
|
|
+ case 'f':
|
7663 |
|
|
+ state = json_tokener_state_boolean;
|
7664 |
|
|
+ printbuf_reset(tok->pb);
|
7665 |
|
|
+ tok->st_pos = 0;
|
7666 |
|
|
+ goto redo_char;
|
7667 |
|
|
+#if defined(__GNUC__)
|
7668 |
|
|
+ case '0' ... '9':
|
7669 |
|
|
+#else
|
7670 |
|
|
+ case '0':
|
7671 |
|
|
+ case '1':
|
7672 |
|
|
+ case '2':
|
7673 |
|
|
+ case '3':
|
7674 |
|
|
+ case '4':
|
7675 |
|
|
+ case '5':
|
7676 |
|
|
+ case '6':
|
7677 |
|
|
+ case '7':
|
7678 |
|
|
+ case '8':
|
7679 |
|
|
+ case '9':
|
7680 |
|
|
+#endif
|
7681 |
|
|
+ case '-':
|
7682 |
|
|
+ state = json_tokener_state_number;
|
7683 |
|
|
+ printbuf_reset(tok->pb);
|
7684 |
|
|
+ tok->is_double = 0;
|
7685 |
|
|
+ goto redo_char;
|
7686 |
|
|
+ default:
|
7687 |
|
|
+ tok->err = json_tokener_error_parse_unexpected;
|
7688 |
|
|
+ goto out;
|
7689 |
|
|
+ }
|
7690 |
|
|
+ break;
|
7691 |
|
|
+
|
7692 |
|
|
+ case json_tokener_state_finish:
|
7693 |
|
|
+ if(tok->depth == 0) goto out;
|
7694 |
|
|
+ obj = json_object_get(current);
|
7695 |
|
|
+ json_tokener_reset_level(tok, tok->depth);
|
7696 |
|
|
+ tok->depth--;
|
7697 |
|
|
+ goto redo_char;
|
7698 |
|
|
+
|
7699 |
|
|
+ case json_tokener_state_null:
|
7700 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7701 |
|
|
+ if(strncasecmp(json_null_str, tok->pb->buf,
|
7702 |
|
|
+ min(tok->st_pos+1, strlen(json_null_str))) == 0) {
|
7703 |
|
|
+ if(tok->st_pos == strlen(json_null_str)) {
|
7704 |
|
|
+ current = NULL;
|
7705 |
|
|
+ saved_state = json_tokener_state_finish;
|
7706 |
|
|
+ state = json_tokener_state_eatws;
|
7707 |
|
|
+ goto redo_char;
|
7708 |
|
|
+ }
|
7709 |
|
|
+ } else {
|
7710 |
|
|
+ tok->err = json_tokener_error_parse_null;
|
7711 |
|
|
+ goto out;
|
7712 |
|
|
+ }
|
7713 |
|
|
+ tok->st_pos++;
|
7714 |
|
|
+ break;
|
7715 |
|
|
+
|
7716 |
|
|
+ case json_tokener_state_comment_start:
|
7717 |
|
|
+ if(c == '*') {
|
7718 |
|
|
+ state = json_tokener_state_comment;
|
7719 |
|
|
+ } else if(c == '/') {
|
7720 |
|
|
+ state = json_tokener_state_comment_eol;
|
7721 |
|
|
+ } else {
|
7722 |
|
|
+ tok->err = json_tokener_error_parse_comment;
|
7723 |
|
|
+ goto out;
|
7724 |
|
|
+ }
|
7725 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7726 |
|
|
+ break;
|
7727 |
|
|
+
|
7728 |
|
|
+ case json_tokener_state_comment:
|
7729 |
|
|
+ if(c == '*') state = json_tokener_state_comment_end;
|
7730 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7731 |
|
|
+ break;
|
7732 |
|
|
+
|
7733 |
|
|
+ case json_tokener_state_comment_eol:
|
7734 |
|
|
+ if(c == '\n') {
|
7735 |
|
|
+ MC_DEBUG("json_tokener_comment: %s\n", tok->pb->buf);
|
7736 |
|
|
+ state = json_tokener_state_eatws;
|
7737 |
|
|
+ } else {
|
7738 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7739 |
|
|
+ }
|
7740 |
|
|
+ break;
|
7741 |
|
|
+
|
7742 |
|
|
+ case json_tokener_state_comment_end:
|
7743 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7744 |
|
|
+ if(c == '/') {
|
7745 |
|
|
+ MC_DEBUG("json_tokener_comment: %s\n", tok->pb->buf);
|
7746 |
|
|
+ state = json_tokener_state_eatws;
|
7747 |
|
|
+ } else {
|
7748 |
|
|
+ state = json_tokener_state_comment;
|
7749 |
|
|
+ }
|
7750 |
|
|
+ break;
|
7751 |
|
|
+
|
7752 |
|
|
+ case json_tokener_state_string:
|
7753 |
|
|
+ if(c == tok->quote_char) {
|
7754 |
|
|
+ current = json_object_new_string(tok->pb->buf);
|
7755 |
|
|
+ saved_state = json_tokener_state_finish;
|
7756 |
|
|
+ state = json_tokener_state_eatws;
|
7757 |
|
|
+ } else if(c == '\\') {
|
7758 |
|
|
+ saved_state = json_tokener_state_string;
|
7759 |
|
|
+ state = json_tokener_state_string_escape;
|
7760 |
|
|
+ } else {
|
7761 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7762 |
|
|
+ }
|
7763 |
|
|
+ break;
|
7764 |
|
|
+
|
7765 |
|
|
+ case json_tokener_state_string_escape:
|
7766 |
|
|
+ switch(c) {
|
7767 |
|
|
+ case '"':
|
7768 |
|
|
+ case '\\':
|
7769 |
|
|
+ case '/':
|
7770 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7771 |
|
|
+ state = saved_state;
|
7772 |
|
|
+ break;
|
7773 |
|
|
+ case 'b':
|
7774 |
|
|
+ case 'n':
|
7775 |
|
|
+ case 'r':
|
7776 |
|
|
+ case 't':
|
7777 |
|
|
+ if(c == 'b') printbuf_memappend(tok->pb, "\b", 1);
|
7778 |
|
|
+ else if(c == 'n') printbuf_memappend(tok->pb, "\n", 1);
|
7779 |
|
|
+ else if(c == 'r') printbuf_memappend(tok->pb, "\r", 1);
|
7780 |
|
|
+ else if(c == 't') printbuf_memappend(tok->pb, "\t", 1);
|
7781 |
|
|
+ state = saved_state;
|
7782 |
|
|
+ break;
|
7783 |
|
|
+ case 'u':
|
7784 |
|
|
+ tok->ucs_char = 0;
|
7785 |
|
|
+ tok->st_pos = 0;
|
7786 |
|
|
+ state = json_tokener_state_escape_unicode;
|
7787 |
|
|
+ break;
|
7788 |
|
|
+ default:
|
7789 |
|
|
+ tok->err = json_tokener_error_parse_string;
|
7790 |
|
|
+ goto out;
|
7791 |
|
|
+ }
|
7792 |
|
|
+ break;
|
7793 |
|
|
+
|
7794 |
|
|
+ case json_tokener_state_escape_unicode:
|
7795 |
|
|
+ if(strchr(json_hex_chars, c)) {
|
7796 |
|
|
+ tok->ucs_char += ((unsigned int)hexdigit(c) << ((3-tok->st_pos++)*4));
|
7797 |
|
|
+ if(tok->st_pos == 4) {
|
7798 |
|
|
+ unsigned char utf_out[3];
|
7799 |
|
|
+ if (tok->ucs_char < 0x80) {
|
7800 |
|
|
+ utf_out[0] = tok->ucs_char;
|
7801 |
|
|
+ printbuf_memappend(tok->pb, (char*)utf_out, 1);
|
7802 |
|
|
+ } else if (tok->ucs_char < 0x800) {
|
7803 |
|
|
+ utf_out[0] = 0xc0 | (tok->ucs_char >> 6);
|
7804 |
|
|
+ utf_out[1] = 0x80 | (tok->ucs_char & 0x3f);
|
7805 |
|
|
+ printbuf_memappend(tok->pb, (char*)utf_out, 2);
|
7806 |
|
|
+ } else {
|
7807 |
|
|
+ utf_out[0] = 0xe0 | (tok->ucs_char >> 12);
|
7808 |
|
|
+ utf_out[1] = 0x80 | ((tok->ucs_char >> 6) & 0x3f);
|
7809 |
|
|
+ utf_out[2] = 0x80 | (tok->ucs_char & 0x3f);
|
7810 |
|
|
+ printbuf_memappend(tok->pb, (char*)utf_out, 3);
|
7811 |
|
|
+ }
|
7812 |
|
|
+ state = saved_state;
|
7813 |
|
|
+ }
|
7814 |
|
|
+ } else {
|
7815 |
|
|
+ tok->err = json_tokener_error_parse_string;
|
7816 |
|
|
+ goto out;
|
7817 |
|
|
+ }
|
7818 |
|
|
+ break;
|
7819 |
|
|
+
|
7820 |
|
|
+ case json_tokener_state_boolean:
|
7821 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7822 |
|
|
+ if(strncasecmp(json_true_str, tok->pb->buf,
|
7823 |
|
|
+ min(tok->st_pos+1, strlen(json_true_str))) == 0) {
|
7824 |
|
|
+ if(tok->st_pos == strlen(json_true_str)) {
|
7825 |
|
|
+ current = json_object_new_boolean(1);
|
7826 |
|
|
+ saved_state = json_tokener_state_finish;
|
7827 |
|
|
+ state = json_tokener_state_eatws;
|
7828 |
|
|
+ goto redo_char;
|
7829 |
|
|
+ }
|
7830 |
|
|
+ } else if(strncasecmp(json_false_str, tok->pb->buf,
|
7831 |
|
|
+ min(tok->st_pos+1, strlen(json_false_str))) == 0) {
|
7832 |
|
|
+ if(tok->st_pos == strlen(json_false_str)) {
|
7833 |
|
|
+ current = json_object_new_boolean(0);
|
7834 |
|
|
+ saved_state = json_tokener_state_finish;
|
7835 |
|
|
+ state = json_tokener_state_eatws;
|
7836 |
|
|
+ goto redo_char;
|
7837 |
|
|
+ }
|
7838 |
|
|
+ } else {
|
7839 |
|
|
+ tok->err = json_tokener_error_parse_boolean;
|
7840 |
|
|
+ goto out;
|
7841 |
|
|
+ }
|
7842 |
|
|
+ tok->st_pos++;
|
7843 |
|
|
+ break;
|
7844 |
|
|
+
|
7845 |
|
|
+ case json_tokener_state_number:
|
7846 |
|
|
+ if(c && strchr(json_number_chars, c)) {
|
7847 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7848 |
|
|
+ if(c == '.' || c == 'e' || c == 'E') tok->is_double = 1;
|
7849 |
|
|
+ } else {
|
7850 |
|
|
+ int numi;
|
7851 |
|
|
+ double numd;
|
7852 |
|
|
+ if(!tok->is_double && sscanf(tok->pb->buf, "%d", &numi) == 1) {
|
7853 |
|
|
+ current = json_object_new_int(numi);
|
7854 |
|
|
+ } else if(tok->is_double && sscanf(tok->pb->buf, "%lf", &numd) == 1) {
|
7855 |
|
|
+ current = json_object_new_double(numd);
|
7856 |
|
|
+ } else {
|
7857 |
|
|
+ tok->err = json_tokener_error_parse_number;
|
7858 |
|
|
+ goto out;
|
7859 |
|
|
+ }
|
7860 |
|
|
+ saved_state = json_tokener_state_finish;
|
7861 |
|
|
+ state = json_tokener_state_eatws;
|
7862 |
|
|
+ goto redo_char;
|
7863 |
|
|
+ }
|
7864 |
|
|
+ break;
|
7865 |
|
|
+
|
7866 |
|
|
+ case json_tokener_state_array:
|
7867 |
|
|
+ if(c == ']') {
|
7868 |
|
|
+ saved_state = json_tokener_state_finish;
|
7869 |
|
|
+ state = json_tokener_state_eatws;
|
7870 |
|
|
+ } else {
|
7871 |
|
|
+ if(tok->depth >= JSON_TOKENER_MAX_DEPTH-1) {
|
7872 |
|
|
+ tok->err = json_tokener_error_depth;
|
7873 |
|
|
+ goto out;
|
7874 |
|
|
+ }
|
7875 |
|
|
+ state = json_tokener_state_array_add;
|
7876 |
|
|
+ tok->depth++;
|
7877 |
|
|
+ json_tokener_reset_level(tok, tok->depth);
|
7878 |
|
|
+ goto redo_char;
|
7879 |
|
|
+ }
|
7880 |
|
|
+ break;
|
7881 |
|
|
+
|
7882 |
|
|
+ case json_tokener_state_array_add:
|
7883 |
|
|
+ json_object_array_add(current, obj);
|
7884 |
|
|
+ saved_state = json_tokener_state_array_sep;
|
7885 |
|
|
+ state = json_tokener_state_eatws;
|
7886 |
|
|
+ goto redo_char;
|
7887 |
|
|
+
|
7888 |
|
|
+ case json_tokener_state_array_sep:
|
7889 |
|
|
+ if(c == ']') {
|
7890 |
|
|
+ saved_state = json_tokener_state_finish;
|
7891 |
|
|
+ state = json_tokener_state_eatws;
|
7892 |
|
|
+ } else if(c == ',') {
|
7893 |
|
|
+ saved_state = json_tokener_state_array;
|
7894 |
|
|
+ state = json_tokener_state_eatws;
|
7895 |
|
|
+ } else {
|
7896 |
|
|
+ tok->err = json_tokener_error_parse_array;
|
7897 |
|
|
+ goto out;
|
7898 |
|
|
+ }
|
7899 |
|
|
+ break;
|
7900 |
|
|
+
|
7901 |
|
|
+ case json_tokener_state_object_field_start:
|
7902 |
|
|
+ if(c == '}') {
|
7903 |
|
|
+ saved_state = json_tokener_state_finish;
|
7904 |
|
|
+ state = json_tokener_state_eatws;
|
7905 |
|
|
+ } else if (c == '"' || c == '\'') {
|
7906 |
|
|
+ tok->quote_char = c;
|
7907 |
|
|
+ printbuf_reset(tok->pb);
|
7908 |
|
|
+ state = json_tokener_state_object_field;
|
7909 |
|
|
+ } else {
|
7910 |
|
|
+ tok->err = json_tokener_error_parse_object_key_name;
|
7911 |
|
|
+ goto out;
|
7912 |
|
|
+ }
|
7913 |
|
|
+ break;
|
7914 |
|
|
+
|
7915 |
|
|
+ case json_tokener_state_object_field:
|
7916 |
|
|
+ if(c == tok->quote_char) {
|
7917 |
|
|
+ obj_field_name = strdup(tok->pb->buf);
|
7918 |
|
|
+ saved_state = json_tokener_state_object_field_end;
|
7919 |
|
|
+ state = json_tokener_state_eatws;
|
7920 |
|
|
+ } else if(c == '\\') {
|
7921 |
|
|
+ saved_state = json_tokener_state_object_field;
|
7922 |
|
|
+ state = json_tokener_state_string_escape;
|
7923 |
|
|
+ } else {
|
7924 |
|
|
+ printbuf_memappend(tok->pb, &c, 1);
|
7925 |
|
|
+ }
|
7926 |
|
|
+ break;
|
7927 |
|
|
+
|
7928 |
|
|
+ case json_tokener_state_object_field_end:
|
7929 |
|
|
+ if(c == ':') {
|
7930 |
|
|
+ saved_state = json_tokener_state_object_value;
|
7931 |
|
|
+ state = json_tokener_state_eatws;
|
7932 |
|
|
+ } else {
|
7933 |
|
|
+ tok->err = json_tokener_error_parse_object_key_sep;
|
7934 |
|
|
+ goto out;
|
7935 |
|
|
+ }
|
7936 |
|
|
+ break;
|
7937 |
|
|
+
|
7938 |
|
|
+ case json_tokener_state_object_value:
|
7939 |
|
|
+ if(tok->depth >= JSON_TOKENER_MAX_DEPTH-1) {
|
7940 |
|
|
+ tok->err = json_tokener_error_depth;
|
7941 |
|
|
+ goto out;
|
7942 |
|
|
+ }
|
7943 |
|
|
+ state = json_tokener_state_object_value_add;
|
7944 |
|
|
+ tok->depth++;
|
7945 |
|
|
+ json_tokener_reset_level(tok, tok->depth);
|
7946 |
|
|
+ goto redo_char;
|
7947 |
|
|
+
|
7948 |
|
|
+ case json_tokener_state_object_value_add:
|
7949 |
|
|
+ json_object_object_add(current, obj_field_name, obj);
|
7950 |
|
|
+ free(obj_field_name);
|
7951 |
|
|
+ obj_field_name = NULL;
|
7952 |
|
|
+ saved_state = json_tokener_state_object_sep;
|
7953 |
|
|
+ state = json_tokener_state_eatws;
|
7954 |
|
|
+ goto redo_char;
|
7955 |
|
|
+
|
7956 |
|
|
+ case json_tokener_state_object_sep:
|
7957 |
|
|
+ if(c == '}') {
|
7958 |
|
|
+ saved_state = json_tokener_state_finish;
|
7959 |
|
|
+ state = json_tokener_state_eatws;
|
7960 |
|
|
+ } else if(c == ',') {
|
7961 |
|
|
+ saved_state = json_tokener_state_object_field_start;
|
7962 |
|
|
+ state = json_tokener_state_eatws;
|
7963 |
|
|
+ } else {
|
7964 |
|
|
+ tok->err = json_tokener_error_parse_object_value_sep;
|
7965 |
|
|
+ goto out;
|
7966 |
|
|
+ }
|
7967 |
|
|
+ break;
|
7968 |
|
|
+
|
7969 |
|
|
+ }
|
7970 |
|
|
+ str++;
|
7971 |
|
|
+ tok->char_offset++;
|
7972 |
|
|
+ } while(c);
|
7973 |
|
|
+
|
7974 |
|
|
+ if(state != json_tokener_state_finish &&
|
7975 |
|
|
+ saved_state != json_tokener_state_finish)
|
7976 |
|
|
+ tok->err = json_tokener_error_parse_eof;
|
7977 |
|
|
+
|
7978 |
|
|
+ out:
|
7979 |
|
|
+ if(tok->err == json_tokener_success) return json_object_get(current);
|
7980 |
|
|
+ MC_DEBUG("json_tokener_parse_ex: error %s at offset %d\n",
|
7981 |
|
|
+ json_tokener_errors[tok->err], tok->char_offset);
|
7982 |
|
|
+ return NULL;
|
7983 |
|
|
+}
|
7984 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/json_tokener.h sdcc-src-3.1.0-pblaze/src/json/json/json_tokener.h
|
7985 |
|
|
--- sdcc-src-3.1.0/src/json/json/json_tokener.h 1970-01-01 01:00:00.000000000 +0100
|
7986 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/json_tokener.h 2011-02-07 20:04:46.000000000 +0100
|
7987 |
|
|
@@ -0,0 +1,90 @@
|
7988 |
|
|
+/*
|
7989 |
|
|
+ * $Id: json_tokener.h,v 1.10 2006/07/25 03:24:50 mclark Exp $
|
7990 |
|
|
+ *
|
7991 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
7992 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
7993 |
|
|
+ *
|
7994 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
7995 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
7996 |
|
|
+ *
|
7997 |
|
|
+ */
|
7998 |
|
|
+
|
7999 |
|
|
+#ifndef _json_tokener_h_
|
8000 |
|
|
+#define _json_tokener_h_
|
8001 |
|
|
+
|
8002 |
|
|
+#include <stddef.h>
|
8003 |
|
|
+#include "json_object.h"
|
8004 |
|
|
+
|
8005 |
|
|
+enum json_tokener_error {
|
8006 |
|
|
+ json_tokener_success,
|
8007 |
|
|
+ json_tokener_continue,
|
8008 |
|
|
+ json_tokener_error_depth,
|
8009 |
|
|
+ json_tokener_error_parse_eof,
|
8010 |
|
|
+ json_tokener_error_parse_unexpected,
|
8011 |
|
|
+ json_tokener_error_parse_null,
|
8012 |
|
|
+ json_tokener_error_parse_boolean,
|
8013 |
|
|
+ json_tokener_error_parse_number,
|
8014 |
|
|
+ json_tokener_error_parse_array,
|
8015 |
|
|
+ json_tokener_error_parse_object_key_name,
|
8016 |
|
|
+ json_tokener_error_parse_object_key_sep,
|
8017 |
|
|
+ json_tokener_error_parse_object_value_sep,
|
8018 |
|
|
+ json_tokener_error_parse_string,
|
8019 |
|
|
+ json_tokener_error_parse_comment
|
8020 |
|
|
+};
|
8021 |
|
|
+
|
8022 |
|
|
+enum json_tokener_state {
|
8023 |
|
|
+ json_tokener_state_eatws,
|
8024 |
|
|
+ json_tokener_state_start,
|
8025 |
|
|
+ json_tokener_state_finish,
|
8026 |
|
|
+ json_tokener_state_null,
|
8027 |
|
|
+ json_tokener_state_comment_start,
|
8028 |
|
|
+ json_tokener_state_comment,
|
8029 |
|
|
+ json_tokener_state_comment_eol,
|
8030 |
|
|
+ json_tokener_state_comment_end,
|
8031 |
|
|
+ json_tokener_state_string,
|
8032 |
|
|
+ json_tokener_state_string_escape,
|
8033 |
|
|
+ json_tokener_state_escape_unicode,
|
8034 |
|
|
+ json_tokener_state_boolean,
|
8035 |
|
|
+ json_tokener_state_number,
|
8036 |
|
|
+ json_tokener_state_array,
|
8037 |
|
|
+ json_tokener_state_array_add,
|
8038 |
|
|
+ json_tokener_state_array_sep,
|
8039 |
|
|
+ json_tokener_state_object_field_start,
|
8040 |
|
|
+ json_tokener_state_object_field,
|
8041 |
|
|
+ json_tokener_state_object_field_end,
|
8042 |
|
|
+ json_tokener_state_object_value,
|
8043 |
|
|
+ json_tokener_state_object_value_add,
|
8044 |
|
|
+ json_tokener_state_object_sep
|
8045 |
|
|
+};
|
8046 |
|
|
+
|
8047 |
|
|
+struct json_tokener_srec
|
8048 |
|
|
+{
|
8049 |
|
|
+ enum json_tokener_state state, saved_state;
|
8050 |
|
|
+ struct json_object *obj;
|
8051 |
|
|
+ struct json_object *current;
|
8052 |
|
|
+ char *obj_field_name;
|
8053 |
|
|
+};
|
8054 |
|
|
+
|
8055 |
|
|
+#define JSON_TOKENER_MAX_DEPTH 32
|
8056 |
|
|
+
|
8057 |
|
|
+struct json_tokener
|
8058 |
|
|
+{
|
8059 |
|
|
+ char *str;
|
8060 |
|
|
+ struct printbuf *pb;
|
8061 |
|
|
+ int depth, is_double, st_pos, char_offset;
|
8062 |
|
|
+ ptrdiff_t err;
|
8063 |
|
|
+ unsigned int ucs_char;
|
8064 |
|
|
+ char quote_char;
|
8065 |
|
|
+ struct json_tokener_srec stack[JSON_TOKENER_MAX_DEPTH];
|
8066 |
|
|
+};
|
8067 |
|
|
+
|
8068 |
|
|
+extern const char* json_tokener_errors[];
|
8069 |
|
|
+
|
8070 |
|
|
+extern struct json_tokener* json_tokener_new(void);
|
8071 |
|
|
+extern void json_tokener_free(struct json_tokener *tok);
|
8072 |
|
|
+extern void json_tokener_reset(struct json_tokener *tok);
|
8073 |
|
|
+extern struct json_object* json_tokener_parse(char *str);
|
8074 |
|
|
+extern struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
8075 |
|
|
+ char *str, int len);
|
8076 |
|
|
+
|
8077 |
|
|
+#endif
|
8078 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/json_util.c sdcc-src-3.1.0-pblaze/src/json/json/json_util.c
|
8079 |
|
|
--- sdcc-src-3.1.0/src/json/json/json_util.c 1970-01-01 01:00:00.000000000 +0100
|
8080 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/json_util.c 2011-02-07 20:04:46.000000000 +0100
|
8081 |
|
|
@@ -0,0 +1,122 @@
|
8082 |
|
|
+/*
|
8083 |
|
|
+ * $Id: json_util.c,v 1.4 2006/01/30 23:07:57 mclark Exp $
|
8084 |
|
|
+ *
|
8085 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
8086 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
8087 |
|
|
+ *
|
8088 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
8089 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
8090 |
|
|
+ *
|
8091 |
|
|
+ */
|
8092 |
|
|
+
|
8093 |
|
|
+#include "config.h"
|
8094 |
|
|
+
|
8095 |
|
|
+#include <stdio.h>
|
8096 |
|
|
+#include <stdlib.h>
|
8097 |
|
|
+#include <stddef.h>
|
8098 |
|
|
+#include <limits.h>
|
8099 |
|
|
+#include <string.h>
|
8100 |
|
|
+#include <errno.h>
|
8101 |
|
|
+
|
8102 |
|
|
+#if HAVE_SYS_TYPES_H
|
8103 |
|
|
+#include <sys/types.h>
|
8104 |
|
|
+#endif /* HAVE_SYS_TYPES_H */
|
8105 |
|
|
+
|
8106 |
|
|
+#if HAVE_SYS_STAT_H
|
8107 |
|
|
+#include <sys/stat.h>
|
8108 |
|
|
+#endif /* HAVE_SYS_STAT_H */
|
8109 |
|
|
+
|
8110 |
|
|
+#if HAVE_FCNTL_H
|
8111 |
|
|
+#include <fcntl.h>
|
8112 |
|
|
+#endif /* HAVE_FCNTL_H */
|
8113 |
|
|
+
|
8114 |
|
|
+#if HAVE_UNISTD_H
|
8115 |
|
|
+# include <unistd.h>
|
8116 |
|
|
+#endif /* HAVE_UNISTD_H */
|
8117 |
|
|
+
|
8118 |
|
|
+#ifdef WIN32
|
8119 |
|
|
+# define WIN32_LEAN_AND_MEAN
|
8120 |
|
|
+# include <windows.h>
|
8121 |
|
|
+# include <io.h>
|
8122 |
|
|
+#endif /* defined(WIN32) */
|
8123 |
|
|
+
|
8124 |
|
|
+#if !HAVE_OPEN && defined(WIN32)
|
8125 |
|
|
+# define open _open
|
8126 |
|
|
+#endif
|
8127 |
|
|
+
|
8128 |
|
|
+
|
8129 |
|
|
+#include "bits.h"
|
8130 |
|
|
+#include "debug.h"
|
8131 |
|
|
+#include "printbuf.h"
|
8132 |
|
|
+#include "json_object.h"
|
8133 |
|
|
+#include "json_tokener.h"
|
8134 |
|
|
+#include "json_util.h"
|
8135 |
|
|
+
|
8136 |
|
|
+struct json_object* json_object_from_file(char *filename)
|
8137 |
|
|
+{
|
8138 |
|
|
+ struct printbuf *pb;
|
8139 |
|
|
+ struct json_object *obj;
|
8140 |
|
|
+ char buf[JSON_FILE_BUF_SIZE];
|
8141 |
|
|
+ int fd, ret;
|
8142 |
|
|
+
|
8143 |
|
|
+ if((fd = open(filename, O_RDONLY)) < 0) {
|
8144 |
|
|
+ MC_ERROR("json_object_from_file: error reading file %s: %s\n",
|
8145 |
|
|
+ filename, strerror(errno));
|
8146 |
|
|
+ return error_ptr(-1);
|
8147 |
|
|
+ }
|
8148 |
|
|
+ if(!(pb = printbuf_new())) {
|
8149 |
|
|
+ MC_ERROR("json_object_from_file: printbuf_new failed\n");
|
8150 |
|
|
+ return error_ptr(-1);
|
8151 |
|
|
+ }
|
8152 |
|
|
+ while((ret = read(fd, buf, JSON_FILE_BUF_SIZE)) > 0) {
|
8153 |
|
|
+ printbuf_memappend(pb, buf, ret);
|
8154 |
|
|
+ }
|
8155 |
|
|
+ close(fd);
|
8156 |
|
|
+ if(ret < 0) {
|
8157 |
|
|
+ MC_ABORT("json_object_from_file: error reading file %s: %s\n",
|
8158 |
|
|
+ filename, strerror(errno));
|
8159 |
|
|
+ printbuf_free(pb);
|
8160 |
|
|
+ return error_ptr(-1);
|
8161 |
|
|
+ }
|
8162 |
|
|
+ obj = json_tokener_parse(pb->buf);
|
8163 |
|
|
+ printbuf_free(pb);
|
8164 |
|
|
+ return obj;
|
8165 |
|
|
+}
|
8166 |
|
|
+
|
8167 |
|
|
+int json_object_to_file(char *filename, struct json_object *obj)
|
8168 |
|
|
+{
|
8169 |
|
|
+ const char *json_str;
|
8170 |
|
|
+ int fd, ret;
|
8171 |
|
|
+ unsigned int wpos, wsize;
|
8172 |
|
|
+
|
8173 |
|
|
+ if(!obj) {
|
8174 |
|
|
+ MC_ERROR("json_object_to_file: object is null\n");
|
8175 |
|
|
+ return -1;
|
8176 |
|
|
+ }
|
8177 |
|
|
+
|
8178 |
|
|
+ if((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0) {
|
8179 |
|
|
+ MC_ERROR("json_object_to_file: error opening file %s: %s\n",
|
8180 |
|
|
+ filename, strerror(errno));
|
8181 |
|
|
+ return -1;
|
8182 |
|
|
+ }
|
8183 |
|
|
+
|
8184 |
|
|
+ if(!(json_str = json_object_to_json_string(obj))) { return -1; }
|
8185 |
|
|
+
|
8186 |
|
|
+
|
8187 |
|
|
+ wsize = (unsigned int)(strlen(json_str) & UINT_MAX); /* CAW: probably unnecessary, but the most 64bit safe */
|
8188 |
|
|
+ wpos = 0;
|
8189 |
|
|
+ while(wpos < wsize) {
|
8190 |
|
|
+ if((ret = write(fd, json_str + wpos, wsize-wpos)) < 0) {
|
8191 |
|
|
+ close(fd);
|
8192 |
|
|
+ MC_ERROR("json_object_to_file: error writing file %s: %s\n",
|
8193 |
|
|
+ filename, strerror(errno));
|
8194 |
|
|
+ return -1;
|
8195 |
|
|
+ }
|
8196 |
|
|
+
|
8197 |
|
|
+ /* because of the above check for ret < 0, we can safely cast and add */
|
8198 |
|
|
+ wpos += (unsigned int)ret;
|
8199 |
|
|
+ }
|
8200 |
|
|
+
|
8201 |
|
|
+ close(fd);
|
8202 |
|
|
+ return 0;
|
8203 |
|
|
+}
|
8204 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/json_util.h sdcc-src-3.1.0-pblaze/src/json/json/json_util.h
|
8205 |
|
|
--- sdcc-src-3.1.0/src/json/json/json_util.h 1970-01-01 01:00:00.000000000 +0100
|
8206 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/json_util.h 2011-02-07 20:04:46.000000000 +0100
|
8207 |
|
|
@@ -0,0 +1,23 @@
|
8208 |
|
|
+/*
|
8209 |
|
|
+ * $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $
|
8210 |
|
|
+ *
|
8211 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
8212 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
8213 |
|
|
+ *
|
8214 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
8215 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
8216 |
|
|
+ *
|
8217 |
|
|
+ */
|
8218 |
|
|
+
|
8219 |
|
|
+#ifndef _json_util_h_
|
8220 |
|
|
+#define _json_util_h_
|
8221 |
|
|
+
|
8222 |
|
|
+#include "json_object.h"
|
8223 |
|
|
+
|
8224 |
|
|
+#define JSON_FILE_BUF_SIZE 4096
|
8225 |
|
|
+
|
8226 |
|
|
+/* utlitiy functions */
|
8227 |
|
|
+extern struct json_object* json_object_from_file(char *filename);
|
8228 |
|
|
+extern int json_object_to_file(char *filename, struct json_object *obj);
|
8229 |
|
|
+
|
8230 |
|
|
+#endif
|
8231 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/linkhash.c sdcc-src-3.1.0-pblaze/src/json/json/linkhash.c
|
8232 |
|
|
--- sdcc-src-3.1.0/src/json/json/linkhash.c 1970-01-01 01:00:00.000000000 +0100
|
8233 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/linkhash.c 2011-02-07 20:04:46.000000000 +0100
|
8234 |
|
|
@@ -0,0 +1,218 @@
|
8235 |
|
|
+/*
|
8236 |
|
|
+ * $Id: linkhash.c,v 1.4 2006/01/26 02:16:28 mclark Exp $
|
8237 |
|
|
+ *
|
8238 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
8239 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
8240 |
|
|
+ *
|
8241 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
8242 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
8243 |
|
|
+ *
|
8244 |
|
|
+ */
|
8245 |
|
|
+
|
8246 |
|
|
+#include "config.h"
|
8247 |
|
|
+
|
8248 |
|
|
+#include <stdio.h>
|
8249 |
|
|
+#include <string.h>
|
8250 |
|
|
+#include <stdlib.h>
|
8251 |
|
|
+#include <stdarg.h>
|
8252 |
|
|
+#include <stddef.h>
|
8253 |
|
|
+#include <limits.h>
|
8254 |
|
|
+
|
8255 |
|
|
+#include "linkhash.h"
|
8256 |
|
|
+
|
8257 |
|
|
+void lh_abort(const char *msg, ...)
|
8258 |
|
|
+{
|
8259 |
|
|
+ va_list ap;
|
8260 |
|
|
+ va_start(ap, msg);
|
8261 |
|
|
+ vprintf(msg, ap);
|
8262 |
|
|
+ va_end(ap);
|
8263 |
|
|
+ exit(1);
|
8264 |
|
|
+}
|
8265 |
|
|
+
|
8266 |
|
|
+unsigned long lh_ptr_hash(const void *k)
|
8267 |
|
|
+{
|
8268 |
|
|
+ /* CAW: refactored to be 64bit nice */
|
8269 |
|
|
+ return (unsigned long)((((ptrdiff_t)k * LH_PRIME) >> 4) & ULONG_MAX);
|
8270 |
|
|
+}
|
8271 |
|
|
+
|
8272 |
|
|
+int lh_ptr_equal(const void *k1, const void *k2)
|
8273 |
|
|
+{
|
8274 |
|
|
+ return (k1 == k2);
|
8275 |
|
|
+}
|
8276 |
|
|
+
|
8277 |
|
|
+unsigned long lh_char_hash(const void *k)
|
8278 |
|
|
+{
|
8279 |
|
|
+ unsigned int h = 0;
|
8280 |
|
|
+ const char* data = k;
|
8281 |
|
|
+
|
8282 |
|
|
+ while( *data!=0 ) h = h*129 + (unsigned int)(*data++) + LH_PRIME;
|
8283 |
|
|
+
|
8284 |
|
|
+ return h;
|
8285 |
|
|
+}
|
8286 |
|
|
+
|
8287 |
|
|
+int lh_char_equal(const void *k1, const void *k2)
|
8288 |
|
|
+{
|
8289 |
|
|
+ return (strcmp((const char*)k1, (const char*)k2) == 0);
|
8290 |
|
|
+}
|
8291 |
|
|
+
|
8292 |
|
|
+struct lh_table* lh_table_new(int size, const char *name,
|
8293 |
|
|
+ lh_entry_free_fn *free_fn,
|
8294 |
|
|
+ lh_hash_fn *hash_fn,
|
8295 |
|
|
+ lh_equal_fn *equal_fn)
|
8296 |
|
|
+{
|
8297 |
|
|
+ int i;
|
8298 |
|
|
+ struct lh_table *t;
|
8299 |
|
|
+
|
8300 |
|
|
+ t = calloc(1, sizeof(struct lh_table));
|
8301 |
|
|
+ if(!t) lh_abort("lh_table_new: calloc failed\n");
|
8302 |
|
|
+ t->count = 0;
|
8303 |
|
|
+ t->size = size;
|
8304 |
|
|
+ t->name = name;
|
8305 |
|
|
+ t->table = calloc(size, sizeof(struct lh_entry));
|
8306 |
|
|
+ if(!t->table) lh_abort("lh_table_new: calloc failed\n");
|
8307 |
|
|
+ t->free_fn = free_fn;
|
8308 |
|
|
+ t->hash_fn = hash_fn;
|
8309 |
|
|
+ t->equal_fn = equal_fn;
|
8310 |
|
|
+ for(i = 0; i < size; i++) t->table[i].k = LH_EMPTY;
|
8311 |
|
|
+ return t;
|
8312 |
|
|
+}
|
8313 |
|
|
+
|
8314 |
|
|
+struct lh_table* lh_kchar_table_new(int size, const char *name,
|
8315 |
|
|
+ lh_entry_free_fn *free_fn)
|
8316 |
|
|
+{
|
8317 |
|
|
+ return lh_table_new(size, name, free_fn, lh_char_hash, lh_char_equal);
|
8318 |
|
|
+}
|
8319 |
|
|
+
|
8320 |
|
|
+struct lh_table* lh_kptr_table_new(int size, const char *name,
|
8321 |
|
|
+ lh_entry_free_fn *free_fn)
|
8322 |
|
|
+{
|
8323 |
|
|
+ return lh_table_new(size, name, free_fn, lh_ptr_hash, lh_ptr_equal);
|
8324 |
|
|
+}
|
8325 |
|
|
+
|
8326 |
|
|
+void lh_table_resize(struct lh_table *t, int new_size)
|
8327 |
|
|
+{
|
8328 |
|
|
+ struct lh_table *new_t;
|
8329 |
|
|
+ struct lh_entry *ent;
|
8330 |
|
|
+
|
8331 |
|
|
+ new_t = lh_table_new(new_size, t->name, NULL, t->hash_fn, t->equal_fn);
|
8332 |
|
|
+ ent = t->head;
|
8333 |
|
|
+ while(ent) {
|
8334 |
|
|
+ lh_table_insert(new_t, ent->k, ent->v);
|
8335 |
|
|
+ ent = ent->next;
|
8336 |
|
|
+ }
|
8337 |
|
|
+ free(t->table);
|
8338 |
|
|
+ t->table = new_t->table;
|
8339 |
|
|
+ t->size = new_size;
|
8340 |
|
|
+ t->head = new_t->head;
|
8341 |
|
|
+ t->tail = new_t->tail;
|
8342 |
|
|
+ t->resizes++;
|
8343 |
|
|
+ free(new_t);
|
8344 |
|
|
+}
|
8345 |
|
|
+
|
8346 |
|
|
+void lh_table_free(struct lh_table *t)
|
8347 |
|
|
+{
|
8348 |
|
|
+ struct lh_entry *c;
|
8349 |
|
|
+ for(c = t->head; c != NULL; c = c->next) {
|
8350 |
|
|
+ if(t->free_fn) {
|
8351 |
|
|
+ t->free_fn(c);
|
8352 |
|
|
+ }
|
8353 |
|
|
+ }
|
8354 |
|
|
+ free(t->table);
|
8355 |
|
|
+ free(t);
|
8356 |
|
|
+}
|
8357 |
|
|
+
|
8358 |
|
|
+
|
8359 |
|
|
+int lh_table_insert(struct lh_table *t, void *k, const void *v)
|
8360 |
|
|
+{
|
8361 |
|
|
+ unsigned long h, n;
|
8362 |
|
|
+
|
8363 |
|
|
+ t->inserts++;
|
8364 |
|
|
+ if(t->count > t->size * 0.66) lh_table_resize(t, t->size * 2);
|
8365 |
|
|
+
|
8366 |
|
|
+ h = t->hash_fn(k);
|
8367 |
|
|
+ n = h % t->size;
|
8368 |
|
|
+
|
8369 |
|
|
+ while( 1 ) {
|
8370 |
|
|
+ if(t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED) break;
|
8371 |
|
|
+ t->collisions++;
|
8372 |
|
|
+ if(++n == t->size) n = 0;
|
8373 |
|
|
+ }
|
8374 |
|
|
+
|
8375 |
|
|
+ t->table[n].k = k;
|
8376 |
|
|
+ t->table[n].v = v;
|
8377 |
|
|
+ t->count++;
|
8378 |
|
|
+
|
8379 |
|
|
+ if(t->head == NULL) {
|
8380 |
|
|
+ t->head = t->tail = &t->table[n];
|
8381 |
|
|
+ t->table[n].next = t->table[n].prev = NULL;
|
8382 |
|
|
+ } else {
|
8383 |
|
|
+ t->tail->next = &t->table[n];
|
8384 |
|
|
+ t->table[n].prev = t->tail;
|
8385 |
|
|
+ t->table[n].next = NULL;
|
8386 |
|
|
+ t->tail = &t->table[n];
|
8387 |
|
|
+ }
|
8388 |
|
|
+
|
8389 |
|
|
+ return 0;
|
8390 |
|
|
+}
|
8391 |
|
|
+
|
8392 |
|
|
+
|
8393 |
|
|
+struct lh_entry* lh_table_lookup_entry(struct lh_table *t, const void *k)
|
8394 |
|
|
+{
|
8395 |
|
|
+ unsigned long h = t->hash_fn(k);
|
8396 |
|
|
+ unsigned long n = h % t->size;
|
8397 |
|
|
+
|
8398 |
|
|
+ t->lookups++;
|
8399 |
|
|
+ while( 1 ) {
|
8400 |
|
|
+ if(t->table[n].k == LH_EMPTY) return NULL;
|
8401 |
|
|
+ if(t->table[n].k != LH_FREED &&
|
8402 |
|
|
+ t->equal_fn(t->table[n].k, k)) return &t->table[n];
|
8403 |
|
|
+ if(++n == t->size) n = 0;
|
8404 |
|
|
+ }
|
8405 |
|
|
+ return NULL;
|
8406 |
|
|
+}
|
8407 |
|
|
+
|
8408 |
|
|
+
|
8409 |
|
|
+const void* lh_table_lookup(struct lh_table *t, const void *k)
|
8410 |
|
|
+{
|
8411 |
|
|
+ struct lh_entry *e = lh_table_lookup_entry(t, k);
|
8412 |
|
|
+ if(e) return e->v;
|
8413 |
|
|
+ return NULL;
|
8414 |
|
|
+}
|
8415 |
|
|
+
|
8416 |
|
|
+
|
8417 |
|
|
+int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e)
|
8418 |
|
|
+{
|
8419 |
|
|
+ ptrdiff_t n = (ptrdiff_t)(e - t->table); /* CAW: fixed to be 64bit nice, still need the crazy negative case... */
|
8420 |
|
|
+
|
8421 |
|
|
+ /* CAW: this is bad, really bad, maybe stack goes other direction on this machine... */
|
8422 |
|
|
+ if(n < 0) { return -2; }
|
8423 |
|
|
+
|
8424 |
|
|
+ if(t->table[n].k == LH_EMPTY || t->table[n].k == LH_FREED) return -1;
|
8425 |
|
|
+ t->count--;
|
8426 |
|
|
+ if(t->free_fn) t->free_fn(e);
|
8427 |
|
|
+ t->table[n].v = NULL;
|
8428 |
|
|
+ t->table[n].k = LH_FREED;
|
8429 |
|
|
+ if(t->tail == &t->table[n] && t->head == &t->table[n]) {
|
8430 |
|
|
+ t->head = t->tail = NULL;
|
8431 |
|
|
+ } else if (t->head == &t->table[n]) {
|
8432 |
|
|
+ t->head->next->prev = NULL;
|
8433 |
|
|
+ t->head = t->head->next;
|
8434 |
|
|
+ } else if (t->tail == &t->table[n]) {
|
8435 |
|
|
+ t->tail->prev->next = NULL;
|
8436 |
|
|
+ t->tail = t->tail->prev;
|
8437 |
|
|
+ } else {
|
8438 |
|
|
+ t->table[n].prev->next = t->table[n].next;
|
8439 |
|
|
+ t->table[n].next->prev = t->table[n].prev;
|
8440 |
|
|
+ }
|
8441 |
|
|
+ t->table[n].next = t->table[n].prev = NULL;
|
8442 |
|
|
+ return 0;
|
8443 |
|
|
+}
|
8444 |
|
|
+
|
8445 |
|
|
+
|
8446 |
|
|
+int lh_table_delete(struct lh_table *t, const void *k)
|
8447 |
|
|
+{
|
8448 |
|
|
+ struct lh_entry *e = lh_table_lookup_entry(t, k);
|
8449 |
|
|
+ if(!e) return -1;
|
8450 |
|
|
+ return lh_table_delete_entry(t, e);
|
8451 |
|
|
+}
|
8452 |
|
|
+
|
8453 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/linkhash.h sdcc-src-3.1.0-pblaze/src/json/json/linkhash.h
|
8454 |
|
|
--- sdcc-src-3.1.0/src/json/json/linkhash.h 1970-01-01 01:00:00.000000000 +0100
|
8455 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/linkhash.h 2011-02-07 20:04:46.000000000 +0100
|
8456 |
|
|
@@ -0,0 +1,264 @@
|
8457 |
|
|
+/*
|
8458 |
|
|
+ * $Id: linkhash.h,v 1.6 2006/01/30 23:07:57 mclark Exp $
|
8459 |
|
|
+ *
|
8460 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
8461 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
8462 |
|
|
+ *
|
8463 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
8464 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
8465 |
|
|
+ *
|
8466 |
|
|
+ */
|
8467 |
|
|
+
|
8468 |
|
|
+#ifndef _linkhash_h_
|
8469 |
|
|
+#define _linkhash_h_
|
8470 |
|
|
+
|
8471 |
|
|
+/**
|
8472 |
|
|
+ * golden prime used in hash functions
|
8473 |
|
|
+ */
|
8474 |
|
|
+#define LH_PRIME 0x9e370001UL
|
8475 |
|
|
+
|
8476 |
|
|
+/**
|
8477 |
|
|
+ * sentinel pointer value for empty slots
|
8478 |
|
|
+ */
|
8479 |
|
|
+#define LH_EMPTY (void*)-1
|
8480 |
|
|
+
|
8481 |
|
|
+/**
|
8482 |
|
|
+ * sentinel pointer value for freed slots
|
8483 |
|
|
+ */
|
8484 |
|
|
+#define LH_FREED (void*)-2
|
8485 |
|
|
+
|
8486 |
|
|
+struct lh_entry;
|
8487 |
|
|
+
|
8488 |
|
|
+/**
|
8489 |
|
|
+ * callback function prototypes
|
8490 |
|
|
+ */
|
8491 |
|
|
+typedef void (lh_entry_free_fn) (struct lh_entry *e);
|
8492 |
|
|
+/**
|
8493 |
|
|
+ * callback function prototypes
|
8494 |
|
|
+ */
|
8495 |
|
|
+typedef unsigned long (lh_hash_fn) (const void *k);
|
8496 |
|
|
+/**
|
8497 |
|
|
+ * callback function prototypes
|
8498 |
|
|
+ */
|
8499 |
|
|
+typedef int (lh_equal_fn) (const void *k1, const void *k2);
|
8500 |
|
|
+
|
8501 |
|
|
+/**
|
8502 |
|
|
+ * An entry in the hash table
|
8503 |
|
|
+ */
|
8504 |
|
|
+struct lh_entry {
|
8505 |
|
|
+ /**
|
8506 |
|
|
+ * The key.
|
8507 |
|
|
+ */
|
8508 |
|
|
+ void *k;
|
8509 |
|
|
+ /**
|
8510 |
|
|
+ * The value.
|
8511 |
|
|
+ */
|
8512 |
|
|
+ const void *v;
|
8513 |
|
|
+ /**
|
8514 |
|
|
+ * The next entry
|
8515 |
|
|
+ */
|
8516 |
|
|
+ struct lh_entry *next;
|
8517 |
|
|
+ /**
|
8518 |
|
|
+ * The previous entry.
|
8519 |
|
|
+ */
|
8520 |
|
|
+ struct lh_entry *prev;
|
8521 |
|
|
+};
|
8522 |
|
|
+
|
8523 |
|
|
+
|
8524 |
|
|
+/**
|
8525 |
|
|
+ * The hash table structure.
|
8526 |
|
|
+ */
|
8527 |
|
|
+struct lh_table {
|
8528 |
|
|
+ /**
|
8529 |
|
|
+ * Size of our hash.
|
8530 |
|
|
+ */
|
8531 |
|
|
+ int size;
|
8532 |
|
|
+ /**
|
8533 |
|
|
+ * Numbers of entries.
|
8534 |
|
|
+ */
|
8535 |
|
|
+ int count;
|
8536 |
|
|
+
|
8537 |
|
|
+ /**
|
8538 |
|
|
+ * Number of collisions.
|
8539 |
|
|
+ */
|
8540 |
|
|
+ int collisions;
|
8541 |
|
|
+
|
8542 |
|
|
+ /**
|
8543 |
|
|
+ * Number of resizes.
|
8544 |
|
|
+ */
|
8545 |
|
|
+ int resizes;
|
8546 |
|
|
+
|
8547 |
|
|
+ /**
|
8548 |
|
|
+ * Number of lookups.
|
8549 |
|
|
+ */
|
8550 |
|
|
+ int lookups;
|
8551 |
|
|
+
|
8552 |
|
|
+ /**
|
8553 |
|
|
+ * Number of inserts.
|
8554 |
|
|
+ */
|
8555 |
|
|
+ int inserts;
|
8556 |
|
|
+
|
8557 |
|
|
+ /**
|
8558 |
|
|
+ * Number of deletes.
|
8559 |
|
|
+ */
|
8560 |
|
|
+ int deletes;
|
8561 |
|
|
+
|
8562 |
|
|
+ /**
|
8563 |
|
|
+ * Name of the hash table.
|
8564 |
|
|
+ */
|
8565 |
|
|
+ const char *name;
|
8566 |
|
|
+
|
8567 |
|
|
+ /**
|
8568 |
|
|
+ * The first entry.
|
8569 |
|
|
+ */
|
8570 |
|
|
+ struct lh_entry *head;
|
8571 |
|
|
+
|
8572 |
|
|
+ /**
|
8573 |
|
|
+ * The last entry.
|
8574 |
|
|
+ */
|
8575 |
|
|
+ struct lh_entry *tail;
|
8576 |
|
|
+
|
8577 |
|
|
+ struct lh_entry *table;
|
8578 |
|
|
+
|
8579 |
|
|
+ /**
|
8580 |
|
|
+ * A pointer onto the function responsible for freeing an entry.
|
8581 |
|
|
+ */
|
8582 |
|
|
+ lh_entry_free_fn *free_fn;
|
8583 |
|
|
+ lh_hash_fn *hash_fn;
|
8584 |
|
|
+ lh_equal_fn *equal_fn;
|
8585 |
|
|
+};
|
8586 |
|
|
+
|
8587 |
|
|
+
|
8588 |
|
|
+/**
|
8589 |
|
|
+ * Pre-defined hash and equality functions
|
8590 |
|
|
+ */
|
8591 |
|
|
+extern unsigned long lh_ptr_hash(const void *k);
|
8592 |
|
|
+extern int lh_ptr_equal(const void *k1, const void *k2);
|
8593 |
|
|
+
|
8594 |
|
|
+extern unsigned long lh_char_hash(const void *k);
|
8595 |
|
|
+extern int lh_char_equal(const void *k1, const void *k2);
|
8596 |
|
|
+
|
8597 |
|
|
+
|
8598 |
|
|
+/**
|
8599 |
|
|
+ * Convenience list iterator.
|
8600 |
|
|
+ */
|
8601 |
|
|
+#define lh_foreach(table, entry) \
|
8602 |
|
|
+for(entry = table->head; entry; entry = entry->next)
|
8603 |
|
|
+
|
8604 |
|
|
+/**
|
8605 |
|
|
+ * lh_foreach_safe allows calling of deletion routine while iterating.
|
8606 |
|
|
+ */
|
8607 |
|
|
+#define lh_foreach_safe(table, entry, tmp) \
|
8608 |
|
|
+for(entry = table->head; entry && ((tmp = entry->next) || 1); entry = tmp)
|
8609 |
|
|
+
|
8610 |
|
|
+
|
8611 |
|
|
+
|
8612 |
|
|
+/**
|
8613 |
|
|
+ * Create a new linkhash table.
|
8614 |
|
|
+ * @param size initial table size. The table is automatically resized
|
8615 |
|
|
+ * although this incurs a performance penalty.
|
8616 |
|
|
+ * @param name the table name.
|
8617 |
|
|
+ * @param free_fn callback function used to free memory for entries
|
8618 |
|
|
+ * when lh_table_free or lh_table_delete is called.
|
8619 |
|
|
+ * If NULL is provided, then memory for keys and values
|
8620 |
|
|
+ * must be freed by the caller.
|
8621 |
|
|
+ * @param hash_fn function used to hash keys. 2 standard ones are defined:
|
8622 |
|
|
+ * lh_ptr_hash and lh_char_hash for hashing pointer values
|
8623 |
|
|
+ * and C strings respectively.
|
8624 |
|
|
+ * @param equal_fn comparison function to compare keys. 2 standard ones defined:
|
8625 |
|
|
+ * lh_ptr_hash and lh_char_hash for comparing pointer values
|
8626 |
|
|
+ * and C strings respectively.
|
8627 |
|
|
+ * @return a pointer onto the linkhash table.
|
8628 |
|
|
+ */
|
8629 |
|
|
+extern struct lh_table* lh_table_new(int size, const char *name,
|
8630 |
|
|
+ lh_entry_free_fn *free_fn,
|
8631 |
|
|
+ lh_hash_fn *hash_fn,
|
8632 |
|
|
+ lh_equal_fn *equal_fn);
|
8633 |
|
|
+
|
8634 |
|
|
+/**
|
8635 |
|
|
+ * Convenience function to create a new linkhash
|
8636 |
|
|
+ * table with char keys.
|
8637 |
|
|
+ * @param size initial table size.
|
8638 |
|
|
+ * @param name table name.
|
8639 |
|
|
+ * @param free_fn callback function used to free memory for entries.
|
8640 |
|
|
+ * @return a pointer onto the linkhash table.
|
8641 |
|
|
+ */
|
8642 |
|
|
+extern struct lh_table* lh_kchar_table_new(int size, const char *name,
|
8643 |
|
|
+ lh_entry_free_fn *free_fn);
|
8644 |
|
|
+
|
8645 |
|
|
+
|
8646 |
|
|
+/**
|
8647 |
|
|
+ * Convenience function to create a new linkhash
|
8648 |
|
|
+ * table with ptr keys.
|
8649 |
|
|
+ * @param size initial table size.
|
8650 |
|
|
+ * @param name table name.
|
8651 |
|
|
+ * @param free_fn callback function used to free memory for entries.
|
8652 |
|
|
+ * @return a pointer onto the linkhash table.
|
8653 |
|
|
+ */
|
8654 |
|
|
+extern struct lh_table* lh_kptr_table_new(int size, const char *name,
|
8655 |
|
|
+ lh_entry_free_fn *free_fn);
|
8656 |
|
|
+
|
8657 |
|
|
+
|
8658 |
|
|
+/**
|
8659 |
|
|
+ * Free a linkhash table.
|
8660 |
|
|
+ * If a callback free function is provided then it is called for all
|
8661 |
|
|
+ * entries in the table.
|
8662 |
|
|
+ * @param t table to free.
|
8663 |
|
|
+ */
|
8664 |
|
|
+extern void lh_table_free(struct lh_table *t);
|
8665 |
|
|
+
|
8666 |
|
|
+
|
8667 |
|
|
+/**
|
8668 |
|
|
+ * Insert a record into the table.
|
8669 |
|
|
+ * @param t the table to insert into.
|
8670 |
|
|
+ * @param k a pointer to the key to insert.
|
8671 |
|
|
+ * @param v a pointer to the value to insert.
|
8672 |
|
|
+ */
|
8673 |
|
|
+extern int lh_table_insert(struct lh_table *t, void *k, const void *v);
|
8674 |
|
|
+
|
8675 |
|
|
+
|
8676 |
|
|
+/**
|
8677 |
|
|
+ * Lookup a record into the table.
|
8678 |
|
|
+ * @param t the table to lookup
|
8679 |
|
|
+ * @param k a pointer to the key to lookup
|
8680 |
|
|
+ * @return a pointer to the record structure of the value or NULL if it does not exist.
|
8681 |
|
|
+ */
|
8682 |
|
|
+extern struct lh_entry* lh_table_lookup_entry(struct lh_table *t, const void *k);
|
8683 |
|
|
+
|
8684 |
|
|
+/**
|
8685 |
|
|
+ * Lookup a record into the table
|
8686 |
|
|
+ * @param t the table to lookup
|
8687 |
|
|
+ * @param k a pointer to the key to lookup
|
8688 |
|
|
+ * @return a pointer to the found value or NULL if it does not exist.
|
8689 |
|
|
+ */
|
8690 |
|
|
+extern const void* lh_table_lookup(struct lh_table *t, const void *k);
|
8691 |
|
|
+
|
8692 |
|
|
+
|
8693 |
|
|
+/**
|
8694 |
|
|
+ * Delete a record from the table.
|
8695 |
|
|
+ * If a callback free function is provided then it is called for the
|
8696 |
|
|
+ * for the item being deleted.
|
8697 |
|
|
+ * @param t the table to delete from.
|
8698 |
|
|
+ * @param e a pointer to the entry to delete.
|
8699 |
|
|
+ * @return 0 if the item was deleted.
|
8700 |
|
|
+ * @return -1 if it was not found.
|
8701 |
|
|
+ */
|
8702 |
|
|
+extern int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e);
|
8703 |
|
|
+
|
8704 |
|
|
+
|
8705 |
|
|
+/**
|
8706 |
|
|
+ * Delete a record from the table.
|
8707 |
|
|
+ * If a callback free function is provided then it is called for the
|
8708 |
|
|
+ * for the item being deleted.
|
8709 |
|
|
+ * @param t the table to delete from.
|
8710 |
|
|
+ * @param k a pointer to the key to delete.
|
8711 |
|
|
+ * @return 0 if the item was deleted.
|
8712 |
|
|
+ * @return -1 if it was not found.
|
8713 |
|
|
+ */
|
8714 |
|
|
+extern int lh_table_delete(struct lh_table *t, const void *k);
|
8715 |
|
|
+
|
8716 |
|
|
+
|
8717 |
|
|
+void lh_abort(const char *msg, ...);
|
8718 |
|
|
+void lh_table_resize(struct lh_table *t, int new_size);
|
8719 |
|
|
+
|
8720 |
|
|
+#endif
|
8721 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/printbuf.c sdcc-src-3.1.0-pblaze/src/json/json/printbuf.c
|
8722 |
|
|
--- sdcc-src-3.1.0/src/json/json/printbuf.c 1970-01-01 01:00:00.000000000 +0100
|
8723 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/printbuf.c 2011-02-07 20:04:46.000000000 +0100
|
8724 |
|
|
@@ -0,0 +1,145 @@
|
8725 |
|
|
+/*
|
8726 |
|
|
+ * $Id: printbuf.c,v 1.5 2006/01/26 02:16:28 mclark Exp $
|
8727 |
|
|
+ *
|
8728 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
8729 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
8730 |
|
|
+ *
|
8731 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
8732 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
8733 |
|
|
+ *
|
8734 |
|
|
+ */
|
8735 |
|
|
+
|
8736 |
|
|
+#include "config.h"
|
8737 |
|
|
+
|
8738 |
|
|
+#include <stdio.h>
|
8739 |
|
|
+#include <stdlib.h>
|
8740 |
|
|
+#include <string.h>
|
8741 |
|
|
+
|
8742 |
|
|
+#if HAVE_STDARG_H
|
8743 |
|
|
+# include <stdarg.h>
|
8744 |
|
|
+#else /* !HAVE_STDARG_H */
|
8745 |
|
|
+# error Not enough var arg support!
|
8746 |
|
|
+#endif /* HAVE_STDARG_H */
|
8747 |
|
|
+
|
8748 |
|
|
+#include "bits.h"
|
8749 |
|
|
+#include "debug.h"
|
8750 |
|
|
+#include "printbuf.h"
|
8751 |
|
|
+
|
8752 |
|
|
+struct printbuf* printbuf_new()
|
8753 |
|
|
+{
|
8754 |
|
|
+ struct printbuf *p;
|
8755 |
|
|
+
|
8756 |
|
|
+ if(!(p = calloc(1, sizeof(struct printbuf)))) return NULL;
|
8757 |
|
|
+ p->size = 32;
|
8758 |
|
|
+ p->bpos = 0;
|
8759 |
|
|
+ if(!(p->buf = malloc(p->size))) {
|
8760 |
|
|
+ free(p);
|
8761 |
|
|
+ return NULL;
|
8762 |
|
|
+ }
|
8763 |
|
|
+ return p;
|
8764 |
|
|
+}
|
8765 |
|
|
+
|
8766 |
|
|
+
|
8767 |
|
|
+int printbuf_memappend(struct printbuf *p, const char *buf, int size)
|
8768 |
|
|
+{
|
8769 |
|
|
+ char *t;
|
8770 |
|
|
+ if(p->size - p->bpos <= size) {
|
8771 |
|
|
+ int new_size = max(p->size * 2, p->bpos + size + 8);
|
8772 |
|
|
+#ifdef PRINTBUF_DEBUG
|
8773 |
|
|
+ MC_DEBUG("printbuf_memappend: realloc "
|
8774 |
|
|
+ "bpos=%d wrsize=%d old_size=%d new_size=%d\n",
|
8775 |
|
|
+ p->bpos, size, p->size, new_size);
|
8776 |
|
|
+#endif /* PRINTBUF_DEBUG */
|
8777 |
|
|
+ if(!(t = realloc(p->buf, new_size))) return -1;
|
8778 |
|
|
+ p->size = new_size;
|
8779 |
|
|
+ p->buf = t;
|
8780 |
|
|
+ }
|
8781 |
|
|
+ memcpy(p->buf + p->bpos, buf, size);
|
8782 |
|
|
+ p->bpos += size;
|
8783 |
|
|
+ p->buf[p->bpos]= '\0';
|
8784 |
|
|
+ return size;
|
8785 |
|
|
+}
|
8786 |
|
|
+
|
8787 |
|
|
+#if !HAVE_VSNPRINTF && defined(WIN32)
|
8788 |
|
|
+# define vsnprintf _vsnprintf
|
8789 |
|
|
+#elif !HAVE_VSNPRINTF /* !HAVE_VSNPRINTF */
|
8790 |
|
|
+# error Need vsnprintf!
|
8791 |
|
|
+#endif /* !HAVE_VSNPRINTF && defined(WIN32) */
|
8792 |
|
|
+
|
8793 |
|
|
+#if !HAVE_VASPRINTF
|
8794 |
|
|
+/* CAW: compliant version of vasprintf */
|
8795 |
|
|
+static int vasprintf(char **buf, const char *fmt, va_list ap)
|
8796 |
|
|
+{
|
8797 |
|
|
+#ifndef WIN32
|
8798 |
|
|
+ static char _T_emptybuffer = '\0';
|
8799 |
|
|
+#endif /* !defined(WIN32) */
|
8800 |
|
|
+ int chars;
|
8801 |
|
|
+ char *b;
|
8802 |
|
|
+
|
8803 |
|
|
+ if(!buf) { return -1; }
|
8804 |
|
|
+
|
8805 |
|
|
+#ifdef WIN32
|
8806 |
|
|
+ chars = _vscprintf(fmt, ap)+1;
|
8807 |
|
|
+#else /* !defined(WIN32) */
|
8808 |
|
|
+ /* CAW: RAWR! We have to hope to god here that vsnprintf doesn't overwrite
|
8809 |
|
|
+ our buffer like on some 64bit sun systems.... but hey, its time to move on */
|
8810 |
|
|
+ chars = vsnprintf(&_T_emptybuffer, 0, fmt, ap)+1;
|
8811 |
|
|
+ if(chars < 0) { chars *= -1; } /* CAW: old glibc versions have this problem */
|
8812 |
|
|
+#endif /* defined(WIN32) */
|
8813 |
|
|
+
|
8814 |
|
|
+ b = (char*)malloc(sizeof(char)*chars);
|
8815 |
|
|
+ if(!b) { return -1; }
|
8816 |
|
|
+
|
8817 |
|
|
+ if((chars = vsprintf(b, fmt, ap)) < 0)
|
8818 |
|
|
+ {
|
8819 |
|
|
+ free(b);
|
8820 |
|
|
+ } else {
|
8821 |
|
|
+ *buf = b;
|
8822 |
|
|
+ }
|
8823 |
|
|
+
|
8824 |
|
|
+ return chars;
|
8825 |
|
|
+}
|
8826 |
|
|
+#endif /* !HAVE_VASPRINTF */
|
8827 |
|
|
+
|
8828 |
|
|
+int sprintbuf(struct printbuf *p, const char *msg, ...)
|
8829 |
|
|
+{
|
8830 |
|
|
+ va_list ap;
|
8831 |
|
|
+ char *t;
|
8832 |
|
|
+ int size;
|
8833 |
|
|
+ char buf[128];
|
8834 |
|
|
+
|
8835 |
|
|
+ /* user stack buffer first */
|
8836 |
|
|
+ va_start(ap, msg);
|
8837 |
|
|
+ size = vsnprintf(buf, 128, msg, ap);
|
8838 |
|
|
+ va_end(ap);
|
8839 |
|
|
+ /* if string is greater than stack buffer, then use dynamic string
|
8840 |
|
|
+ with vasprintf. Note: some implementation of vsnprintf return -1
|
8841 |
|
|
+ if output is truncated whereas some return the number of bytes that
|
8842 |
|
|
+ would have been writen - this code handles both cases. */
|
8843 |
|
|
+ if(size == -1 || size > 127) {
|
8844 |
|
|
+ int ret;
|
8845 |
|
|
+ va_start(ap, msg);
|
8846 |
|
|
+ size = vasprintf(&t, msg, ap);
|
8847 |
|
|
+ va_end(ap);
|
8848 |
|
|
+ if(size == -1) return -1;
|
8849 |
|
|
+ ret = printbuf_memappend(p, t, size);
|
8850 |
|
|
+ free(t);
|
8851 |
|
|
+ return ret;
|
8852 |
|
|
+ } else {
|
8853 |
|
|
+ return printbuf_memappend(p, buf, size);
|
8854 |
|
|
+ }
|
8855 |
|
|
+}
|
8856 |
|
|
+
|
8857 |
|
|
+void printbuf_reset(struct printbuf *p)
|
8858 |
|
|
+{
|
8859 |
|
|
+ p->buf[0] = '\0';
|
8860 |
|
|
+ p->bpos = 0;
|
8861 |
|
|
+}
|
8862 |
|
|
+
|
8863 |
|
|
+void printbuf_free(struct printbuf *p)
|
8864 |
|
|
+{
|
8865 |
|
|
+ if(p) {
|
8866 |
|
|
+ free(p->buf);
|
8867 |
|
|
+ free(p);
|
8868 |
|
|
+ }
|
8869 |
|
|
+}
|
8870 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/json/printbuf.h sdcc-src-3.1.0-pblaze/src/json/json/printbuf.h
|
8871 |
|
|
--- sdcc-src-3.1.0/src/json/json/printbuf.h 1970-01-01 01:00:00.000000000 +0100
|
8872 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/json/printbuf.h 2011-02-07 20:04:44.000000000 +0100
|
8873 |
|
|
@@ -0,0 +1,38 @@
|
8874 |
|
|
+/*
|
8875 |
|
|
+ * $Id: printbuf.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
|
8876 |
|
|
+ *
|
8877 |
|
|
+ * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
8878 |
|
|
+ * Michael Clark <michael@metaparadigm.com>
|
8879 |
|
|
+ *
|
8880 |
|
|
+ * This library is free software; you can redistribute it and/or modify
|
8881 |
|
|
+ * it under the terms of the MIT license. See COPYING for details.
|
8882 |
|
|
+ *
|
8883 |
|
|
+ */
|
8884 |
|
|
+
|
8885 |
|
|
+#ifndef _printbuf_h_
|
8886 |
|
|
+#define _printbuf_h_
|
8887 |
|
|
+
|
8888 |
|
|
+#undef PRINTBUF_DEBUG
|
8889 |
|
|
+
|
8890 |
|
|
+struct printbuf {
|
8891 |
|
|
+ char *buf;
|
8892 |
|
|
+ int bpos;
|
8893 |
|
|
+ int size;
|
8894 |
|
|
+};
|
8895 |
|
|
+
|
8896 |
|
|
+extern struct printbuf*
|
8897 |
|
|
+printbuf_new(void);
|
8898 |
|
|
+
|
8899 |
|
|
+extern int
|
8900 |
|
|
+printbuf_memappend(struct printbuf *p, const char *buf, int size);
|
8901 |
|
|
+
|
8902 |
|
|
+extern int
|
8903 |
|
|
+sprintbuf(struct printbuf *p, const char *msg, ...);
|
8904 |
|
|
+
|
8905 |
|
|
+extern void
|
8906 |
|
|
+printbuf_reset(struct printbuf *p);
|
8907 |
|
|
+
|
8908 |
|
|
+extern void
|
8909 |
|
|
+printbuf_free(struct printbuf *p);
|
8910 |
|
|
+
|
8911 |
|
|
+#endif
|
8912 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/main.c sdcc-src-3.1.0-pblaze/src/json/main.c
|
8913 |
|
|
--- sdcc-src-3.1.0/src/json/main.c 1970-01-01 01:00:00.000000000 +0100
|
8914 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/main.c 2011-02-07 20:04:44.000000000 +0100
|
8915 |
|
|
@@ -0,0 +1,380 @@
|
8916 |
|
|
+/** @file main.c
|
8917 |
|
|
+ json specific general functions.
|
8918 |
|
|
+
|
8919 |
|
|
+ Note that mlh prepended _json_ on the static functions. Makes
|
8920 |
|
|
+ it easier to set a breakpoint using the debugger.
|
8921 |
|
|
+*/
|
8922 |
|
|
+#include "common.h"
|
8923 |
|
|
+#include "main.h"
|
8924 |
|
|
+#include "ralloc.h"
|
8925 |
|
|
+#include "gen.h"
|
8926 |
|
|
+#include "device.h"
|
8927 |
|
|
+
|
8928 |
|
|
+static char _defaultRules[] = {
|
8929 |
|
|
+#include "peeph.rul"
|
8930 |
|
|
+};
|
8931 |
|
|
+
|
8932 |
|
|
+/* list of key words used by msc51 */
|
8933 |
|
|
+static char *_json_keywords[] = {
|
8934 |
|
|
+ "at",
|
8935 |
|
|
+ "code",
|
8936 |
|
|
+ "critical",
|
8937 |
|
|
+ "eeprom",
|
8938 |
|
|
+ "interrupt",
|
8939 |
|
|
+ "sfr",
|
8940 |
|
|
+ "xdata",
|
8941 |
|
|
+ "_code",
|
8942 |
|
|
+ "_eeprom",
|
8943 |
|
|
+ "_generic",
|
8944 |
|
|
+ "_xdata",
|
8945 |
|
|
+ "sram",
|
8946 |
|
|
+ "_sram",
|
8947 |
|
|
+ "flash",
|
8948 |
|
|
+ "_flash",
|
8949 |
|
|
+ NULL
|
8950 |
|
|
+};
|
8951 |
|
|
+
|
8952 |
|
|
+static int regParmFlg = 0; /* determine if we can register a parameter */
|
8953 |
|
|
+json_options_t json_options;
|
8954 |
|
|
+
|
8955 |
|
|
+static void
|
8956 |
|
|
+_json_init (void)
|
8957 |
|
|
+{
|
8958 |
|
|
+ asm_addTree (&asm_asxxxx_mapping);
|
8959 |
|
|
+}
|
8960 |
|
|
+
|
8961 |
|
|
+static void
|
8962 |
|
|
+_json_reset_regparm (void)
|
8963 |
|
|
+{
|
8964 |
|
|
+ regParmFlg = 0;
|
8965 |
|
|
+}
|
8966 |
|
|
+
|
8967 |
|
|
+
|
8968 |
|
|
+void _json_genInitStartup (FILE * of)
|
8969 |
|
|
+{
|
8970 |
|
|
+
|
8971 |
|
|
+}
|
8972 |
|
|
+
|
8973 |
|
|
+
|
8974 |
|
|
+static int
|
8975 |
|
|
+_json_regparm (sym_link * l, bool reentrant)
|
8976 |
|
|
+{
|
8977 |
|
|
+ /* the first eight bytes will be passed in
|
8978 |
|
|
+ registers r16-r23. but we won't split variables
|
8979 |
|
|
+ i.e. if not enough registers left to hold
|
8980 |
|
|
+ the parameter then the whole parameter along
|
8981 |
|
|
+ with rest of the parameters go onto the stack */
|
8982 |
|
|
+ if (regParmFlg < 8) {
|
8983 |
|
|
+ int size;
|
8984 |
|
|
+ if ((size = getSize (l)) > (8 - regParmFlg)) {
|
8985 |
|
|
+ /* all remaining go on stack */
|
8986 |
|
|
+ regParmFlg = 8;
|
8987 |
|
|
+ return 0;
|
8988 |
|
|
+ }
|
8989 |
|
|
+ regParmFlg += size;
|
8990 |
|
|
+ return 1;
|
8991 |
|
|
+ }
|
8992 |
|
|
+
|
8993 |
|
|
+ return 0;
|
8994 |
|
|
+}
|
8995 |
|
|
+
|
8996 |
|
|
+void json_assignRegisters (ebbIndex *);
|
8997 |
|
|
+
|
8998 |
|
|
+#define GEN_JSON "--json"
|
8999 |
|
|
+#define GEN_JSONFILE "--json-file="
|
9000 |
|
|
+#define ISOPT(str) !strncmp(argv[ *i ], str, strlen(str) )
|
9001 |
|
|
+
|
9002 |
|
|
+
|
9003 |
|
|
+
|
9004 |
|
|
+// TODO
|
9005 |
|
|
+OPTION json_optionsTable[]= {
|
9006 |
|
|
+ /* json debugging options */ /* code generation options */
|
9007 |
|
|
+ { 0, GEN_JSON, &json_options.json_flag, "dump iCodes in JSON format"},
|
9008 |
|
|
+ { 0, GEN_JSONFILE, &json_options.json_dumpfile, "JSON output filename"},
|
9009 |
|
|
+ { 0, NULL, NULL, NULL}
|
9010 |
|
|
+};
|
9011 |
|
|
+
|
9012 |
|
|
+static bool
|
9013 |
|
|
+_json_parseOptions (int *pargc, char **argv, int *i)
|
9014 |
|
|
+{
|
9015 |
|
|
+ /* TODO: allow port-specific command line options to specify
|
9016 |
|
|
+ * segment names here.
|
9017 |
|
|
+ */
|
9018 |
|
|
+ int j=0;
|
9019 |
|
|
+ //char *stkmodel;
|
9020 |
|
|
+
|
9021 |
|
|
+ /* check for arguments that have associated an integer variable */
|
9022 |
|
|
+ while(json_optionsTable[j].pparameter) {
|
9023 |
|
|
+ if(ISOPT( json_optionsTable[j].longOpt )) {
|
9024 |
|
|
+ (*(int *)json_optionsTable[j].pparameter)++;
|
9025 |
|
|
+ return TRUE;
|
9026 |
|
|
+ }
|
9027 |
|
|
+ j++;
|
9028 |
|
|
+ }
|
9029 |
|
|
+/*
|
9030 |
|
|
+ if(ISOPT(STACK_MODEL)) {
|
9031 |
|
|
+ stkmodel = getStringArg(STACK_MODEL, argv, i, *pargc);
|
9032 |
|
|
+ if(!STRCASECMP(stkmodel, "small"))picoBlaze_options.stack_model = 0;
|
9033 |
|
|
+ else if(!STRCASECMP(stkmodel, "large"))picoBlaze_options.stack_model = 1;
|
9034 |
|
|
+ else {
|
9035 |
|
|
+ fprintf(stderr, "Unknown stack model: %s", stkmodel);
|
9036 |
|
|
+ exit(EXIT_FAILURE);
|
9037 |
|
|
+ }
|
9038 |
|
|
+ return TRUE;
|
9039 |
|
|
+ }
|
9040 |
|
|
+
|
9041 |
|
|
+ if(ISOPT(IVT_LOC)) {
|
9042 |
|
|
+ picoBlaze_options.ivt_loc = getIntArg(IVT_LOC, argv, i, *pargc);
|
9043 |
|
|
+ fprintf(stderr, "%s:%d setting interrupt vector addresses 0x%x\n", __FILE__, __LINE__, picoBlaze_options.ivt_loc);
|
9044 |
|
|
+ return TRUE;
|
9045 |
|
|
+ }
|
9046 |
|
|
+
|
9047 |
|
|
+ if(ISOPT(USE_CRT)) {
|
9048 |
|
|
+ picoBlaze_options.no_crt = 0;
|
9049 |
|
|
+ picoBlaze_options.crt_name = Safe_strdup( getStringArg(USE_CRT, argv, i, *pargc) );
|
9050 |
|
|
+
|
9051 |
|
|
+ return TRUE;
|
9052 |
|
|
+ }
|
9053 |
|
|
+
|
9054 |
|
|
+ if (ISOPT(NO_OPTIMIZE_GOTO)) {
|
9055 |
|
|
+ picoBlaze_options.opt_flags |= OF_NO_OPTIMIZE_GOTO;
|
9056 |
|
|
+ return TRUE;
|
9057 |
|
|
+ }
|
9058 |
|
|
+
|
9059 |
|
|
+ if(ISOPT(OPTIMIZE_CMP)) {
|
9060 |
|
|
+ picoBlaze_options.opt_flags |= OF_OPTIMIZE_CMP;
|
9061 |
|
|
+ return TRUE;
|
9062 |
|
|
+ }
|
9063 |
|
|
+
|
9064 |
|
|
+ if (ISOPT(OPTIMIZE_DF)) {
|
9065 |
|
|
+ picoBlaze_options.opt_flags |= OF_OPTIMIZE_DF;
|
9066 |
|
|
+ return TRUE;
|
9067 |
|
|
+ }
|
9068 |
|
|
+*/
|
9069 |
|
|
+
|
9070 |
|
|
+ if (ISOPT(GEN_JSON)) {
|
9071 |
|
|
+ json_options.json_flag = TRUE;
|
9072 |
|
|
+ if (ISOPT(GEN_JSONFILE)) { // inside block because JSON and JSON-FILE have common starting substring checked in arguments
|
9073 |
|
|
+ json_options.json_dumpfile = Safe_strdup( getStringArg(GEN_JSONFILE, argv, i, *pargc) );
|
9074 |
|
|
+ }
|
9075 |
|
|
+ return TRUE;
|
9076 |
|
|
+ }
|
9077 |
|
|
+
|
9078 |
|
|
+ return FALSE;
|
9079 |
|
|
+}
|
9080 |
|
|
+
|
9081 |
|
|
+static void
|
9082 |
|
|
+_json_finaliseOptions (void)
|
9083 |
|
|
+{
|
9084 |
|
|
+ port->mem.default_local_map = port->mem.default_globl_map = xdata;
|
9085 |
|
|
+ /* change stack to be in far space */
|
9086 |
|
|
+ /* internal stack segment ;
|
9087 |
|
|
+ SFRSPACE - NO
|
9088 |
|
|
+ FAR-SPACE - YES
|
9089 |
|
|
+ PAGED - NO
|
9090 |
|
|
+ DIRECT-ACCESS - NO
|
9091 |
|
|
+ BIT-ACCESS - NO
|
9092 |
|
|
+ CODE-ACESS - NO
|
9093 |
|
|
+ DEBUG-NAME - 'B'
|
9094 |
|
|
+ POINTER-TYPE - FPOINTER
|
9095 |
|
|
+ */
|
9096 |
|
|
+ istack =
|
9097 |
|
|
+ allocMap (0, 1, 0, 0, 0, 0, options.stack_loc, ISTACK_NAME,
|
9098 |
|
|
+ 'B', FPOINTER);
|
9099 |
|
|
+
|
9100 |
|
|
+ /* also change xdata to be direct space since we can use lds/sts */
|
9101 |
|
|
+ xdata->direct = 1;
|
9102 |
|
|
+
|
9103 |
|
|
+}
|
9104 |
|
|
+
|
9105 |
|
|
+static void
|
9106 |
|
|
+_json_setDefaultOptions (void)
|
9107 |
|
|
+{
|
9108 |
|
|
+ options.stackAuto = 1;
|
9109 |
|
|
+ json_options.json_flag = 0;
|
9110 |
|
|
+ json_options.json_dumpfile = "iCodeDumpFile.txt";
|
9111 |
|
|
+}
|
9112 |
|
|
+
|
9113 |
|
|
+static const char *
|
9114 |
|
|
+_json_getRegName (struct regs *reg)
|
9115 |
|
|
+{
|
9116 |
|
|
+ if (reg)
|
9117 |
|
|
+ return reg->name;
|
9118 |
|
|
+ return "err";
|
9119 |
|
|
+}
|
9120 |
|
|
+
|
9121 |
|
|
+static void
|
9122 |
|
|
+_json_genAssemblerPreamble (FILE * of)
|
9123 |
|
|
+{
|
9124 |
|
|
+
|
9125 |
|
|
+}
|
9126 |
|
|
+
|
9127 |
|
|
+/* Generate interrupt vector table. */
|
9128 |
|
|
+static int
|
9129 |
|
|
+_json_genIVT (struct dbuf_s * oBuf, symbol ** interrupts, int maxInterrupts)
|
9130 |
|
|
+{
|
9131 |
|
|
+ return TRUE;
|
9132 |
|
|
+}
|
9133 |
|
|
+
|
9134 |
|
|
+/* Indicate which extended bit operations this port supports */
|
9135 |
|
|
+static bool
|
9136 |
|
|
+hasExtBitOp (int op, int size)
|
9137 |
|
|
+{
|
9138 |
|
|
+ if (op == RRC
|
9139 |
|
|
+ || op == RLC
|
9140 |
|
|
+ || op == GETHBIT
|
9141 |
|
|
+ )
|
9142 |
|
|
+ return TRUE;
|
9143 |
|
|
+ else
|
9144 |
|
|
+ return FALSE;
|
9145 |
|
|
+}
|
9146 |
|
|
+
|
9147 |
|
|
+/* Indicate the expense of an access to an output storage class */
|
9148 |
|
|
+static int
|
9149 |
|
|
+oclsExpense (struct memmap *oclass)
|
9150 |
|
|
+{
|
9151 |
|
|
+ if (IN_FARSPACE(oclass))
|
9152 |
|
|
+ return 1;
|
9153 |
|
|
+
|
9154 |
|
|
+ return 0;
|
9155 |
|
|
+}
|
9156 |
|
|
+
|
9157 |
|
|
+/** $1 is always the basename.
|
9158 |
|
|
+ $2 is always the output file.
|
9159 |
|
|
+ $3 varies
|
9160 |
|
|
+ $l is the list of extra options that should be there somewhere...
|
9161 |
|
|
+ MUST be terminated with a NULL.
|
9162 |
|
|
+*/
|
9163 |
|
|
+static const char *_linkCmd[] = {
|
9164 |
|
|
+ //"linkjson", "", "\"$1\"", NULL
|
9165 |
|
|
+ NULL
|
9166 |
|
|
+};
|
9167 |
|
|
+
|
9168 |
|
|
+/* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
|
9169 |
|
|
+static const char *_asmCmd[] = {
|
9170 |
|
|
+ //"asjson", "$l" , "$3", "\"$1.s\"", NULL
|
9171 |
|
|
+ NULL
|
9172 |
|
|
+};
|
9173 |
|
|
+
|
9174 |
|
|
+/* Globals */
|
9175 |
|
|
+PORT json_port = {
|
9176 |
|
|
+ TARGET_ID_JSON,
|
9177 |
|
|
+ "json",
|
9178 |
|
|
+ "Json iCodes", /* Target name */
|
9179 |
|
|
+ NULL, /* processor */
|
9180 |
|
|
+ {
|
9181 |
|
|
+ glue,
|
9182 |
|
|
+ TRUE, /* Emit glue around main */
|
9183 |
|
|
+ MODEL_LARGE | MODEL_SMALL,
|
9184 |
|
|
+ MODEL_SMALL,
|
9185 |
|
|
+ NULL, /* model == target */
|
9186 |
|
|
+ },
|
9187 |
|
|
+ {
|
9188 |
|
|
+ _asmCmd,
|
9189 |
|
|
+ NULL,
|
9190 |
|
|
+ "-plosgff", /* Options with debug */
|
9191 |
|
|
+ "-plosgff", /* Options without debug */
|
9192 |
|
|
+ 0,
|
9193 |
|
|
+ ".s",
|
9194 |
|
|
+ NULL, /* no do_assemble */
|
9195 |
|
|
+ },
|
9196 |
|
|
+ {
|
9197 |
|
|
+ NULL,
|
9198 |
|
|
+ NULL,
|
9199 |
|
|
+ NULL,
|
9200 |
|
|
+ ".rel",
|
9201 |
|
|
+ 1},
|
9202 |
|
|
+ {
|
9203 |
|
|
+ _defaultRules},
|
9204 |
|
|
+ {
|
9205 |
|
|
+ /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
|
9206 |
|
|
+ 1, 2, 2, 4, 1, 2, 2, 1, 4, 4},
|
9207 |
|
|
+
|
9208 |
|
|
+ /* tags for generic pointers */
|
9209 |
|
|
+ { 0x00, 0x40, 0x60, 0x80 }, /* far, near, xstack, code */
|
9210 |
|
|
+
|
9211 |
|
|
+ {
|
9212 |
|
|
+ "XSEG",
|
9213 |
|
|
+ "STACK",
|
9214 |
|
|
+ "CSEG",
|
9215 |
|
|
+ "DSEG",
|
9216 |
|
|
+ "ISEG",
|
9217 |
|
|
+ NULL, //PSEG
|
9218 |
|
|
+ "XSEG",
|
9219 |
|
|
+ "BSEG",
|
9220 |
|
|
+ "RSEG",
|
9221 |
|
|
+ "GSINIT",
|
9222 |
|
|
+ "OSEG",
|
9223 |
|
|
+ "GSFINAL",
|
9224 |
|
|
+ "HOME",
|
9225 |
|
|
+ NULL, // initialized xdata
|
9226 |
|
|
+ NULL, // a code copy of xiseg
|
9227 |
|
|
+ "CONST (CODE)", // const_name - const data (code or not)
|
9228 |
|
|
+ "CABS (ABS,CODE)", // cabs_name - const absolute data (code or not)
|
9229 |
|
|
+ "XABS (ABS,XDATA)", // xabs_name - absolute xdata/pdata
|
9230 |
|
|
+ "IABS (ABS,DATA)", // iabs_name - absolute idata/data
|
9231 |
|
|
+ NULL,
|
9232 |
|
|
+ NULL,
|
9233 |
|
|
+ 0,
|
9234 |
|
|
+ },
|
9235 |
|
|
+ { NULL, NULL },
|
9236 |
|
|
+ {
|
9237 |
|
|
+ -1, 1, 4, 1, 1, 0},
|
9238 |
|
|
+ /* pblaze hasn't any mul */
|
9239 |
|
|
+ {
|
9240 |
|
|
+ 1, -1
|
9241 |
|
|
+ },
|
9242 |
|
|
+ {
|
9243 |
|
|
+ json_emitDebuggerSymbol
|
9244 |
|
|
+ },
|
9245 |
|
|
+ {
|
9246 |
|
|
+ 32, /* maxCount */
|
9247 |
|
|
+ 2, /* sizeofElement */
|
9248 |
|
|
+ /* The rest of these costs are bogus. They approximate */
|
9249 |
|
|
+ /* the behavior of src/SDCCicode.c 1.207 and earlier. */
|
9250 |
|
|
+ {2,2,2}, /* sizeofMatchJump[] */
|
9251 |
|
|
+ {0,0,0}, /* sizeofRangeCompare[] */
|
9252 |
|
|
+ 0, /* sizeofSubtract */
|
9253 |
|
|
+ 2, /* sizeofDispatch */
|
9254 |
|
|
+ },
|
9255 |
|
|
+ "_",
|
9256 |
|
|
+ _json_init,
|
9257 |
|
|
+ _json_parseOptions,
|
9258 |
|
|
+ json_optionsTable,
|
9259 |
|
|
+ NULL,
|
9260 |
|
|
+ _json_finaliseOptions,
|
9261 |
|
|
+ _json_setDefaultOptions,
|
9262 |
|
|
+ json_assignRegisters,
|
9263 |
|
|
+ _json_getRegName,
|
9264 |
|
|
+ _json_keywords,
|
9265 |
|
|
+ _json_genAssemblerPreamble,
|
9266 |
|
|
+ NULL, /* no genAssemblerEnd */
|
9267 |
|
|
+ _json_genIVT,
|
9268 |
|
|
+ NULL, // _json_genXINIT
|
9269 |
|
|
+ _json_genInitStartup, /* genInitStartup */
|
9270 |
|
|
+ _json_reset_regparm,
|
9271 |
|
|
+ _json_regparm,
|
9272 |
|
|
+ NULL,
|
9273 |
|
|
+ NULL,
|
9274 |
|
|
+ NULL,
|
9275 |
|
|
+ hasExtBitOp, /* hasExtBitOp */
|
9276 |
|
|
+ oclsExpense, /* oclsExpense */
|
9277 |
|
|
+ FALSE,
|
9278 |
|
|
+ TRUE, /* little endian */
|
9279 |
|
|
+ 0, /* leave lt */
|
9280 |
|
|
+ 1, /* transform gt ==> not le */
|
9281 |
|
|
+ 0, /* leave le */
|
9282 |
|
|
+ 0, /* leave ge */
|
9283 |
|
|
+ 0, /* leave != */
|
9284 |
|
|
+ 0, /* leave == */
|
9285 |
|
|
+ FALSE, /* No array initializer support. */
|
9286 |
|
|
+ 0, /* no CSE cost estimation yet */
|
9287 |
|
|
+ NULL, /* no builtin functions */
|
9288 |
|
|
+ GPOINTER, /* treat unqualified pointers as "generic" pointers */
|
9289 |
|
|
+ 1, /* reset labelKey to 1 */
|
9290 |
|
|
+ 1, /* globals & local static allowed */
|
9291 |
|
|
+ PORT_MAGIC
|
9292 |
|
|
+};
|
9293 |
|
|
+
|
9294 |
|
|
+
|
9295 |
|
|
+
|
9296 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/main.h sdcc-src-3.1.0-pblaze/src/json/main.h
|
9297 |
|
|
--- sdcc-src-3.1.0/src/json/main.h 1970-01-01 01:00:00.000000000 +0100
|
9298 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/main.h 2011-02-07 20:04:48.000000000 +0100
|
9299 |
|
|
@@ -0,0 +1,8 @@
|
9300 |
|
|
+#ifndef MAIN_INCLUDE
|
9301 |
|
|
+#define MAIN_INCLUDE
|
9302 |
|
|
+
|
9303 |
|
|
+bool x_parseOptions (char **argv, int *pargc);
|
9304 |
|
|
+void x_setDefaultOptions (void);
|
9305 |
|
|
+void x_finaliseOptions (void);
|
9306 |
|
|
+
|
9307 |
|
|
+#endif
|
9308 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/peeph.rul sdcc-src-3.1.0-pblaze/src/json/peeph.rul
|
9309 |
|
|
--- sdcc-src-3.1.0/src/json/peeph.rul 1970-01-01 01:00:00.000000000 +0100
|
9310 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/peeph.rul 2011-02-07 20:04:44.000000000 +0100
|
9311 |
|
|
@@ -0,0 +1,1676 @@
|
9312 |
|
|
+/* Generated file, DO NOT Edit! */
|
9313 |
|
|
+/* To Make changes to rules edit */
|
9314 |
|
|
+/* <port>/peeph.def instead. */
|
9315 |
|
|
+"\n"
|
9316 |
|
|
+"\n"
|
9317 |
|
|
+"replace restart {\n"
|
9318 |
|
|
+" xch a,%1\n"
|
9319 |
|
|
+" xch a,%1\n"
|
9320 |
|
|
+"} by {\n"
|
9321 |
|
|
+" ; Peephole 2.a removed redundant xch xch\n"
|
9322 |
|
|
+"}\n"
|
9323 |
|
|
+"\n"
|
9324 |
|
|
+"replace restart {\n"
|
9325 |
|
|
+" mov %1,#0x00\n"
|
9326 |
|
|
+" mov a,#0x00\n"
|
9327 |
|
|
+"} by {\n"
|
9328 |
|
|
+" ; Peephole 3.a changed mov to clr\n"
|
9329 |
|
|
+" clr a\n"
|
9330 |
|
|
+" mov %1,a\n"
|
9331 |
|
|
+"}\n"
|
9332 |
|
|
+"\n"
|
9333 |
|
|
+"replace restart {\n"
|
9334 |
|
|
+" mov %1,#0x00\n"
|
9335 |
|
|
+" clr a\n"
|
9336 |
|
|
+"} by {\n"
|
9337 |
|
|
+" ; Peephole 3.b changed mov to clr\n"
|
9338 |
|
|
+" clr a\n"
|
9339 |
|
|
+" mov %1,a\n"
|
9340 |
|
|
+"}\n"
|
9341 |
|
|
+"\n"
|
9342 |
|
|
+"replace restart {\n"
|
9343 |
|
|
+" mov %1,#0x00\n"
|
9344 |
|
|
+" mov %2,#0x00\n"
|
9345 |
|
|
+" mov a,%3\n"
|
9346 |
|
|
+"} by {\n"
|
9347 |
|
|
+" ; Peephole 3.c changed mov to clr\n"
|
9348 |
|
|
+" clr a\n"
|
9349 |
|
|
+" mov %1,a\n"
|
9350 |
|
|
+" mov %2,a\n"
|
9351 |
|
|
+" mov a,%3\n"
|
9352 |
|
|
+"}\n"
|
9353 |
|
|
+"\n"
|
9354 |
|
|
+"\n"
|
9355 |
|
|
+"\n"
|
9356 |
|
|
+"replace {\n"
|
9357 |
|
|
+" mov %1,a\n"
|
9358 |
|
|
+" mov dptr,#%2\n"
|
9359 |
|
|
+" mov a,%1\n"
|
9360 |
|
|
+" movx @dptr,a\n"
|
9361 |
|
|
+"} by {\n"
|
9362 |
|
|
+" ; Peephole 100 removed redundant mov\n"
|
9363 |
|
|
+" mov %1,a\n"
|
9364 |
|
|
+" mov dptr,#%2\n"
|
9365 |
|
|
+" movx @dptr,a\n"
|
9366 |
|
|
+"}\n"
|
9367 |
|
|
+"\n"
|
9368 |
|
|
+"replace {\n"
|
9369 |
|
|
+" mov a,acc\n"
|
9370 |
|
|
+"} by {\n"
|
9371 |
|
|
+" ; Peephole 100.a removed redundant mov\n"
|
9372 |
|
|
+"}\n"
|
9373 |
|
|
+"\n"
|
9374 |
|
|
+"replace {\n"
|
9375 |
|
|
+" mov a,%1\n"
|
9376 |
|
|
+" movx @dptr,a\n"
|
9377 |
|
|
+" inc dptr\n"
|
9378 |
|
|
+" mov a,%1\n"
|
9379 |
|
|
+" movx @dptr,a\n"
|
9380 |
|
|
+"} by {\n"
|
9381 |
|
|
+" ; Peephole 101 removed redundant mov\n"
|
9382 |
|
|
+" mov a,%1\n"
|
9383 |
|
|
+" movx @dptr,a\n"
|
9384 |
|
|
+" inc dptr\n"
|
9385 |
|
|
+" movx @dptr,a\n"
|
9386 |
|
|
+"}\n"
|
9387 |
|
|
+"\n"
|
9388 |
|
|
+"replace {\n"
|
9389 |
|
|
+" mov %1,%2\n"
|
9390 |
|
|
+" ljmp %3\n"
|
9391 |
|
|
+"%4:\n"
|
9392 |
|
|
+" mov %1,%5\n"
|
9393 |
|
|
+"%3:\n"
|
9394 |
|
|
+" mov dpl,%1\n"
|
9395 |
|
|
+"%7:\n"
|
9396 |
|
|
+" mov sp,bp\n"
|
9397 |
|
|
+" pop bp\n"
|
9398 |
|
|
+"} by {\n"
|
9399 |
|
|
+" ; Peephole 102 removed redundant mov\n"
|
9400 |
|
|
+" mov dpl,%2\n"
|
9401 |
|
|
+" ljmp %3\n"
|
9402 |
|
|
+"%4:\n"
|
9403 |
|
|
+" mov dpl,%5\n"
|
9404 |
|
|
+"%3:\n"
|
9405 |
|
|
+"%7:\n"
|
9406 |
|
|
+" mov sp,bp\n"
|
9407 |
|
|
+" pop bp\n"
|
9408 |
|
|
+"}\n"
|
9409 |
|
|
+"\n"
|
9410 |
|
|
+"replace {\n"
|
9411 |
|
|
+" mov %1,%2\n"
|
9412 |
|
|
+" ljmp %3\n"
|
9413 |
|
|
+"%4:\n"
|
9414 |
|
|
+" mov a%1,%5\n"
|
9415 |
|
|
+"%3:\n"
|
9416 |
|
|
+" mov dpl,%1\n"
|
9417 |
|
|
+"%7:\n"
|
9418 |
|
|
+" mov sp,bp\n"
|
9419 |
|
|
+" pop bp\n"
|
9420 |
|
|
+"} by {\n"
|
9421 |
|
|
+" ; Peephole 103 removed redundant mov\n"
|
9422 |
|
|
+" mov dpl,%2\n"
|
9423 |
|
|
+" ljmp %3\n"
|
9424 |
|
|
+"%4:\n"
|
9425 |
|
|
+" mov dpl,%5\n"
|
9426 |
|
|
+"%3:\n"
|
9427 |
|
|
+"%7:\n"
|
9428 |
|
|
+" mov sp,bp\n"
|
9429 |
|
|
+" pop bp\n"
|
9430 |
|
|
+"}\n"
|
9431 |
|
|
+"\n"
|
9432 |
|
|
+"replace {\n"
|
9433 |
|
|
+" mov a,bp\n"
|
9434 |
|
|
+" clr c\n"
|
9435 |
|
|
+" add a,#0x01\n"
|
9436 |
|
|
+" mov r%1,a\n"
|
9437 |
|
|
+"} by {\n"
|
9438 |
|
|
+" ; Peephole 104 optimized increment (acc not set to r%1, flags undefined)\n"
|
9439 |
|
|
+" mov r%1,bp\n"
|
9440 |
|
|
+" inc r%1\n"
|
9441 |
|
|
+"}\n"
|
9442 |
|
|
+"\n"
|
9443 |
|
|
+"replace {\n"
|
9444 |
|
|
+" mov %1,a\n"
|
9445 |
|
|
+" mov a,%1\n"
|
9446 |
|
|
+"} by {\n"
|
9447 |
|
|
+" ; Peephole 105 removed redundant mov\n"
|
9448 |
|
|
+" mov %1,a\n"
|
9449 |
|
|
+"}\n"
|
9450 |
|
|
+"\n"
|
9451 |
|
|
+"replace {\n"
|
9452 |
|
|
+" mov %1,a\n"
|
9453 |
|
|
+" clr c\n"
|
9454 |
|
|
+" mov a,%1\n"
|
9455 |
|
|
+"} by {\n"
|
9456 |
|
|
+" ; Peephole 106 removed redundant mov \n"
|
9457 |
|
|
+" mov %1,a\n"
|
9458 |
|
|
+" clr c\n"
|
9459 |
|
|
+"}\n"
|
9460 |
|
|
+"\n"
|
9461 |
|
|
+"replace {\n"
|
9462 |
|
|
+" ljmp %1\n"
|
9463 |
|
|
+"%1:\n"
|
9464 |
|
|
+"} by {\n"
|
9465 |
|
|
+" ; Peephole 107 removed redundant ljmp\n"
|
9466 |
|
|
+"%1:\n"
|
9467 |
|
|
+"}\n"
|
9468 |
|
|
+"\n"
|
9469 |
|
|
+"replace {\n"
|
9470 |
|
|
+" jc %1\n"
|
9471 |
|
|
+" ljmp %5\n"
|
9472 |
|
|
+"%1:\n"
|
9473 |
|
|
+"} by {\n"
|
9474 |
|
|
+" ; Peephole 108 removed ljmp by inverse jump logic\n"
|
9475 |
|
|
+" jnc %5\n"
|
9476 |
|
|
+"%1:\n"
|
9477 |
|
|
+"} if labelInRange\n"
|
9478 |
|
|
+"\n"
|
9479 |
|
|
+"replace {\n"
|
9480 |
|
|
+" jz %1\n"
|
9481 |
|
|
+" ljmp %5\n"
|
9482 |
|
|
+"%1:\n"
|
9483 |
|
|
+"} by {\n"
|
9484 |
|
|
+" ; Peephole 109 removed ljmp by inverse jump logic\n"
|
9485 |
|
|
+" jnz %5\n"
|
9486 |
|
|
+"%1:\n"
|
9487 |
|
|
+"} if labelInRange\n"
|
9488 |
|
|
+"\n"
|
9489 |
|
|
+"replace {\n"
|
9490 |
|
|
+" jnz %1\n"
|
9491 |
|
|
+" ljmp %5\n"
|
9492 |
|
|
+"%1:\n"
|
9493 |
|
|
+"} by {\n"
|
9494 |
|
|
+" ; Peephole 110 removed ljmp by inverse jump logic\n"
|
9495 |
|
|
+" jz %5\n"
|
9496 |
|
|
+"%1:\n"
|
9497 |
|
|
+"} if labelInRange\n"
|
9498 |
|
|
+"\n"
|
9499 |
|
|
+"replace {\n"
|
9500 |
|
|
+" jb %1,%2\n"
|
9501 |
|
|
+" ljmp %5\n"
|
9502 |
|
|
+"%2:\n"
|
9503 |
|
|
+"} by {\n"
|
9504 |
|
|
+" ; Peephole 111 removed ljmp by inverse jump logic\n"
|
9505 |
|
|
+" jnb %1,%5\n"
|
9506 |
|
|
+"%2:\n"
|
9507 |
|
|
+"} if labelInRange\n"
|
9508 |
|
|
+"\n"
|
9509 |
|
|
+"replace {\n"
|
9510 |
|
|
+" jnb %1,%2\n"
|
9511 |
|
|
+" ljmp %5\n"
|
9512 |
|
|
+"%2:\n"
|
9513 |
|
|
+"} by {\n"
|
9514 |
|
|
+" ; Peephole 112 removed ljmp by inverse jump logic\n"
|
9515 |
|
|
+" jb %1,%5\n"
|
9516 |
|
|
+"%2:\n"
|
9517 |
|
|
+"} if labelInRange\n"
|
9518 |
|
|
+"\n"
|
9519 |
|
|
+"replace {\n"
|
9520 |
|
|
+" ljmp %5\n"
|
9521 |
|
|
+"%1:\n"
|
9522 |
|
|
+"} by {\n"
|
9523 |
|
|
+" ; Peephole 132 changed ljmp to sjmp\n"
|
9524 |
|
|
+" sjmp %5\n"
|
9525 |
|
|
+"%1:\n"
|
9526 |
|
|
+"} if labelInRange\n"
|
9527 |
|
|
+"\n"
|
9528 |
|
|
+"\n"
|
9529 |
|
|
+"replace {\n"
|
9530 |
|
|
+" clr a\n"
|
9531 |
|
|
+" cjne %1,%2,%3\n"
|
9532 |
|
|
+" cpl a\n"
|
9533 |
|
|
+"%3:\n"
|
9534 |
|
|
+" rrc a\n"
|
9535 |
|
|
+" mov %4,c\n"
|
9536 |
|
|
+"} by {\n"
|
9537 |
|
|
+" ; Peephole 113 optimized misc sequence\n"
|
9538 |
|
|
+" clr %4\n"
|
9539 |
|
|
+" cjne %1,%2,%3\n"
|
9540 |
|
|
+" setb %4\n"
|
9541 |
|
|
+"%3:\n"
|
9542 |
|
|
+"}\n"
|
9543 |
|
|
+"\n"
|
9544 |
|
|
+"replace {\n"
|
9545 |
|
|
+" clr a\n"
|
9546 |
|
|
+" cjne %1,%2,%3\n"
|
9547 |
|
|
+" cjne %10,%11,%3\n"
|
9548 |
|
|
+" cpl a\n"
|
9549 |
|
|
+"%3:\n"
|
9550 |
|
|
+" rrc a\n"
|
9551 |
|
|
+" mov %4,c\n"
|
9552 |
|
|
+"} by {\n"
|
9553 |
|
|
+" ; Peephole 114 optimized misc sequence\n"
|
9554 |
|
|
+" clr %4\n"
|
9555 |
|
|
+" cjne %1,%2,%3\n"
|
9556 |
|
|
+" cjne %10,%11,%3\n"
|
9557 |
|
|
+" setb %4\n"
|
9558 |
|
|
+"%3:\n"
|
9559 |
|
|
+"}\n"
|
9560 |
|
|
+"\n"
|
9561 |
|
|
+"replace {\n"
|
9562 |
|
|
+" clr a\n"
|
9563 |
|
|
+" cjne %1,%2,%3\n"
|
9564 |
|
|
+" cpl a\n"
|
9565 |
|
|
+"%3:\n"
|
9566 |
|
|
+" jnz %4\n"
|
9567 |
|
|
+"} by {\n"
|
9568 |
|
|
+" ; Peephole 115 jump optimization \n"
|
9569 |
|
|
+" cjne %1,%2,%3\n"
|
9570 |
|
|
+" sjmp %4\n"
|
9571 |
|
|
+"%3:\n"
|
9572 |
|
|
+"}\n"
|
9573 |
|
|
+"\n"
|
9574 |
|
|
+"replace {\n"
|
9575 |
|
|
+" clr a\n"
|
9576 |
|
|
+" cjne %1,%2,%3\n"
|
9577 |
|
|
+" cjne %9,%10,%3\n"
|
9578 |
|
|
+" cpl a\n"
|
9579 |
|
|
+"%3:\n"
|
9580 |
|
|
+" jnz %4\n"
|
9581 |
|
|
+"} by {\n"
|
9582 |
|
|
+" ; Peephole 116 jump optimization\n"
|
9583 |
|
|
+" cjne %1,%2,%3\n"
|
9584 |
|
|
+" cjne %9,%10,%3\n"
|
9585 |
|
|
+" sjmp %4\n"
|
9586 |
|
|
+"%3:\n"
|
9587 |
|
|
+"}\n"
|
9588 |
|
|
+"\n"
|
9589 |
|
|
+"replace {\n"
|
9590 |
|
|
+" clr a\n"
|
9591 |
|
|
+" cjne %1,%2,%3\n"
|
9592 |
|
|
+" cjne %9,%10,%3\n"
|
9593 |
|
|
+" cjne %11,%12,%3\n"
|
9594 |
|
|
+" cpl a\n"
|
9595 |
|
|
+"%3:\n"
|
9596 |
|
|
+" jnz %4\n"
|
9597 |
|
|
+"} by {\n"
|
9598 |
|
|
+" ; Peephole 117 jump optimization\n"
|
9599 |
|
|
+" cjne %1,%2,%3\n"
|
9600 |
|
|
+" cjne %9,%10,%3\n"
|
9601 |
|
|
+" cjne %11,%12,%3\n"
|
9602 |
|
|
+" sjmp %4\n"
|
9603 |
|
|
+"%3:\n"
|
9604 |
|
|
+"}\n"
|
9605 |
|
|
+"\n"
|
9606 |
|
|
+"replace {\n"
|
9607 |
|
|
+" clr a\n"
|
9608 |
|
|
+" cjne %1,%2,%3\n"
|
9609 |
|
|
+" cjne %9,%10,%3\n"
|
9610 |
|
|
+" cjne %11,%12,%3\n"
|
9611 |
|
|
+" cjne %13,%14,%3\n"
|
9612 |
|
|
+" cpl a\n"
|
9613 |
|
|
+"%3:\n"
|
9614 |
|
|
+" jnz %4\n"
|
9615 |
|
|
+"} by {\n"
|
9616 |
|
|
+" ; Peephole 118 jump optimization\n"
|
9617 |
|
|
+" cjne %1,%2,%3\n"
|
9618 |
|
|
+" cjne %9,%10,%3\n"
|
9619 |
|
|
+" cjne %11,%12,%3\n"
|
9620 |
|
|
+" cjne %13,%14,%3\n"
|
9621 |
|
|
+" sjmp %4\n"
|
9622 |
|
|
+"%3:\n"
|
9623 |
|
|
+"}\n"
|
9624 |
|
|
+"replace {\n"
|
9625 |
|
|
+" mov a,#0x01\n"
|
9626 |
|
|
+" cjne %1,%2,%3\n"
|
9627 |
|
|
+" clr a\n"
|
9628 |
|
|
+"%3:\n"
|
9629 |
|
|
+" jnz %4\n"
|
9630 |
|
|
+"} by {\n"
|
9631 |
|
|
+" ; Peephole 119 jump optimization\n"
|
9632 |
|
|
+" cjne %1,%2,%4\n"
|
9633 |
|
|
+"%3:\n"
|
9634 |
|
|
+"}\n"
|
9635 |
|
|
+"\n"
|
9636 |
|
|
+"replace {\n"
|
9637 |
|
|
+" mov a,#0x01\n"
|
9638 |
|
|
+" cjne %1,%2,%3\n"
|
9639 |
|
|
+" cjne %10,%11,%3\n"
|
9640 |
|
|
+" clr a\n"
|
9641 |
|
|
+"%3:\n"
|
9642 |
|
|
+" jnz %4\n"
|
9643 |
|
|
+"} by {\n"
|
9644 |
|
|
+" ; Peephole 120 jump optimization\n"
|
9645 |
|
|
+" cjne %1,%2,%4\n"
|
9646 |
|
|
+" cjne %10,%11,%4\n"
|
9647 |
|
|
+"%3:\n"
|
9648 |
|
|
+"}\n"
|
9649 |
|
|
+"replace {\n"
|
9650 |
|
|
+" mov a,#0x01\n"
|
9651 |
|
|
+" cjne %1,%2,%3\n"
|
9652 |
|
|
+" cjne %10,%11,%3\n"
|
9653 |
|
|
+" cjne %12,%13,%3\n"
|
9654 |
|
|
+" clr a\n"
|
9655 |
|
|
+"%3:\n"
|
9656 |
|
|
+" jnz %4\n"
|
9657 |
|
|
+"} by {\n"
|
9658 |
|
|
+" ; Peephole 121 jump optimization\n"
|
9659 |
|
|
+" cjne %1,%2,%4\n"
|
9660 |
|
|
+" cjne %10,%11,%4\n"
|
9661 |
|
|
+" cjne %12,%13,%4\n"
|
9662 |
|
|
+"%3:\n"
|
9663 |
|
|
+"}\n"
|
9664 |
|
|
+"\n"
|
9665 |
|
|
+"replace {\n"
|
9666 |
|
|
+" mov a,#0x01\n"
|
9667 |
|
|
+" cjne %1,%2,%3\n"
|
9668 |
|
|
+" cjne %10,%11,%3\n"
|
9669 |
|
|
+" cjne %12,%13,%3\n"
|
9670 |
|
|
+" cjne %14,%15,%3\n"
|
9671 |
|
|
+" clr a\n"
|
9672 |
|
|
+"%3:\n"
|
9673 |
|
|
+" jnz %4\n"
|
9674 |
|
|
+"} by {\n"
|
9675 |
|
|
+" ; Peephole 122 jump optimization\n"
|
9676 |
|
|
+" cjne %1,%2,%4\n"
|
9677 |
|
|
+" cjne %10,%11,%4\n"
|
9678 |
|
|
+" cjne %12,%13,%4\n"
|
9679 |
|
|
+" cjne %14,%15,%4\n"
|
9680 |
|
|
+"%3:\n"
|
9681 |
|
|
+"}\n"
|
9682 |
|
|
+"\n"
|
9683 |
|
|
+"replace {\n"
|
9684 |
|
|
+" mov a,#0x01\n"
|
9685 |
|
|
+" cjne %1,%2,%3\n"
|
9686 |
|
|
+" clr a\n"
|
9687 |
|
|
+"%3:\n"
|
9688 |
|
|
+" jz %4\n"
|
9689 |
|
|
+"} by {\n"
|
9690 |
|
|
+" ; Peephole 123 jump optimization\n"
|
9691 |
|
|
+" cjne %1,%2,%3\n"
|
9692 |
|
|
+" smp %4\n"
|
9693 |
|
|
+"%3:\n"
|
9694 |
|
|
+"}\n"
|
9695 |
|
|
+"replace {\n"
|
9696 |
|
|
+" mov a,#0x01\n"
|
9697 |
|
|
+" cjne %1,%2,%3\n"
|
9698 |
|
|
+" cjne %10,%11,%3\n"
|
9699 |
|
|
+" clr a\n"
|
9700 |
|
|
+"%3:\n"
|
9701 |
|
|
+" jz %4\n"
|
9702 |
|
|
+"} by {\n"
|
9703 |
|
|
+" ; Peephole 124 jump optimization\n"
|
9704 |
|
|
+" cjne %1,%2,%3\n"
|
9705 |
|
|
+" cjne %10,%11,%3\n"
|
9706 |
|
|
+" smp %4\n"
|
9707 |
|
|
+"%3:\n"
|
9708 |
|
|
+"}\n"
|
9709 |
|
|
+"\n"
|
9710 |
|
|
+"replace {\n"
|
9711 |
|
|
+" mov a,#0x01\n"
|
9712 |
|
|
+" cjne %1,%2,%3\n"
|
9713 |
|
|
+" cjne %10,%11,%3\n"
|
9714 |
|
|
+" cjne %12,%13,%3\n"
|
9715 |
|
|
+" clr a\n"
|
9716 |
|
|
+"%3:\n"
|
9717 |
|
|
+" jz %4\n"
|
9718 |
|
|
+"} by {\n"
|
9719 |
|
|
+" ; Peephole 125 jump optimization\n"
|
9720 |
|
|
+" cjne %1,%2,%3\n"
|
9721 |
|
|
+" cjne %10,%11,%3\n"
|
9722 |
|
|
+" cjne %12,%13,%3\n"
|
9723 |
|
|
+" sjmp %4\n"
|
9724 |
|
|
+"%3:\n"
|
9725 |
|
|
+"}\n"
|
9726 |
|
|
+"\n"
|
9727 |
|
|
+"replace {\n"
|
9728 |
|
|
+" mov a,#0x01\n"
|
9729 |
|
|
+" cjne %1,%2,%3\n"
|
9730 |
|
|
+" cjne %10,%11,%3\n"
|
9731 |
|
|
+" cjne %12,%13,%3\n"
|
9732 |
|
|
+" cjne %14,%15,%3\n"
|
9733 |
|
|
+" clr a\n"
|
9734 |
|
|
+"%3:\n"
|
9735 |
|
|
+" jz %4\n"
|
9736 |
|
|
+"} by {\n"
|
9737 |
|
|
+" ; Peephole 126 jump optimization\n"
|
9738 |
|
|
+" cjne %1,%2,%3\n"
|
9739 |
|
|
+" cjne %10,%11,%3\n"
|
9740 |
|
|
+" cjne %12,%13,%3\n"
|
9741 |
|
|
+" cjne %14,%15,%3\n"
|
9742 |
|
|
+" sjmp %4\n"
|
9743 |
|
|
+"%3:\n"
|
9744 |
|
|
+"}\n"
|
9745 |
|
|
+"\n"
|
9746 |
|
|
+"replace {\n"
|
9747 |
|
|
+" push psw\n"
|
9748 |
|
|
+" mov psw,%1\n"
|
9749 |
|
|
+" push bp\n"
|
9750 |
|
|
+" mov bp,%2\n"
|
9751 |
|
|
+"%3:\n"
|
9752 |
|
|
+" mov %2,bp\n"
|
9753 |
|
|
+" pop bp\n"
|
9754 |
|
|
+" pop psw\n"
|
9755 |
|
|
+" ret\n"
|
9756 |
|
|
+"} by {\n"
|
9757 |
|
|
+" ; Peephole 127 removed misc sequence\n"
|
9758 |
|
|
+" ret\n"
|
9759 |
|
|
+"}\n"
|
9760 |
|
|
+"\n"
|
9761 |
|
|
+"replace {\n"
|
9762 |
|
|
+" clr a\n"
|
9763 |
|
|
+" rlc a\n"
|
9764 |
|
|
+" jz %1\n"
|
9765 |
|
|
+"} by {\n"
|
9766 |
|
|
+" ; Peephole 128 jump optimization\n"
|
9767 |
|
|
+" jnc %1\n"
|
9768 |
|
|
+"}\n"
|
9769 |
|
|
+"\n"
|
9770 |
|
|
+"replace {\n"
|
9771 |
|
|
+" clr a\n"
|
9772 |
|
|
+" rlc a\n"
|
9773 |
|
|
+" jnz %1\n"
|
9774 |
|
|
+"} by {\n"
|
9775 |
|
|
+" ; Peephole 129 jump optimization\n"
|
9776 |
|
|
+" jc %1\n"
|
9777 |
|
|
+"}\n"
|
9778 |
|
|
+"\n"
|
9779 |
|
|
+"replace { \n"
|
9780 |
|
|
+" mov r%1,@r%2\n"
|
9781 |
|
|
+"} by {\n"
|
9782 |
|
|
+" ; Peephole 130 changed target address mode r%1 to ar%1\n"
|
9783 |
|
|
+" mov ar%1,@r%2\n"
|
9784 |
|
|
+"}\n"
|
9785 |
|
|
+"\n"
|
9786 |
|
|
+"replace { \n"
|
9787 |
|
|
+" mov a,%1\n"
|
9788 |
|
|
+" subb a,#0x01\n"
|
9789 |
|
|
+" mov %2,a\n"
|
9790 |
|
|
+" mov %1,%2\n"
|
9791 |
|
|
+"} by {\n"
|
9792 |
|
|
+" ; Peephole 131 optimized decrement (not caring for c)\n"
|
9793 |
|
|
+" dec %1 \n"
|
9794 |
|
|
+" mov %2,%1 \n"
|
9795 |
|
|
+"}\n"
|
9796 |
|
|
+"\n"
|
9797 |
|
|
+"replace {\n"
|
9798 |
|
|
+" mov r%1,%2\n"
|
9799 |
|
|
+" mov ar%3,@r%1\n"
|
9800 |
|
|
+" inc r%3\n"
|
9801 |
|
|
+" mov r%4,%2\n"
|
9802 |
|
|
+" mov @r%4,ar%3\n"
|
9803 |
|
|
+"} by {\n"
|
9804 |
|
|
+" ; Peephole 133 removed redundant moves\n"
|
9805 |
|
|
+" mov r%1,%2\n"
|
9806 |
|
|
+" inc @r%1\n"
|
9807 |
|
|
+" mov ar%3,@r%1\n"
|
9808 |
|
|
+"}\n"
|
9809 |
|
|
+"\n"
|
9810 |
|
|
+"replace {\n"
|
9811 |
|
|
+" mov r%1,%2\n"
|
9812 |
|
|
+" mov ar%3,@r%1\n"
|
9813 |
|
|
+" dec r%3\n"
|
9814 |
|
|
+" mov r%4,%2\n"
|
9815 |
|
|
+" mov @r%4,ar%3\n"
|
9816 |
|
|
+"} by {\n"
|
9817 |
|
|
+" ; Peephole 134 removed redundant moves\n"
|
9818 |
|
|
+" mov r%1,%2\n"
|
9819 |
|
|
+" dec @r%1\n"
|
9820 |
|
|
+" mov ar%3,@r%1\n"
|
9821 |
|
|
+"}\n"
|
9822 |
|
|
+"\n"
|
9823 |
|
|
+"replace {\n"
|
9824 |
|
|
+" mov r%1,a\n"
|
9825 |
|
|
+" mov a,r%2\n"
|
9826 |
|
|
+" orl a,r%1\n"
|
9827 |
|
|
+"} by {\n"
|
9828 |
|
|
+" ; Peephole 135 removed redundant mov\n"
|
9829 |
|
|
+" mov r%1,a\n"
|
9830 |
|
|
+" orl a,r%2\n"
|
9831 |
|
|
+"}\n"
|
9832 |
|
|
+"\n"
|
9833 |
|
|
+"replace {\n"
|
9834 |
|
|
+" mov %1,a\n"
|
9835 |
|
|
+" mov dpl,%2\n"
|
9836 |
|
|
+" mov dph,%3\n"
|
9837 |
|
|
+" mov dpx,%4\n"
|
9838 |
|
|
+" mov a,%1\n"
|
9839 |
|
|
+"} by {\n"
|
9840 |
|
|
+" ; Peephole 136a removed redundant moves\n"
|
9841 |
|
|
+" mov %1,a\n"
|
9842 |
|
|
+" mov dpl,%2\n"
|
9843 |
|
|
+" mov dph,%3\n"
|
9844 |
|
|
+" mov dpx,%4\n"
|
9845 |
|
|
+"} if 24bitMode\n"
|
9846 |
|
|
+"\n"
|
9847 |
|
|
+"replace {\n"
|
9848 |
|
|
+" mov %1,a\n"
|
9849 |
|
|
+" mov dpl,%2\n"
|
9850 |
|
|
+" mov dph,%3\n"
|
9851 |
|
|
+" mov a,%1\n"
|
9852 |
|
|
+"} by {\n"
|
9853 |
|
|
+" ; Peephole 136 removed redundant moves\n"
|
9854 |
|
|
+" mov %1,a\n"
|
9855 |
|
|
+" mov dpl,%2\n"
|
9856 |
|
|
+" mov dph,%3\n"
|
9857 |
|
|
+"}\n"
|
9858 |
|
|
+"\n"
|
9859 |
|
|
+"replace {\n"
|
9860 |
|
|
+" mov b,#0x00\n"
|
9861 |
|
|
+" mov a,%1\n"
|
9862 |
|
|
+" cjne %2,%3,%4\n"
|
9863 |
|
|
+" mov b,#0x01\n"
|
9864 |
|
|
+"%4:\n"
|
9865 |
|
|
+" mov a,b\n"
|
9866 |
|
|
+" jz %5\n"
|
9867 |
|
|
+"} by {\n"
|
9868 |
|
|
+" ; Peephole 137 optimized misc jump sequence\n"
|
9869 |
|
|
+" mov a,%1\n"
|
9870 |
|
|
+" cjne %2,%3,%5\n"
|
9871 |
|
|
+"%4:\n"
|
9872 |
|
|
+"}\n"
|
9873 |
|
|
+"\n"
|
9874 |
|
|
+"replace {\n"
|
9875 |
|
|
+" mov b,#0x00\n"
|
9876 |
|
|
+" mov a,%1\n"
|
9877 |
|
|
+" cjne %2,%3,%4\n"
|
9878 |
|
|
+" mov b,#0x01\n"
|
9879 |
|
|
+"%4:\n"
|
9880 |
|
|
+" mov a,b\n"
|
9881 |
|
|
+" jnz %5\n"
|
9882 |
|
|
+"} by {\n"
|
9883 |
|
|
+" ; Peephole 138 optimized misc jump sequence\n"
|
9884 |
|
|
+" mov a,%1\n"
|
9885 |
|
|
+" cjne %2,%3,%4\n"
|
9886 |
|
|
+" sjmp %5\n"
|
9887 |
|
|
+"%4:\n"
|
9888 |
|
|
+"}\n"
|
9889 |
|
|
+"\n"
|
9890 |
|
|
+"replace {\n"
|
9891 |
|
|
+" mov r%1,a\n"
|
9892 |
|
|
+" anl ar%1,%2\n"
|
9893 |
|
|
+" mov a,r%1\n"
|
9894 |
|
|
+"} by {\n"
|
9895 |
|
|
+" ; Peephole 139 removed redundant mov\n"
|
9896 |
|
|
+" anl a,%2\n"
|
9897 |
|
|
+" mov r%1,a\n"
|
9898 |
|
|
+"}\n"
|
9899 |
|
|
+"\n"
|
9900 |
|
|
+"replace {\n"
|
9901 |
|
|
+" mov r%1,a\n"
|
9902 |
|
|
+" orl ar%1,%2\n"
|
9903 |
|
|
+" mov a,r%1\n"
|
9904 |
|
|
+"} by {\n"
|
9905 |
|
|
+" ; Peephole 140 removed redundant mov\n"
|
9906 |
|
|
+" orl a,%2\n"
|
9907 |
|
|
+" mov r%1,a }\n"
|
9908 |
|
|
+"\n"
|
9909 |
|
|
+"replace {\n"
|
9910 |
|
|
+" mov r%1,a\n"
|
9911 |
|
|
+" xrl ar%1,%2\n"
|
9912 |
|
|
+" mov a,r%1\n"
|
9913 |
|
|
+"} by {\n"
|
9914 |
|
|
+" ; Peephole 141 removed redundant mov\n"
|
9915 |
|
|
+" xrl a,%2\n"
|
9916 |
|
|
+" mov r%1,a\n"
|
9917 |
|
|
+"}\n"
|
9918 |
|
|
+"\n"
|
9919 |
|
|
+"replace {\n"
|
9920 |
|
|
+" mov r%1,a\n"
|
9921 |
|
|
+" mov r%2,ar%1\n"
|
9922 |
|
|
+" mov ar%1,@r%2\n"
|
9923 |
|
|
+"} by {\n"
|
9924 |
|
|
+" ; Peephole 142 removed redundant moves\n"
|
9925 |
|
|
+" mov r%2,a\n"
|
9926 |
|
|
+" mov ar%1,@r%2\n"
|
9927 |
|
|
+"}\n"
|
9928 |
|
|
+"\n"
|
9929 |
|
|
+"replace {\n"
|
9930 |
|
|
+" rlc a\n"
|
9931 |
|
|
+" mov acc.0,c\n"
|
9932 |
|
|
+"} by {\n"
|
9933 |
|
|
+" ; Peephole 143 converted rlc to rl\n"
|
9934 |
|
|
+" rl a\n"
|
9935 |
|
|
+"}\n"
|
9936 |
|
|
+"\n"
|
9937 |
|
|
+"replace {\n"
|
9938 |
|
|
+" rrc a\n"
|
9939 |
|
|
+" mov acc.7,c\n"
|
9940 |
|
|
+"} by {\n"
|
9941 |
|
|
+" ; Peephole 144 converted rrc to rc\n"
|
9942 |
|
|
+" rr a\n"
|
9943 |
|
|
+"}\n"
|
9944 |
|
|
+"\n"
|
9945 |
|
|
+"replace {\n"
|
9946 |
|
|
+" clr c\n"
|
9947 |
|
|
+" addc a,%1\n"
|
9948 |
|
|
+"} by {\n"
|
9949 |
|
|
+" ; Peephole 145 changed to add without carry \n"
|
9950 |
|
|
+" add a,%1\n"
|
9951 |
|
|
+"}\n"
|
9952 |
|
|
+"\n"
|
9953 |
|
|
+"replace {\n"
|
9954 |
|
|
+" clr c\n"
|
9955 |
|
|
+" mov a,%1\n"
|
9956 |
|
|
+" addc a,%2\n"
|
9957 |
|
|
+"} by {\n"
|
9958 |
|
|
+" ; Peephole 146 changed to add without carry\n"
|
9959 |
|
|
+" mov a,%1\n"
|
9960 |
|
|
+" add a,%2\n"
|
9961 |
|
|
+"}\n"
|
9962 |
|
|
+"\n"
|
9963 |
|
|
+"replace {\n"
|
9964 |
|
|
+" orl r%1,a\n"
|
9965 |
|
|
+"} by {\n"
|
9966 |
|
|
+" ; Peephole 147 changed target address mode r%1 to ar%1\n"
|
9967 |
|
|
+" orl ar%1,a\n"
|
9968 |
|
|
+"}\n"
|
9969 |
|
|
+"\n"
|
9970 |
|
|
+"replace {\n"
|
9971 |
|
|
+" anl r%1,a\n"
|
9972 |
|
|
+"} by {\n"
|
9973 |
|
|
+" ; Peephole 148 changed target address mode r%1 to ar%1\n"
|
9974 |
|
|
+" anl ar%1,a\n"
|
9975 |
|
|
+"}\n"
|
9976 |
|
|
+"\n"
|
9977 |
|
|
+"replace {\n"
|
9978 |
|
|
+" xrl r%1,a\n"
|
9979 |
|
|
+"} by {\n"
|
9980 |
|
|
+" ; Peephole 149 changed target address mode r%1 to ar%1\n"
|
9981 |
|
|
+" xrl ar%1,a\n"
|
9982 |
|
|
+"}\n"
|
9983 |
|
|
+"\n"
|
9984 |
|
|
+"replace {\n"
|
9985 |
|
|
+" mov %1,dpl\n"
|
9986 |
|
|
+" mov dpl,%1\n"
|
9987 |
|
|
+"%9:\n"
|
9988 |
|
|
+" ret\n"
|
9989 |
|
|
+"} by {\n"
|
9990 |
|
|
+" ; Peephole 150 removed misc moves via dpl before return\n"
|
9991 |
|
|
+"%9:\n"
|
9992 |
|
|
+" ret\n"
|
9993 |
|
|
+"}\n"
|
9994 |
|
|
+"\n"
|
9995 |
|
|
+"replace {\n"
|
9996 |
|
|
+" mov %1,dpl\n"
|
9997 |
|
|
+" mov %2,dph\n"
|
9998 |
|
|
+" mov dpl,%1\n"
|
9999 |
|
|
+" mov dph,%2\n"
|
10000 |
|
|
+"%9:\n"
|
10001 |
|
|
+" ret\n"
|
10002 |
|
|
+"} by {\n"
|
10003 |
|
|
+" ; Peephole 151 removed misc moves via dph, dpl before return\n"
|
10004 |
|
|
+"%9:\n"
|
10005 |
|
|
+" ret\n"
|
10006 |
|
|
+"}\n"
|
10007 |
|
|
+"\n"
|
10008 |
|
|
+"replace {\n"
|
10009 |
|
|
+" mov %1,dpl\n"
|
10010 |
|
|
+" mov %2,dph\n"
|
10011 |
|
|
+" mov dpl,%1\n"
|
10012 |
|
|
+"%9:\n"
|
10013 |
|
|
+" ret\n"
|
10014 |
|
|
+"} by {\n"
|
10015 |
|
|
+" ; Peephole 152 removed misc moves via dph, dpl before return\n"
|
10016 |
|
|
+"%9:\n"
|
10017 |
|
|
+" ret\n"
|
10018 |
|
|
+"}\n"
|
10019 |
|
|
+"\n"
|
10020 |
|
|
+"replace {\n"
|
10021 |
|
|
+" mov %1,dpl\n"
|
10022 |
|
|
+" mov %2,dph\n"
|
10023 |
|
|
+" mov %3,b\n"
|
10024 |
|
|
+" mov dpl,%1\n"
|
10025 |
|
|
+" mov dph,%2\n"
|
10026 |
|
|
+" mov b,%3\n"
|
10027 |
|
|
+"%9:\n"
|
10028 |
|
|
+" ret\n"
|
10029 |
|
|
+"} by {\n"
|
10030 |
|
|
+" ; Peephole 153 removed misc moves via dph, dpl, b before return\n"
|
10031 |
|
|
+"%9:\n"
|
10032 |
|
|
+" ret\n"
|
10033 |
|
|
+"}\n"
|
10034 |
|
|
+"\n"
|
10035 |
|
|
+"replace {\n"
|
10036 |
|
|
+" mov %1,dpl\n"
|
10037 |
|
|
+" mov %2,dph\n"
|
10038 |
|
|
+" mov %3,b\n"
|
10039 |
|
|
+" mov dpl,%1\n"
|
10040 |
|
|
+"%9:\n"
|
10041 |
|
|
+" ret\n"
|
10042 |
|
|
+"} by {\n"
|
10043 |
|
|
+" ; Peephole 154 removed misc moves via dph, dpl, b before return\n"
|
10044 |
|
|
+"%9:\n"
|
10045 |
|
|
+" ret\n"
|
10046 |
|
|
+"}\n"
|
10047 |
|
|
+"\n"
|
10048 |
|
|
+"replace {\n"
|
10049 |
|
|
+" mov %1,dpl\n"
|
10050 |
|
|
+" mov %2,dph\n"
|
10051 |
|
|
+" mov %3,b\n"
|
10052 |
|
|
+" mov dpl,%1\n"
|
10053 |
|
|
+" mov dph,%2\n"
|
10054 |
|
|
+"%9:\n"
|
10055 |
|
|
+" ret\n"
|
10056 |
|
|
+"} by {\n"
|
10057 |
|
|
+" ; Peephole 155 removed misc moves via dph, dpl, b before return\n"
|
10058 |
|
|
+"%9:\n"
|
10059 |
|
|
+" ret\n"
|
10060 |
|
|
+"}\n"
|
10061 |
|
|
+"\n"
|
10062 |
|
|
+"replace {\n"
|
10063 |
|
|
+" mov %1,dpl\n"
|
10064 |
|
|
+" mov %2,dph\n"
|
10065 |
|
|
+" mov %3,b\n"
|
10066 |
|
|
+" mov %4,a\n"
|
10067 |
|
|
+" mov dpl,%1\n"
|
10068 |
|
|
+" mov dph,%2\n"
|
10069 |
|
|
+" mov b,%3\n"
|
10070 |
|
|
+" mov a,%4\n"
|
10071 |
|
|
+"%9:\n"
|
10072 |
|
|
+" ret\n"
|
10073 |
|
|
+"} by {\n"
|
10074 |
|
|
+" ; Peephole 156 removed misc moves via dph, dpl, b, a before return\n"
|
10075 |
|
|
+"%9:\n"
|
10076 |
|
|
+" ret\n"
|
10077 |
|
|
+"}\n"
|
10078 |
|
|
+"\n"
|
10079 |
|
|
+"replace {\n"
|
10080 |
|
|
+" mov %1,dpl\n"
|
10081 |
|
|
+" mov %2,dph\n"
|
10082 |
|
|
+" mov %3,b\n"
|
10083 |
|
|
+" mov %4,a\n"
|
10084 |
|
|
+" mov dpl,%1\n"
|
10085 |
|
|
+" mov dph,%2\n"
|
10086 |
|
|
+"%9:\n"
|
10087 |
|
|
+" ret\n"
|
10088 |
|
|
+"} by {\n"
|
10089 |
|
|
+" ; Peephole 157 removed misc moves via dph, dpl, b, a before return\n"
|
10090 |
|
|
+"%9:\n"
|
10091 |
|
|
+" ret\n"
|
10092 |
|
|
+"}\n"
|
10093 |
|
|
+"\n"
|
10094 |
|
|
+"replace {\n"
|
10095 |
|
|
+" mov %1,dpl\n"
|
10096 |
|
|
+" mov %2,dph\n"
|
10097 |
|
|
+" mov %3,b\n"
|
10098 |
|
|
+" mov %4,a\n"
|
10099 |
|
|
+" mov dpl,%1\n"
|
10100 |
|
|
+"%9:\n"
|
10101 |
|
|
+" ret } by {\n"
|
10102 |
|
|
+" ; Peephole 158 removed misc moves via dph, dpl, b, a before return\n"
|
10103 |
|
|
+"%9:\n"
|
10104 |
|
|
+" ret }\n"
|
10105 |
|
|
+"\n"
|
10106 |
|
|
+"replace {\n"
|
10107 |
|
|
+" mov %1,#%2\n"
|
10108 |
|
|
+" xrl %1,#0x80\n"
|
10109 |
|
|
+"} by {\n"
|
10110 |
|
|
+" ; Peephole 159 avoided xrl during execution\n"
|
10111 |
|
|
+" mov %1,#(%2 ^ 0x80)\n"
|
10112 |
|
|
+"}\n"
|
10113 |
|
|
+"\n"
|
10114 |
|
|
+"replace {\n"
|
10115 |
|
|
+" jnc %1\n"
|
10116 |
|
|
+" sjmp %2\n"
|
10117 |
|
|
+"%1:\n"
|
10118 |
|
|
+"} by {\n"
|
10119 |
|
|
+" ; Peephole 160 removed sjmp by inverse jump logic\n"
|
10120 |
|
|
+" jc %2\n"
|
10121 |
|
|
+"%1:}\n"
|
10122 |
|
|
+"\n"
|
10123 |
|
|
+"replace {\n"
|
10124 |
|
|
+" jc %1\n"
|
10125 |
|
|
+" sjmp %2\n"
|
10126 |
|
|
+"%1:\n"
|
10127 |
|
|
+"} by {\n"
|
10128 |
|
|
+" ; Peephole 161 removed sjmp by inverse jump logic\n"
|
10129 |
|
|
+" jnc %2\n"
|
10130 |
|
|
+"%1:}\n"
|
10131 |
|
|
+"\n"
|
10132 |
|
|
+"replace {\n"
|
10133 |
|
|
+" jnz %1\n"
|
10134 |
|
|
+" sjmp %2\n"
|
10135 |
|
|
+"%1:\n"
|
10136 |
|
|
+"} by {\n"
|
10137 |
|
|
+" ; Peephole 162 removed sjmp by inverse jump logic\n"
|
10138 |
|
|
+" jz %2\n"
|
10139 |
|
|
+"%1:}\n"
|
10140 |
|
|
+"\n"
|
10141 |
|
|
+"replace {\n"
|
10142 |
|
|
+" jz %1\n"
|
10143 |
|
|
+" sjmp %2\n"
|
10144 |
|
|
+"%1:\n"
|
10145 |
|
|
+"} by {\n"
|
10146 |
|
|
+" ; Peephole 163 removed sjmp by inverse jump logic\n"
|
10147 |
|
|
+" jnz %2\n"
|
10148 |
|
|
+"%1:}\n"
|
10149 |
|
|
+"\n"
|
10150 |
|
|
+"replace {\n"
|
10151 |
|
|
+" jnb %3,%1\n"
|
10152 |
|
|
+" sjmp %2\n"
|
10153 |
|
|
+"%1:\n"
|
10154 |
|
|
+"} by {\n"
|
10155 |
|
|
+" ; Peephole 164 removed sjmp by inverse jump logic\n"
|
10156 |
|
|
+" jb %3,%2\n"
|
10157 |
|
|
+"%1:\n"
|
10158 |
|
|
+"}\n"
|
10159 |
|
|
+"\n"
|
10160 |
|
|
+"replace {\n"
|
10161 |
|
|
+" jb %3,%1\n"
|
10162 |
|
|
+" sjmp %2\n"
|
10163 |
|
|
+"%1:\n"
|
10164 |
|
|
+"} by {\n"
|
10165 |
|
|
+" ; Peephole 165 removed sjmp by inverse jump logic\n"
|
10166 |
|
|
+" jnb %3,%2\n"
|
10167 |
|
|
+"%1:\n"
|
10168 |
|
|
+"}\n"
|
10169 |
|
|
+"\n"
|
10170 |
|
|
+"replace {\n"
|
10171 |
|
|
+" mov %1,%2\n"
|
10172 |
|
|
+" mov %3,%1\n"
|
10173 |
|
|
+" mov %2,%1\n"
|
10174 |
|
|
+"} by {\n"
|
10175 |
|
|
+" ; Peephole 166 removed redundant mov\n"
|
10176 |
|
|
+" mov %1,%2\n"
|
10177 |
|
|
+" mov %3,%1 }\n"
|
10178 |
|
|
+"\n"
|
10179 |
|
|
+"replace {\n"
|
10180 |
|
|
+" mov c,%1\n"
|
10181 |
|
|
+" cpl c\n"
|
10182 |
|
|
+" mov %1,c\n"
|
10183 |
|
|
+"} by {\n"
|
10184 |
|
|
+" ; Peephole 167 removed redundant bit moves (c not set to %1)\n"
|
10185 |
|
|
+" cpl %1 }\n"
|
10186 |
|
|
+"\n"
|
10187 |
|
|
+"replace {\n"
|
10188 |
|
|
+" jnb %1,%2\n"
|
10189 |
|
|
+" sjmp %3\n"
|
10190 |
|
|
+"%2:} by {\n"
|
10191 |
|
|
+" ; Peephole 168 jump optimization\n"
|
10192 |
|
|
+" jb %1,%3\n"
|
10193 |
|
|
+"%2:}\n"
|
10194 |
|
|
+"\n"
|
10195 |
|
|
+"replace {\n"
|
10196 |
|
|
+" jb %1,%2\n"
|
10197 |
|
|
+" sjmp %3\n"
|
10198 |
|
|
+"%2:} by {\n"
|
10199 |
|
|
+" ; Peephole 169 jump optimization\n"
|
10200 |
|
|
+" jnb %1,%3\n"
|
10201 |
|
|
+"%2:}\n"
|
10202 |
|
|
+"\n"
|
10203 |
|
|
+"replace {\n"
|
10204 |
|
|
+" clr a\n"
|
10205 |
|
|
+" cjne %1,%2,%3\n"
|
10206 |
|
|
+" cpl a\n"
|
10207 |
|
|
+"%3:\n"
|
10208 |
|
|
+" jz %4\n"
|
10209 |
|
|
+"} by {\n"
|
10210 |
|
|
+" ; Peephole 170 jump optimization\n"
|
10211 |
|
|
+" cjne %1,%2,%4\n"
|
10212 |
|
|
+"%3:}\n"
|
10213 |
|
|
+"\n"
|
10214 |
|
|
+"replace {\n"
|
10215 |
|
|
+" clr a\n"
|
10216 |
|
|
+" cjne %1,%2,%3\n"
|
10217 |
|
|
+" cjne %9,%10,%3\n"
|
10218 |
|
|
+" cpl a\n"
|
10219 |
|
|
+"%3:\n"
|
10220 |
|
|
+" jz %4\n"
|
10221 |
|
|
+"} by {\n"
|
10222 |
|
|
+" ; Peephole 171 jump optimization\n"
|
10223 |
|
|
+" cjne %1,%2,%4\n"
|
10224 |
|
|
+" cjne %9,%10,%4\n"
|
10225 |
|
|
+"%3:}\n"
|
10226 |
|
|
+"\n"
|
10227 |
|
|
+"replace {\n"
|
10228 |
|
|
+" clr a\n"
|
10229 |
|
|
+" cjne %1,%2,%3\n"
|
10230 |
|
|
+" cjne %9,%10,%3\n"
|
10231 |
|
|
+" cjne %11,%12,%3\n"
|
10232 |
|
|
+" cpl a\n"
|
10233 |
|
|
+"%3:\n"
|
10234 |
|
|
+" jz %4\n"
|
10235 |
|
|
+"} by {\n"
|
10236 |
|
|
+" ; Peephole 172 jump optimization\n"
|
10237 |
|
|
+" cjne %1,%2,%4\n"
|
10238 |
|
|
+" cjne %9,%10,%4\n"
|
10239 |
|
|
+" cjne %11,%12,%4\n"
|
10240 |
|
|
+"%3:}\n"
|
10241 |
|
|
+"\n"
|
10242 |
|
|
+"replace {\n"
|
10243 |
|
|
+" clr a\n"
|
10244 |
|
|
+" cjne %1,%2,%3\n"
|
10245 |
|
|
+" cjne %9,%10,%3\n"
|
10246 |
|
|
+" cjne %11,%12,%3\n"
|
10247 |
|
|
+" cjne %13,%14,%3\n"
|
10248 |
|
|
+" cpl a\n"
|
10249 |
|
|
+"%3:\n"
|
10250 |
|
|
+" jz %4\n"
|
10251 |
|
|
+"} by {\n"
|
10252 |
|
|
+" ; Peephole 173 jump optimization\n"
|
10253 |
|
|
+" cjne %1,%2,%4\n"
|
10254 |
|
|
+" cjne %9,%10,%4\n"
|
10255 |
|
|
+" cjne %11,%12,%4\n"
|
10256 |
|
|
+" cjne %13,%14,%4\n"
|
10257 |
|
|
+"%3:}\n"
|
10258 |
|
|
+"\n"
|
10259 |
|
|
+"replace {\n"
|
10260 |
|
|
+" mov r%1,%2\n"
|
10261 |
|
|
+" clr c\n"
|
10262 |
|
|
+" mov a,r%1\n"
|
10263 |
|
|
+" subb a,#0x01\n"
|
10264 |
|
|
+" mov %2,a\n"
|
10265 |
|
|
+"} by {\n"
|
10266 |
|
|
+" ; Peephole 174 optimized decrement (acc not set to %2, flags undefined)\n"
|
10267 |
|
|
+" mov r%1,%2\n"
|
10268 |
|
|
+" dec %2\n"
|
10269 |
|
|
+"}\n"
|
10270 |
|
|
+"\n"
|
10271 |
|
|
+"\n"
|
10272 |
|
|
+"replace {\n"
|
10273 |
|
|
+" mov r%1,%2\n"
|
10274 |
|
|
+" mov a,r%1\n"
|
10275 |
|
|
+" add a,#0x01\n"
|
10276 |
|
|
+" mov %2,a\n"
|
10277 |
|
|
+"} by {\n"
|
10278 |
|
|
+" ; Peephole 175 optimized increment (acc not set to %2, flags undefined)\n"
|
10279 |
|
|
+" mov r%1,%2\n"
|
10280 |
|
|
+" inc %2\n"
|
10281 |
|
|
+"}\n"
|
10282 |
|
|
+"\n"
|
10283 |
|
|
+"replace {\n"
|
10284 |
|
|
+" mov %1,@r%2\n"
|
10285 |
|
|
+" inc %1\n"
|
10286 |
|
|
+" mov @r%2,%1\n"
|
10287 |
|
|
+"} by {\n"
|
10288 |
|
|
+" ; Peephole 176 optimized increment, removed redundant mov\n"
|
10289 |
|
|
+" inc @r%2\n"
|
10290 |
|
|
+" mov %1,@r%2\n"
|
10291 |
|
|
+"}\n"
|
10292 |
|
|
+"\n"
|
10293 |
|
|
+"replace {\n"
|
10294 |
|
|
+" mov %1,%2\n"
|
10295 |
|
|
+" mov %2,%1\n"
|
10296 |
|
|
+"} by {\n"
|
10297 |
|
|
+" ; Peephole 177 removed redundant mov\n"
|
10298 |
|
|
+" mov %1,%2\n"
|
10299 |
|
|
+"}\n"
|
10300 |
|
|
+"\n"
|
10301 |
|
|
+"replace {\n"
|
10302 |
|
|
+" mov a,%1\n"
|
10303 |
|
|
+" mov b,a\n"
|
10304 |
|
|
+" mov a,%2\n"
|
10305 |
|
|
+"} by {\n"
|
10306 |
|
|
+" ; Peephole 178 removed redundant mov\n"
|
10307 |
|
|
+" mov b,%1\n"
|
10308 |
|
|
+" mov a,%2\n"
|
10309 |
|
|
+"}\n"
|
10310 |
|
|
+"\n"
|
10311 |
|
|
+"replace {\n"
|
10312 |
|
|
+" mov b,#0x00\n"
|
10313 |
|
|
+" mov a,#0x00\n"
|
10314 |
|
|
+"} by {\n"
|
10315 |
|
|
+" ; Peephole 179 changed mov to clr\n"
|
10316 |
|
|
+" clr a\n"
|
10317 |
|
|
+" mov b,a\n"
|
10318 |
|
|
+"}\n"
|
10319 |
|
|
+"\n"
|
10320 |
|
|
+"replace {\n"
|
10321 |
|
|
+" mov a,#0x00\n"
|
10322 |
|
|
+"} by {\n"
|
10323 |
|
|
+" ; Peephole 180 changed mov to clr\n"
|
10324 |
|
|
+" clr a\n"
|
10325 |
|
|
+"}\n"
|
10326 |
|
|
+"\n"
|
10327 |
|
|
+"replace {\n"
|
10328 |
|
|
+" mov dpl,#0x00\n"
|
10329 |
|
|
+" mov dph,#0x00\n"
|
10330 |
|
|
+" mov dpx,#0x00\n"
|
10331 |
|
|
+"} by {\n"
|
10332 |
|
|
+" ; Peephole 181a used 24 bit load of dptr\n"
|
10333 |
|
|
+" mov dptr,#0x0000\n"
|
10334 |
|
|
+"} if 24bitMode\n"
|
10335 |
|
|
+"\n"
|
10336 |
|
|
+"replace {\n"
|
10337 |
|
|
+" mov dpl,#0x00\n"
|
10338 |
|
|
+" mov dph,#0x00\n"
|
10339 |
|
|
+"} by {\n"
|
10340 |
|
|
+" ; Peephole 181 used 16 bit load of dptr\n"
|
10341 |
|
|
+" mov dptr,#0x0000\n"
|
10342 |
|
|
+"}\n"
|
10343 |
|
|
+"\n"
|
10344 |
|
|
+"replace {\n"
|
10345 |
|
|
+" mov dpl,#%1\n"
|
10346 |
|
|
+" mov dph,#(%1 >> 8)\n"
|
10347 |
|
|
+" mov dpx,#(%1 >> 16)\n"
|
10348 |
|
|
+"} by {\n"
|
10349 |
|
|
+" ; Peephole 182a used 24 bit load of dptr\n"
|
10350 |
|
|
+" mov dptr,#%1\n"
|
10351 |
|
|
+"} if 24bitMode\n"
|
10352 |
|
|
+"\n"
|
10353 |
|
|
+"replace {\n"
|
10354 |
|
|
+" mov dpl,#%1\n"
|
10355 |
|
|
+" mov dph,#%2\n"
|
10356 |
|
|
+"} by {\n"
|
10357 |
|
|
+" ; Peephole 182 used 16 bit load of dptr\n"
|
10358 |
|
|
+" mov dptr,#(((%2)<<8) + %1)\n"
|
10359 |
|
|
+"}\n"
|
10360 |
|
|
+"\n"
|
10361 |
|
|
+"replace {\n"
|
10362 |
|
|
+" anl %1,#%2\n"
|
10363 |
|
|
+" anl %1,#%3\n"
|
10364 |
|
|
+"} by {\n"
|
10365 |
|
|
+" ; Peephole 183 avoided anl during execution\n"
|
10366 |
|
|
+" anl %1,#(%2 & %3)\n"
|
10367 |
|
|
+"}\n"
|
10368 |
|
|
+"\n"
|
10369 |
|
|
+"replace {\n"
|
10370 |
|
|
+" mov %1,a\n"
|
10371 |
|
|
+" cpl a\n"
|
10372 |
|
|
+" mov %1,a\n"
|
10373 |
|
|
+"} by {\n"
|
10374 |
|
|
+" ; Peephole 184 removed redundant mov\n"
|
10375 |
|
|
+" cpl a\n"
|
10376 |
|
|
+" mov %1,a\n"
|
10377 |
|
|
+"}\n"
|
10378 |
|
|
+"\n"
|
10379 |
|
|
+"replace {\n"
|
10380 |
|
|
+" mov %1,a\n"
|
10381 |
|
|
+" inc %1\n"
|
10382 |
|
|
+"} by {\n"
|
10383 |
|
|
+" ; Peephole 185 changed order of increment (acc incremented also!)\n"
|
10384 |
|
|
+" inc a\n"
|
10385 |
|
|
+" mov %1,a\n"
|
10386 |
|
|
+"}\n"
|
10387 |
|
|
+"\n"
|
10388 |
|
|
+"replace {\n"
|
10389 |
|
|
+" add a,#%1\n"
|
10390 |
|
|
+" mov dpl,a\n"
|
10391 |
|
|
+" clr a\n"
|
10392 |
|
|
+" addc a,#(%1 >> 8)\n"
|
10393 |
|
|
+" mov dph,a\n"
|
10394 |
|
|
+" clr a\n"
|
10395 |
|
|
+" movc a,@a+dptr\n"
|
10396 |
|
|
+" mov %2,a\n"
|
10397 |
|
|
+" inc dptr\n"
|
10398 |
|
|
+" clr a\n"
|
10399 |
|
|
+" movc a,@a+dptr\n"
|
10400 |
|
|
+" mov %3,a\n"
|
10401 |
|
|
+" inc dptr\n"
|
10402 |
|
|
+" clr a\n"
|
10403 |
|
|
+" movc a,@a+dptr\n"
|
10404 |
|
|
+" mov %4,a\n"
|
10405 |
|
|
+" inc dptr\n"
|
10406 |
|
|
+" clr a \n"
|
10407 |
|
|
+"} by {\n"
|
10408 |
|
|
+" ; Peephole 186.a optimized movc sequence\n"
|
10409 |
|
|
+" mov dptr,#%1\n"
|
10410 |
|
|
+" mov b,acc\n"
|
10411 |
|
|
+" movc a,@a+dptr\n"
|
10412 |
|
|
+" mov %2,a\n"
|
10413 |
|
|
+" mov acc,b\n"
|
10414 |
|
|
+" inc dptr \n"
|
10415 |
|
|
+" movc a,@a+dptr\n"
|
10416 |
|
|
+" mov %3,a\n"
|
10417 |
|
|
+" mov acc,b\n"
|
10418 |
|
|
+" inc dptr\n"
|
10419 |
|
|
+" mov %4,a\n"
|
10420 |
|
|
+" mov acc,b\n"
|
10421 |
|
|
+" inc dptr\n"
|
10422 |
|
|
+"}\n"
|
10423 |
|
|
+"\n"
|
10424 |
|
|
+"replace {\n"
|
10425 |
|
|
+" add a,#%1\n"
|
10426 |
|
|
+" mov dpl,a\n"
|
10427 |
|
|
+" clr a\n"
|
10428 |
|
|
+" addc a,#(%1 >> 8)\n"
|
10429 |
|
|
+" mov dph,a\n"
|
10430 |
|
|
+" clr a\n"
|
10431 |
|
|
+" movc a,@a+dptr\n"
|
10432 |
|
|
+" mov %2,a\n"
|
10433 |
|
|
+" inc dptr\n"
|
10434 |
|
|
+" clr a\n"
|
10435 |
|
|
+" movc a,@a+dptr\n"
|
10436 |
|
|
+" mov %3,a\n"
|
10437 |
|
|
+" inc dptr\n"
|
10438 |
|
|
+" clr a\n"
|
10439 |
|
|
+"} by {\n"
|
10440 |
|
|
+" ; Peephole 186.b optimized movc sequence\n"
|
10441 |
|
|
+" mov dptr,#%1\n"
|
10442 |
|
|
+" mov b,acc\n"
|
10443 |
|
|
+" movc a,@a+dptr\n"
|
10444 |
|
|
+" mov %2,a\n"
|
10445 |
|
|
+" mov acc,b\n"
|
10446 |
|
|
+" inc dptr \n"
|
10447 |
|
|
+" movc a,@a+dptr\n"
|
10448 |
|
|
+" mov %3,a\n"
|
10449 |
|
|
+" mov acc,b\n"
|
10450 |
|
|
+" inc dptr \n"
|
10451 |
|
|
+"}\n"
|
10452 |
|
|
+"\n"
|
10453 |
|
|
+"replace {\n"
|
10454 |
|
|
+" add a,#%1\n"
|
10455 |
|
|
+" mov dpl,a\n"
|
10456 |
|
|
+" clr a\n"
|
10457 |
|
|
+" addc a,#(%1 >> 8)\n"
|
10458 |
|
|
+" mov dph,a\n"
|
10459 |
|
|
+" clr a\n"
|
10460 |
|
|
+" movc a,@a+dptr\n"
|
10461 |
|
|
+" mov %2,a\n"
|
10462 |
|
|
+" inc dptr\n"
|
10463 |
|
|
+" clr a\n"
|
10464 |
|
|
+"} by {\n"
|
10465 |
|
|
+" ; Peephole 186.c optimized movc sequence\n"
|
10466 |
|
|
+" mov dptr,#%1\n"
|
10467 |
|
|
+" mov b,acc\n"
|
10468 |
|
|
+" movc a,@a+dptr\n"
|
10469 |
|
|
+" mov %2,a\n"
|
10470 |
|
|
+" mov acc,b\n"
|
10471 |
|
|
+" inc dptr\n"
|
10472 |
|
|
+"}\n"
|
10473 |
|
|
+"\n"
|
10474 |
|
|
+"replace {\n"
|
10475 |
|
|
+" add a,#%1\n"
|
10476 |
|
|
+" mov dpl,a\n"
|
10477 |
|
|
+" clr a\n"
|
10478 |
|
|
+" addc a,#(%1 >> 8)\n"
|
10479 |
|
|
+" mov dph,a\n"
|
10480 |
|
|
+" clr a\n"
|
10481 |
|
|
+" movc a,@a+dptr\n"
|
10482 |
|
|
+"} by {\n"
|
10483 |
|
|
+" ; Peephole 186 optimized movc sequence\n"
|
10484 |
|
|
+" mov dptr,#%1\n"
|
10485 |
|
|
+" movc a,@a+dptr\n"
|
10486 |
|
|
+"}\n"
|
10487 |
|
|
+"\n"
|
10488 |
|
|
+"replace {\n"
|
10489 |
|
|
+" mov r%1,%2\n"
|
10490 |
|
|
+" anl ar%1,#%3\n"
|
10491 |
|
|
+" mov a,r%1\n"
|
10492 |
|
|
+"} by {\n"
|
10493 |
|
|
+" ; Peephole 187 used a instead of ar%1 for anl\n"
|
10494 |
|
|
+" mov a,%2\n"
|
10495 |
|
|
+" anl a,#%3\n"
|
10496 |
|
|
+" mov r%1,a\n"
|
10497 |
|
|
+"}\n"
|
10498 |
|
|
+"\n"
|
10499 |
|
|
+"replace {\n"
|
10500 |
|
|
+" mov %1,a\n"
|
10501 |
|
|
+" mov dptr,%2\n"
|
10502 |
|
|
+" movc a,@a+dptr\n"
|
10503 |
|
|
+" mov %1,a\n"
|
10504 |
|
|
+"} by {\n"
|
10505 |
|
|
+" ; Peephole 188 removed redundant mov\n"
|
10506 |
|
|
+" mov dptr,%2\n"
|
10507 |
|
|
+" movc a,@a+dptr\n"
|
10508 |
|
|
+" mov %1,a\n"
|
10509 |
|
|
+"}\n"
|
10510 |
|
|
+"\n"
|
10511 |
|
|
+"replace {\n"
|
10512 |
|
|
+" anl a,#0x0f\n"
|
10513 |
|
|
+" mov %1,a\n"
|
10514 |
|
|
+" mov a,#0x0f\n"
|
10515 |
|
|
+" anl a,%1\n"
|
10516 |
|
|
+"} by {\n"
|
10517 |
|
|
+" ; Peephole 189 removed redundant mov and anl\n"
|
10518 |
|
|
+" anl a,#0x0f\n"
|
10519 |
|
|
+" mov %1,a\n"
|
10520 |
|
|
+"}\n"
|
10521 |
|
|
+"\n"
|
10522 |
|
|
+"replace {\n"
|
10523 |
|
|
+" mov a,%1\n"
|
10524 |
|
|
+" lcall __gptrput\n"
|
10525 |
|
|
+" mov a,%1\n"
|
10526 |
|
|
+"} by {\n"
|
10527 |
|
|
+" ; Peephole 190 removed redundant mov\n"
|
10528 |
|
|
+" mov a,%1\n"
|
10529 |
|
|
+" lcall __gptrput\n"
|
10530 |
|
|
+"}\n"
|
10531 |
|
|
+"\n"
|
10532 |
|
|
+"replace {\n"
|
10533 |
|
|
+" mov %1,a\n"
|
10534 |
|
|
+" mov dpl,%2\n"
|
10535 |
|
|
+" mov dph,%3\n"
|
10536 |
|
|
+" mov b,%4\n"
|
10537 |
|
|
+" mov a,%1\n"
|
10538 |
|
|
+"} by {\n"
|
10539 |
|
|
+" ; Peephole 191 removed redundant mov\n"
|
10540 |
|
|
+" mov %1,a\n"
|
10541 |
|
|
+" mov dpl,%2\n"
|
10542 |
|
|
+" mov dph,%3\n"
|
10543 |
|
|
+" mov b,%4\n"
|
10544 |
|
|
+"}\n"
|
10545 |
|
|
+"\n"
|
10546 |
|
|
+"replace {\n"
|
10547 |
|
|
+" mov r%1,a\n"
|
10548 |
|
|
+" mov @r%2,ar%1\n"
|
10549 |
|
|
+"} by {\n"
|
10550 |
|
|
+" ; Peephole 192 used a instead of ar%1 as source\n"
|
10551 |
|
|
+" mov r%1,a\n"
|
10552 |
|
|
+" mov @r%2,a\n"
|
10553 |
|
|
+"}\n"
|
10554 |
|
|
+"\n"
|
10555 |
|
|
+"replace {\n"
|
10556 |
|
|
+" jnz %3\n"
|
10557 |
|
|
+" mov a,%4\n"
|
10558 |
|
|
+" jnz %3\n"
|
10559 |
|
|
+" mov a,%9\n"
|
10560 |
|
|
+" jnz %3\n"
|
10561 |
|
|
+" mov a,%12\n"
|
10562 |
|
|
+" cjne %13,%14,%3\n"
|
10563 |
|
|
+" sjmp %7\n"
|
10564 |
|
|
+"%3:\n"
|
10565 |
|
|
+" sjmp %8\n"
|
10566 |
|
|
+"} by {\n"
|
10567 |
|
|
+" ; Peephole 193.a optimized misc jump sequence\n"
|
10568 |
|
|
+" jnz %8\n"
|
10569 |
|
|
+" mov a,%4\n"
|
10570 |
|
|
+" jnz %8\n"
|
10571 |
|
|
+" mov a,%9\n"
|
10572 |
|
|
+" jnz %8\n"
|
10573 |
|
|
+" mov a,%12\n"
|
10574 |
|
|
+" cjne %13,%14,%8\n"
|
10575 |
|
|
+" sjmp %7\n"
|
10576 |
|
|
+"%3:\n"
|
10577 |
|
|
+"}\n"
|
10578 |
|
|
+"\n"
|
10579 |
|
|
+"replace {\n"
|
10580 |
|
|
+" cjne %1,%2,%3\n"
|
10581 |
|
|
+" mov a,%4\n"
|
10582 |
|
|
+" cjne %5,%6,%3\n"
|
10583 |
|
|
+" mov a,%9\n"
|
10584 |
|
|
+" cjne %10,%11,%3\n"
|
10585 |
|
|
+" mov a,%12\n"
|
10586 |
|
|
+" cjne %13,%14,%3\n"
|
10587 |
|
|
+" sjmp %7\n"
|
10588 |
|
|
+"%3:\n"
|
10589 |
|
|
+" sjmp %8\n"
|
10590 |
|
|
+"} by {\n"
|
10591 |
|
|
+" ; Peephole 193 optimized misc jump sequence\n"
|
10592 |
|
|
+" cjne %1,%2,%8\n"
|
10593 |
|
|
+" mov a,%4\n"
|
10594 |
|
|
+" cjne %5,%6,%8\n"
|
10595 |
|
|
+" mov a,%9\n"
|
10596 |
|
|
+" cjne %10,%11,%8\n"
|
10597 |
|
|
+" mov a,%12\n"
|
10598 |
|
|
+" cjne %13,%14,%8\n"
|
10599 |
|
|
+" sjmp %7\n"
|
10600 |
|
|
+"%3:\n"
|
10601 |
|
|
+"}\n"
|
10602 |
|
|
+"\n"
|
10603 |
|
|
+"replace {\n"
|
10604 |
|
|
+" cjne %1,%2,%3\n"
|
10605 |
|
|
+" cjne %5,%6,%3\n"
|
10606 |
|
|
+" cjne %10,%11,%3\n"
|
10607 |
|
|
+" cjne %13,%14,%3\n"
|
10608 |
|
|
+" sjmp %7\n"
|
10609 |
|
|
+"%3:\n"
|
10610 |
|
|
+" sjmp %8\n"
|
10611 |
|
|
+"} by {\n"
|
10612 |
|
|
+" ; Peephole 194 optimized misc jump sequence\n"
|
10613 |
|
|
+" cjne %1,%2,%8\n"
|
10614 |
|
|
+" cjne %5,%6,%8\n"
|
10615 |
|
|
+" cjne %10,%11,%8\n"
|
10616 |
|
|
+" cjne %13,%14,%8\n"
|
10617 |
|
|
+" sjmp %7\n"
|
10618 |
|
|
+"%3:\n"
|
10619 |
|
|
+"}\n"
|
10620 |
|
|
+"\n"
|
10621 |
|
|
+"replace {\n"
|
10622 |
|
|
+" jnz %3\n"
|
10623 |
|
|
+" mov a,%4\n"
|
10624 |
|
|
+" jnz %3\n"
|
10625 |
|
|
+" mov a,%9\n"
|
10626 |
|
|
+" cjne %10,%11,%3\n"
|
10627 |
|
|
+" sjmp %7\n"
|
10628 |
|
|
+"%3:\n"
|
10629 |
|
|
+" sjmp %8\n"
|
10630 |
|
|
+"} by {\n"
|
10631 |
|
|
+" ; Peephole 195.a optimized misc jump sequence\n"
|
10632 |
|
|
+" jnz %8\n"
|
10633 |
|
|
+" mov a,%4\n"
|
10634 |
|
|
+" jnz %8\n"
|
10635 |
|
|
+" mov a,%9\n"
|
10636 |
|
|
+" cjne %10,%11,%8\n"
|
10637 |
|
|
+" sjmp %7\n"
|
10638 |
|
|
+"%3:\n"
|
10639 |
|
|
+"}\n"
|
10640 |
|
|
+"\n"
|
10641 |
|
|
+"replace {\n"
|
10642 |
|
|
+" cjne %1,%2,%3\n"
|
10643 |
|
|
+" mov a,%4\n"
|
10644 |
|
|
+" cjne %5,%6,%3\n"
|
10645 |
|
|
+" mov a,%9\n"
|
10646 |
|
|
+" cjne %10,%11,%3\n"
|
10647 |
|
|
+" sjmp %7\n"
|
10648 |
|
|
+"%3:\n"
|
10649 |
|
|
+" sjmp %8\n"
|
10650 |
|
|
+"} by {\n"
|
10651 |
|
|
+" ; Peephole 195 optimized misc jump sequence\n"
|
10652 |
|
|
+" cjne %1,%2,%8\n"
|
10653 |
|
|
+" mov a,%4\n"
|
10654 |
|
|
+" cjne %5,%6,%8\n"
|
10655 |
|
|
+" mov a,%9\n"
|
10656 |
|
|
+" cjne %10,%11,%8\n"
|
10657 |
|
|
+" sjmp %7\n"
|
10658 |
|
|
+"%3:\n"
|
10659 |
|
|
+"}\n"
|
10660 |
|
|
+"\n"
|
10661 |
|
|
+"replace {\n"
|
10662 |
|
|
+" cjne %1,%2,%3\n"
|
10663 |
|
|
+" cjne %5,%6,%3\n"
|
10664 |
|
|
+" cjne %10,%11,%3\n"
|
10665 |
|
|
+" sjmp %7\n"
|
10666 |
|
|
+"%3:\n"
|
10667 |
|
|
+" sjmp %8\n"
|
10668 |
|
|
+"} by {\n"
|
10669 |
|
|
+" ; Peephole 196 optimized misc jump sequence\n"
|
10670 |
|
|
+" cjne %1,%2,%8\n"
|
10671 |
|
|
+" cjne %5,%6,%8\n"
|
10672 |
|
|
+" cjne %10,%11,%8\n"
|
10673 |
|
|
+" sjmp %7\n"
|
10674 |
|
|
+"%3:\n"
|
10675 |
|
|
+"}\n"
|
10676 |
|
|
+"\n"
|
10677 |
|
|
+"replace {\n"
|
10678 |
|
|
+" jnz %3\n"
|
10679 |
|
|
+" mov a,%4\n"
|
10680 |
|
|
+" cjne %5,%6,%3\n"
|
10681 |
|
|
+" sjmp %7\n"
|
10682 |
|
|
+"%3:\n"
|
10683 |
|
|
+" sjmp %8 \n"
|
10684 |
|
|
+"} by {\n"
|
10685 |
|
|
+" ; Peephole 197.a optimized misc jump sequence\n"
|
10686 |
|
|
+" jnz %8\n"
|
10687 |
|
|
+" mov a,%4\n"
|
10688 |
|
|
+" cjne %5,%6,%8\n"
|
10689 |
|
|
+" sjmp %7\n"
|
10690 |
|
|
+"%3: \n"
|
10691 |
|
|
+"}\n"
|
10692 |
|
|
+"\n"
|
10693 |
|
|
+"replace {\n"
|
10694 |
|
|
+" cjne %1,%2,%3\n"
|
10695 |
|
|
+" mov a,%4\n"
|
10696 |
|
|
+" cjne %5,%6,%3\n"
|
10697 |
|
|
+" sjmp %7\n"
|
10698 |
|
|
+"%3:\n"
|
10699 |
|
|
+" sjmp %8\n"
|
10700 |
|
|
+"} by {\n"
|
10701 |
|
|
+" ; Peephole 197 optimized misc jump sequence\n"
|
10702 |
|
|
+" cjne %1,%2,%8\n"
|
10703 |
|
|
+" mov a,%4\n"
|
10704 |
|
|
+" cjne %5,%6,%8\n"
|
10705 |
|
|
+" sjmp %7\n"
|
10706 |
|
|
+"%3:\n"
|
10707 |
|
|
+"}\n"
|
10708 |
|
|
+"\n"
|
10709 |
|
|
+"replace {\n"
|
10710 |
|
|
+" cjne %1,%2,%3\n"
|
10711 |
|
|
+" cjne %5,%6,%3\n"
|
10712 |
|
|
+" sjmp %7\n"
|
10713 |
|
|
+"%3:\n"
|
10714 |
|
|
+" sjmp %8\n"
|
10715 |
|
|
+"} by {\n"
|
10716 |
|
|
+" ; Peephole 198 optimized misc jump sequence\n"
|
10717 |
|
|
+" cjne %1,%2,%8\n"
|
10718 |
|
|
+" cjne %5,%6,%8\n"
|
10719 |
|
|
+" sjmp %7\n"
|
10720 |
|
|
+"%3:\n"
|
10721 |
|
|
+"}\n"
|
10722 |
|
|
+"\n"
|
10723 |
|
|
+"replace {\n"
|
10724 |
|
|
+" cjne %1,%2,%3\n"
|
10725 |
|
|
+" sjmp %4\n"
|
10726 |
|
|
+"%3:\n"
|
10727 |
|
|
+" sjmp %5\n"
|
10728 |
|
|
+"} by {\n"
|
10729 |
|
|
+" ; Peephole 199 optimized misc jump sequence\n"
|
10730 |
|
|
+" cjne %1,%2,%5\n"
|
10731 |
|
|
+" sjmp %4\n"
|
10732 |
|
|
+"%3:\n"
|
10733 |
|
|
+"}\n"
|
10734 |
|
|
+"\n"
|
10735 |
|
|
+"replace {\n"
|
10736 |
|
|
+" sjmp %1\n"
|
10737 |
|
|
+"%1:\n"
|
10738 |
|
|
+"} by {\n"
|
10739 |
|
|
+" ; Peephole 200 removed redundant sjmp\n"
|
10740 |
|
|
+"%1:\n"
|
10741 |
|
|
+"}\n"
|
10742 |
|
|
+"\n"
|
10743 |
|
|
+"replace {\n"
|
10744 |
|
|
+" sjmp %1\n"
|
10745 |
|
|
+"%2:\n"
|
10746 |
|
|
+"%1:\n"
|
10747 |
|
|
+"} by {\n"
|
10748 |
|
|
+" ; Peephole 201 removed redundant sjmp\n"
|
10749 |
|
|
+"%2:\n"
|
10750 |
|
|
+"%1:\n"
|
10751 |
|
|
+"}\n"
|
10752 |
|
|
+"\n"
|
10753 |
|
|
+"replace {\n"
|
10754 |
|
|
+" push acc\n"
|
10755 |
|
|
+" mov dptr,%1\n"
|
10756 |
|
|
+" pop acc\n"
|
10757 |
|
|
+"} by {\n"
|
10758 |
|
|
+" ; Peephole 202 removed redundant push pop\n"
|
10759 |
|
|
+" mov dptr,%1\n"
|
10760 |
|
|
+"}\n"
|
10761 |
|
|
+"\n"
|
10762 |
|
|
+"replace {\n"
|
10763 |
|
|
+" mov r%1,_spx\n"
|
10764 |
|
|
+" lcall %2\n"
|
10765 |
|
|
+" mov r%1,_spx\n"
|
10766 |
|
|
+"} by {\n"
|
10767 |
|
|
+" ; Peephole 203 removed mov r%1,_spx\n"
|
10768 |
|
|
+" lcall %2\n"
|
10769 |
|
|
+"}\n"
|
10770 |
|
|
+"\n"
|
10771 |
|
|
+"replace {\n"
|
10772 |
|
|
+" mov %1,a\n"
|
10773 |
|
|
+" add a,acc\n"
|
10774 |
|
|
+" mov %1,a\n"
|
10775 |
|
|
+"} by {\n"
|
10776 |
|
|
+" ; Peephole 204 removed redundant mov\n"
|
10777 |
|
|
+" add a,acc\n"
|
10778 |
|
|
+" mov %1,a\n"
|
10779 |
|
|
+"}\n"
|
10780 |
|
|
+"\n"
|
10781 |
|
|
+"replace {\n"
|
10782 |
|
|
+" djnz %1,%2\n"
|
10783 |
|
|
+" sjmp %3\n"
|
10784 |
|
|
+"%2:\n"
|
10785 |
|
|
+" sjmp %4\n"
|
10786 |
|
|
+"%3:\n"
|
10787 |
|
|
+"} by {\n"
|
10788 |
|
|
+" ; Peephole 205 optimized misc jump sequence\n"
|
10789 |
|
|
+" djnz %1,%4\n"
|
10790 |
|
|
+"%2:\n"
|
10791 |
|
|
+"%3:\n"
|
10792 |
|
|
+"}\n"
|
10793 |
|
|
+"\n"
|
10794 |
|
|
+"replace {\n"
|
10795 |
|
|
+" mov %1,%1\n"
|
10796 |
|
|
+"} by {\n"
|
10797 |
|
|
+" ; Peephole 206 removed redundant mov %1,%1\n"
|
10798 |
|
|
+"}\n"
|
10799 |
|
|
+"\n"
|
10800 |
|
|
+"replace {\n"
|
10801 |
|
|
+" mov a,_bp\n"
|
10802 |
|
|
+" add a,#0x00\n"
|
10803 |
|
|
+" mov %1,a\n"
|
10804 |
|
|
+"} by {\n"
|
10805 |
|
|
+" ; Peephole 207 removed zero add (acc not set to %1, flags undefined)\n"
|
10806 |
|
|
+" mov %1,_bp\n"
|
10807 |
|
|
+"}\n"
|
10808 |
|
|
+"\n"
|
10809 |
|
|
+"replace {\n"
|
10810 |
|
|
+" push acc\n"
|
10811 |
|
|
+" mov r%1,_bp\n"
|
10812 |
|
|
+" pop acc\n"
|
10813 |
|
|
+"} by {\n"
|
10814 |
|
|
+" ; Peephole 208 removed redundant push pop\n"
|
10815 |
|
|
+" mov r%1,_bp\n"
|
10816 |
|
|
+"}\n"
|
10817 |
|
|
+"\n"
|
10818 |
|
|
+"replace {\n"
|
10819 |
|
|
+" mov a,_bp\n"
|
10820 |
|
|
+" add a,#0x00\n"
|
10821 |
|
|
+" inc a\n"
|
10822 |
|
|
+" mov %1,a\n"
|
10823 |
|
|
+"} by {\n"
|
10824 |
|
|
+" ; Peephole 209 optimized increment (acc not set to %1, flags undefined)\n"
|
10825 |
|
|
+" mov %1,_bp\n"
|
10826 |
|
|
+" inc %1\n"
|
10827 |
|
|
+"}\n"
|
10828 |
|
|
+"\n"
|
10829 |
|
|
+"replace {\n"
|
10830 |
|
|
+" mov dptr,#((((%1 >> 16)) <<16) + (((%1 >> 8)) <<8) + %1)\n"
|
10831 |
|
|
+"} by {\n"
|
10832 |
|
|
+" ; Peephole 210a simplified expression\n"
|
10833 |
|
|
+" mov dptr,#%1\n"
|
10834 |
|
|
+"} if 24bitMode\n"
|
10835 |
|
|
+"\n"
|
10836 |
|
|
+"replace {\n"
|
10837 |
|
|
+" mov dptr,#((((%1 >> 8)) <<8) + %1)\n"
|
10838 |
|
|
+"} by {\n"
|
10839 |
|
|
+" ; Peephole 210 simplified expression\n"
|
10840 |
|
|
+" mov dptr,#%1\n"
|
10841 |
|
|
+"}\n"
|
10842 |
|
|
+"\n"
|
10843 |
|
|
+"replace {\n"
|
10844 |
|
|
+" push %1\n"
|
10845 |
|
|
+" pop %1\n"
|
10846 |
|
|
+"} by {\n"
|
10847 |
|
|
+" ; Peephole 211 removed redundant push %1 pop %1 \n"
|
10848 |
|
|
+"} \n"
|
10849 |
|
|
+"\n"
|
10850 |
|
|
+"replace {\n"
|
10851 |
|
|
+" mov a,_bp\n"
|
10852 |
|
|
+" add a,#0x01\n"
|
10853 |
|
|
+" mov r%1,a\n"
|
10854 |
|
|
+"} by {\n"
|
10855 |
|
|
+" ; Peephole 212 reduced add sequence to inc\n"
|
10856 |
|
|
+" mov r%1,_bp\n"
|
10857 |
|
|
+" inc r%1\n"
|
10858 |
|
|
+"}\n"
|
10859 |
|
|
+"\n"
|
10860 |
|
|
+"replace {\n"
|
10861 |
|
|
+" mov %1,#(( %2 >> 8 ) ^ 0x80)\n"
|
10862 |
|
|
+"} by { \n"
|
10863 |
|
|
+" mov %1,#(%2 >> 8)\n"
|
10864 |
|
|
+" xrl %1,#0x80\n"
|
10865 |
|
|
+"}\n"
|
10866 |
|
|
+"\n"
|
10867 |
|
|
+"replace {\n"
|
10868 |
|
|
+" mov %1,#(( %2 + %3 >> 8 ) ^ 0x80)\n"
|
10869 |
|
|
+"} by { \n"
|
10870 |
|
|
+" mov %1,#((%2 + %3) >> 8)\n"
|
10871 |
|
|
+" xrl %1,#0x80\n"
|
10872 |
|
|
+"}\n"
|
10873 |
|
|
+"\n"
|
10874 |
|
|
+"replace {\n"
|
10875 |
|
|
+" mov %1,a\n"
|
10876 |
|
|
+" mov a,%2\n"
|
10877 |
|
|
+" add a,%1\n"
|
10878 |
|
|
+"} by {\n"
|
10879 |
|
|
+" ; Peephole 214 reduced some extra movs\n"
|
10880 |
|
|
+" mov %1,a\n"
|
10881 |
|
|
+" add a,%2 \n"
|
10882 |
|
|
+"} if notSame(%1 %2)\n"
|
10883 |
|
|
+"\n"
|
10884 |
|
|
+"replace {\n"
|
10885 |
|
|
+" mov %1,a\n"
|
10886 |
|
|
+" add a,%2\n"
|
10887 |
|
|
+" mov %1,a\n"
|
10888 |
|
|
+"} by {\n"
|
10889 |
|
|
+" ; Peephole 215 removed some movs\n"
|
10890 |
|
|
+" add a,%2\n"
|
10891 |
|
|
+" mov %1,a\n"
|
10892 |
|
|
+"} if notSame(%1 %2)\n"
|
10893 |
|
|
+"\n"
|
10894 |
|
|
+"replace {\n"
|
10895 |
|
|
+" mov r%1,%2\n"
|
10896 |
|
|
+" clr a\n"
|
10897 |
|
|
+" inc r%1\n"
|
10898 |
|
|
+" mov @r%1,a\n"
|
10899 |
|
|
+" dec r%1\n"
|
10900 |
|
|
+" mov @r%1,a\n"
|
10901 |
|
|
+"} by {\n"
|
10902 |
|
|
+" ; Peephole 216 simplified clear (2bytes)\n"
|
10903 |
|
|
+" mov r%1,%2\n"
|
10904 |
|
|
+" clr a\n"
|
10905 |
|
|
+" mov @r%1,a\n"
|
10906 |
|
|
+" inc r%1\n"
|
10907 |
|
|
+" mov @r%1,a\n"
|
10908 |
|
|
+"}\n"
|
10909 |
|
|
+"\n"
|
10910 |
|
|
+"replace {\n"
|
10911 |
|
|
+" mov r%1,%2\n"
|
10912 |
|
|
+" clr a\n"
|
10913 |
|
|
+" inc r%1\n"
|
10914 |
|
|
+" inc r%1\n"
|
10915 |
|
|
+" mov @r%1,a\n"
|
10916 |
|
|
+" dec r%1\n"
|
10917 |
|
|
+" mov @r%1,a\n"
|
10918 |
|
|
+" dec r%1\n"
|
10919 |
|
|
+" mov @r%1,a\n"
|
10920 |
|
|
+"} by {\n"
|
10921 |
|
|
+" ; Peephole 217 simplified clear (3bytes)\n"
|
10922 |
|
|
+" mov r%1,%2\n"
|
10923 |
|
|
+" clr a\n"
|
10924 |
|
|
+" mov @r%1,a\n"
|
10925 |
|
|
+" inc r%1\n"
|
10926 |
|
|
+" mov @r%1,a\n"
|
10927 |
|
|
+" inc r%1\n"
|
10928 |
|
|
+" mov @r%1,a\n"
|
10929 |
|
|
+"}\n"
|
10930 |
|
|
+"\n"
|
10931 |
|
|
+"replace {\n"
|
10932 |
|
|
+" mov r%1,%2\n"
|
10933 |
|
|
+" clr a\n"
|
10934 |
|
|
+" inc r%1\n"
|
10935 |
|
|
+" inc r%1\n"
|
10936 |
|
|
+" inc r%1\n"
|
10937 |
|
|
+" mov @r%1,a\n"
|
10938 |
|
|
+" dec r%1\n"
|
10939 |
|
|
+" mov @r%1,a\n"
|
10940 |
|
|
+" dec r%1\n"
|
10941 |
|
|
+" mov @r%1,a\n"
|
10942 |
|
|
+" dec r%1\n"
|
10943 |
|
|
+" mov @r%1,a\n"
|
10944 |
|
|
+"} by {\n"
|
10945 |
|
|
+" ; Peephole 218 simplified clear (4bytes)\n"
|
10946 |
|
|
+" mov r%1,%2\n"
|
10947 |
|
|
+" clr a\n"
|
10948 |
|
|
+" mov @r%1,a\n"
|
10949 |
|
|
+" inc r%1\n"
|
10950 |
|
|
+" mov @r%1,a\n"
|
10951 |
|
|
+" inc r%1\n"
|
10952 |
|
|
+" mov @r%1,a\n"
|
10953 |
|
|
+" inc r%1\n"
|
10954 |
|
|
+" mov @r%1,a\n"
|
10955 |
|
|
+"}\n"
|
10956 |
|
|
+"\n"
|
10957 |
|
|
+"replace {\n"
|
10958 |
|
|
+" clr a\n"
|
10959 |
|
|
+" movx @dptr,a\n"
|
10960 |
|
|
+" mov dptr,%1\n"
|
10961 |
|
|
+" clr a\n"
|
10962 |
|
|
+" movx @dptr,a\n"
|
10963 |
|
|
+"} by {\n"
|
10964 |
|
|
+" ; Peephole 219 removed redundant clear\n"
|
10965 |
|
|
+" clr a\n"
|
10966 |
|
|
+" movx @dptr,a\n"
|
10967 |
|
|
+" mov dptr,%1\n"
|
10968 |
|
|
+" movx @dptr,a\n"
|
10969 |
|
|
+"}\n"
|
10970 |
|
|
+"\n"
|
10971 |
|
|
+"replace {\n"
|
10972 |
|
|
+" clr a\n"
|
10973 |
|
|
+" movx @dptr,a\n"
|
10974 |
|
|
+" mov dptr,%1\n"
|
10975 |
|
|
+" movx @dptr,a\n"
|
10976 |
|
|
+" mov dptr,%2\n"
|
10977 |
|
|
+" clr a\n"
|
10978 |
|
|
+" movx @dptr,a\n"
|
10979 |
|
|
+"} by {\n"
|
10980 |
|
|
+" ; Peephole 219a removed redundant clear\n"
|
10981 |
|
|
+" clr a\n"
|
10982 |
|
|
+" movx @dptr,a\n"
|
10983 |
|
|
+" mov dptr,%1\n"
|
10984 |
|
|
+" movx @dptr,a\n"
|
10985 |
|
|
+" mov dptr,%2\n"
|
10986 |
|
|
+" movx @dptr,a\n"
|
10987 |
|
|
+"}\n"
|
10988 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/ralloc.c sdcc-src-3.1.0-pblaze/src/json/ralloc.c
|
10989 |
|
|
--- sdcc-src-3.1.0/src/json/ralloc.c 1970-01-01 01:00:00.000000000 +0100
|
10990 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/ralloc.c 2011-02-07 20:04:48.000000000 +0100
|
10991 |
|
|
@@ -0,0 +1,259 @@
|
10992 |
|
|
+/*------------------------------------------------------------------------
|
10993 |
|
|
+
|
10994 |
|
|
+ SDCCralloc.c - source file for register allocation. (XILINX PICOBLAZE) specific
|
10995 |
|
|
+
|
10996 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
10997 |
|
|
+ under the terms of the GNU General Public License as published by the
|
10998 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
10999 |
|
|
+ later version.
|
11000 |
|
|
+
|
11001 |
|
|
+ This program is distributed in the hope that it will be useful,
|
11002 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11003 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11004 |
|
|
+ GNU General Public License for more details.
|
11005 |
|
|
+
|
11006 |
|
|
+ You should have received a copy of the GNU General Public License
|
11007 |
|
|
+ along with this program; if not, write to the Free Software
|
11008 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
11009 |
|
|
+
|
11010 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
11011 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
11012 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
11013 |
|
|
+-------------------------------------------------------------------------*/
|
11014 |
|
|
+
|
11015 |
|
|
+#include "common.h"
|
11016 |
|
|
+#include "ralloc.h"
|
11017 |
|
|
+#include "gen.h"
|
11018 |
|
|
+
|
11019 |
|
|
+
|
11020 |
|
|
+extern void genJSONCode (iCode *);
|
11021 |
|
|
+
|
11022 |
|
|
+/* Global data */
|
11023 |
|
|
+static struct {
|
11024 |
|
|
+ bitVect *spiltSet;
|
11025 |
|
|
+ set *stackSpil;
|
11026 |
|
|
+ bitVect *regAssigned;
|
11027 |
|
|
+ short blockSpil;
|
11028 |
|
|
+ int slocNum;
|
11029 |
|
|
+ bitVect *funcrUsed; /* registers used in a function */
|
11030 |
|
|
+ int stackExtend;
|
11031 |
|
|
+ int dataExtend;
|
11032 |
|
|
+} _G;
|
11033 |
|
|
+
|
11034 |
|
|
+/* Shared with gen.c */
|
11035 |
|
|
+int json_ptrRegReq; /* pointer register required */
|
11036 |
|
|
+
|
11037 |
|
|
+/* JSON registers */
|
11038 |
|
|
+regs regsJSON[] = {
|
11039 |
|
|
+ {REG_GPR, S0_IDX, "s0", NULL, 0, 1},
|
11040 |
|
|
+ {REG_GPR, S1_IDX, "s1", NULL, 0, 1},
|
11041 |
|
|
+ {REG_GPR, S2_IDX, "s2", NULL, 0, 1},
|
11042 |
|
|
+ {REG_GPR, S3_IDX, "s3", NULL, 0, 1},
|
11043 |
|
|
+ {REG_GPR, S4_IDX, "s4", NULL, 0, 1},
|
11044 |
|
|
+ {REG_GPR, S5_IDX, "s5", NULL, 0, 1},
|
11045 |
|
|
+ {REG_GPR, S6_IDX, "s6", NULL, 0, 1},
|
11046 |
|
|
+ {REG_GPR, S7_IDX, "s7", NULL, 0, 1},
|
11047 |
|
|
+ {REG_GPR, S8_IDX, "s8", NULL, 0, 1},
|
11048 |
|
|
+ {REG_GPR, S9_IDX, "s9", NULL, 0, 1},
|
11049 |
|
|
+ {REG_GPR, SA_IDX, "sA", NULL, 0, 1},
|
11050 |
|
|
+ {REG_GPR, SB_IDX, "sB", NULL, 0, 1},
|
11051 |
|
|
+ {REG_GPR, SC_IDX, "sC", NULL, 0, 1},
|
11052 |
|
|
+ {REG_GPR, SD_IDX, "sD", NULL, 0, 1},
|
11053 |
|
|
+ {REG_GPR, SE_IDX, "sE", NULL, 0, 1},
|
11054 |
|
|
+ {REG_GPR, SF_IDX, "sF", NULL, 0, 1},
|
11055 |
|
|
+};
|
11056 |
|
|
+int json_nRegs = 16;
|
11057 |
|
|
+int json_fReg = 0; /* first allocatable register */
|
11058 |
|
|
+
|
11059 |
|
|
+
|
11060 |
|
|
+
|
11061 |
|
|
+
|
11062 |
|
|
+/*-----------------------------------------------------------------*/
|
11063 |
|
|
+/* json_regWithIdx - returns pointer to register with index number*/
|
11064 |
|
|
+/*-----------------------------------------------------------------*/
|
11065 |
|
|
+regs *
|
11066 |
|
|
+json_regWithIdx (int idx)
|
11067 |
|
|
+{
|
11068 |
|
|
+ int i;
|
11069 |
|
|
+
|
11070 |
|
|
+ for (i = 0; i < json_nRegs; i++)
|
11071 |
|
|
+ if (regsJSON[i].rIdx == idx)
|
11072 |
|
|
+ return ®sJSON[i];
|
11073 |
|
|
+
|
11074 |
|
|
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "regWithIdx not found");
|
11075 |
|
|
+ exit (1);
|
11076 |
|
|
+}
|
11077 |
|
|
+
|
11078 |
|
|
+/*-----------------------------------------------------------------*/
|
11079 |
|
|
+/* firstFreeReg - returns first free register */
|
11080 |
|
|
+/*-----------------------------------------------------------------*/
|
11081 |
|
|
+static regs *
|
11082 |
|
|
+firstFreeReg (void)
|
11083 |
|
|
+{
|
11084 |
|
|
+ int i;
|
11085 |
|
|
+
|
11086 |
|
|
+ for (i = 0; i < json_nRegs; i++) {
|
11087 |
|
|
+ if(regsJSON[i].isFree == 1)
|
11088 |
|
|
+ return ®sJSON[i];
|
11089 |
|
|
+
|
11090 |
|
|
+ }
|
11091 |
|
|
+
|
11092 |
|
|
+ return NULL;
|
11093 |
|
|
+}
|
11094 |
|
|
+
|
11095 |
|
|
+
|
11096 |
|
|
+
|
11097 |
|
|
+/*-----------------------------------------------------------------*/
|
11098 |
|
|
+/* freeReg - frees a register */
|
11099 |
|
|
+/*-----------------------------------------------------------------*/
|
11100 |
|
|
+static void
|
11101 |
|
|
+freeReg (regs * reg)
|
11102 |
|
|
+{
|
11103 |
|
|
+ reg->isFree = 1;
|
11104 |
|
|
+ reg->currSymbol = NULL;
|
11105 |
|
|
+}
|
11106 |
|
|
+
|
11107 |
|
|
+
|
11108 |
|
|
+/*-----------------------------------------------------------------*/
|
11109 |
|
|
+/* nFreeRegs - returns number of free registers */
|
11110 |
|
|
+/*-----------------------------------------------------------------*/
|
11111 |
|
|
+static int
|
11112 |
|
|
+nFreeRegs (void)
|
11113 |
|
|
+{
|
11114 |
|
|
+ int i;
|
11115 |
|
|
+ int nfr = 0;
|
11116 |
|
|
+
|
11117 |
|
|
+ for (i = json_fReg; i < json_nRegs; i++)
|
11118 |
|
|
+ if (regsJSON[i].isFree )
|
11119 |
|
|
+ nfr++;
|
11120 |
|
|
+ return nfr;
|
11121 |
|
|
+}
|
11122 |
|
|
+
|
11123 |
|
|
+
|
11124 |
|
|
+/*-----------------------------------------------------------------*/
|
11125 |
|
|
+/* isSymbolInReg - test if symbol is in registers */
|
11126 |
|
|
+/*-----------------------------------------------------------------*/
|
11127 |
|
|
+static int isSymbolInReg( symbol *s)
|
11128 |
|
|
+{
|
11129 |
|
|
+ int i, size, found = 0;
|
11130 |
|
|
+
|
11131 |
|
|
+ if(!s)
|
11132 |
|
|
+ return 0;
|
11133 |
|
|
+
|
11134 |
|
|
+
|
11135 |
|
|
+ size = getSize ( s->type );
|
11136 |
|
|
+
|
11137 |
|
|
+
|
11138 |
|
|
+ // && s->regs[ regsJSON[i].offset ] == ®sJSON[i]
|
11139 |
|
|
+
|
11140 |
|
|
+
|
11141 |
|
|
+ for (i = json_fReg; i < json_nRegs; i++)
|
11142 |
|
|
+ {
|
11143 |
|
|
+ if (regsJSON[i].currSymbol == s ) {
|
11144 |
|
|
+ found++;
|
11145 |
|
|
+ }
|
11146 |
|
|
+
|
11147 |
|
|
+ }
|
11148 |
|
|
+
|
11149 |
|
|
+ if (found == size) return 1;
|
11150 |
|
|
+ else if (found == 0) return 0;
|
11151 |
|
|
+
|
11152 |
|
|
+ wassertl(FALSE, "chybi cast operandu v registrech");
|
11153 |
|
|
+}
|
11154 |
|
|
+
|
11155 |
|
|
+
|
11156 |
|
|
+/*-----------------------------------------------------------------*/
|
11157 |
|
|
+/* assignReg - assign registers to the symbol */
|
11158 |
|
|
+/*-----------------------------------------------------------------*/
|
11159 |
|
|
+void
|
11160 |
|
|
+XXXassignReg (operand * op)
|
11161 |
|
|
+{
|
11162 |
|
|
+ regs *rtmp;
|
11163 |
|
|
+ int i, size;
|
11164 |
|
|
+
|
11165 |
|
|
+ // Q? pouze typ Symbol
|
11166 |
|
|
+ if(op->type == SYMBOL) {
|
11167 |
|
|
+
|
11168 |
|
|
+ /* get number of requied registers */
|
11169 |
|
|
+ size = getSize ( operandType (op) );
|
11170 |
|
|
+ //size = OP_SYMBOL(op)->nRegs;
|
11171 |
|
|
+
|
11172 |
|
|
+ /* symbol is already in the registers */
|
11173 |
|
|
+ if ( isSymbolInReg( OP_SYMBOL(op) ) ) {
|
11174 |
|
|
+
|
11175 |
|
|
+
|
11176 |
|
|
+ }
|
11177 |
|
|
+
|
11178 |
|
|
+
|
11179 |
|
|
+ /* symbol is not in the registers and there is a sufficient number of registers for assigment */
|
11180 |
|
|
+ else if (nFreeRegs() >= size) {
|
11181 |
|
|
+
|
11182 |
|
|
+ //printf("Size:%d\n", size);
|
11183 |
|
|
+
|
11184 |
|
|
+ OP_SYMBOL(op)->nRegs = size;
|
11185 |
|
|
+
|
11186 |
|
|
+ for(i = 0; i<size; i++) {
|
11187 |
|
|
+
|
11188 |
|
|
+ rtmp = firstFreeReg();
|
11189 |
|
|
+ if(!rtmp) assert ("neosetreno\n");
|
11190 |
|
|
+
|
11191 |
|
|
+ rtmp->isFree = 0;
|
11192 |
|
|
+ rtmp->currSymbol = OP_SYMBOL(op);
|
11193 |
|
|
+ rtmp->offset = i;
|
11194 |
|
|
+
|
11195 |
|
|
+ OP_SYMBOL(op)->regs[i] = rtmp;
|
11196 |
|
|
+
|
11197 |
|
|
+ }
|
11198 |
|
|
+
|
11199 |
|
|
+ }
|
11200 |
|
|
+
|
11201 |
|
|
+ // TODO: nedostatek registru,
|
11202 |
|
|
+ // Q?: potreba uvolnit -> pamet / zasobnik
|
11203 |
|
|
+ else {
|
11204 |
|
|
+
|
11205 |
|
|
+
|
11206 |
|
|
+
|
11207 |
|
|
+ }
|
11208 |
|
|
+
|
11209 |
|
|
+ }
|
11210 |
|
|
+}
|
11211 |
|
|
+
|
11212 |
|
|
+
|
11213 |
|
|
+
|
11214 |
|
|
+/*-----------------------------------------------------------------*/
|
11215 |
|
|
+/* assignRegisters */
|
11216 |
|
|
+/*-----------------------------------------------------------------*/
|
11217 |
|
|
+void
|
11218 |
|
|
+json_assignRegisters (ebbIndex * ebbi)
|
11219 |
|
|
+{
|
11220 |
|
|
+ eBBlock ** ebbs = ebbi->bbOrder;
|
11221 |
|
|
+ int count = ebbi->count;
|
11222 |
|
|
+ iCode *ic;
|
11223 |
|
|
+ int i;
|
11224 |
|
|
+
|
11225 |
|
|
+ setToNull ((void *) &_G.funcrUsed);
|
11226 |
|
|
+ //json_ptrRegReq = _G.stackExtend = _G.dataExtend = 0;
|
11227 |
|
|
+
|
11228 |
|
|
+
|
11229 |
|
|
+
|
11230 |
|
|
+ /* now get back the chain */
|
11231 |
|
|
+ //ic = iCodeLabelOptimize (iCodeFromeBBlock (ebbs, count));
|
11232 |
|
|
+
|
11233 |
|
|
+ //symbol *sym, *tempsym;
|
11234 |
|
|
+ //sym = (symbol *) findSymWithLevel(SymbolTab,tempsym);
|
11235 |
|
|
+ //printf("sym:%s\n", SymbolTab[0]->name);
|
11236 |
|
|
+
|
11237 |
|
|
+
|
11238 |
|
|
+ ic = iCodeFromeBBlock (ebbs, count);
|
11239 |
|
|
+
|
11240 |
|
|
+ genJSONCode (ic);
|
11241 |
|
|
+ /* for (; ic ; ic = ic->next) */
|
11242 |
|
|
+ /* piCode(ic,stdout); */
|
11243 |
|
|
+ /* free up any _G.stackSpil locations allocated */
|
11244 |
|
|
+
|
11245 |
|
|
+ _G.slocNum = 0;
|
11246 |
|
|
+
|
11247 |
|
|
+ /* mark all registers as free */
|
11248 |
|
|
+
|
11249 |
|
|
+ return;
|
11250 |
|
|
+}
|
11251 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/json/ralloc.h sdcc-src-3.1.0-pblaze/src/json/ralloc.h
|
11252 |
|
|
--- sdcc-src-3.1.0/src/json/ralloc.h 1970-01-01 01:00:00.000000000 +0100
|
11253 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/json/ralloc.h 2011-02-07 20:04:44.000000000 +0100
|
11254 |
|
|
@@ -0,0 +1,58 @@
|
11255 |
|
|
+/*-------------------------------------------------------------------------
|
11256 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
11257 |
|
|
+ under the terms of the GNU General Public License as published by the
|
11258 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
11259 |
|
|
+ later version.
|
11260 |
|
|
+
|
11261 |
|
|
+ This program is distributed in the hope that it will be useful,
|
11262 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11263 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11264 |
|
|
+ GNU General Public License for more details.
|
11265 |
|
|
+
|
11266 |
|
|
+ You should have received a copy of the GNU General Public License
|
11267 |
|
|
+ along with this program; if not, write to the Free Software
|
11268 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
11269 |
|
|
+
|
11270 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
11271 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
11272 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
11273 |
|
|
+-------------------------------------------------------------------------*/
|
11274 |
|
|
+#ifndef _JSON_SDCCRALLOC_H
|
11275 |
|
|
+#define _JSON_SDCCRALLOC_H
|
11276 |
|
|
+
|
11277 |
|
|
+#include "SDCCicode.h"
|
11278 |
|
|
+#include "SDCCBBlock.h"
|
11279 |
|
|
+
|
11280 |
|
|
+
|
11281 |
|
|
+enum
|
11282 |
|
|
+ {
|
11283 |
|
|
+ S0_IDX = 0,
|
11284 |
|
|
+ S1_IDX, S2_IDX, S3_IDX, S4_IDX,
|
11285 |
|
|
+ S5_IDX, S6_IDX, S7_IDX, S8_IDX,
|
11286 |
|
|
+ S9_IDX, SA_IDX, SB_IDX, SC_IDX,
|
11287 |
|
|
+ SD_IDX, SE_IDX, SF_IDX
|
11288 |
|
|
+ };
|
11289 |
|
|
+
|
11290 |
|
|
+
|
11291 |
|
|
+#define REG_PTR 0x01
|
11292 |
|
|
+#define REG_GPR 0x02 /* general purpose registers*/
|
11293 |
|
|
+
|
11294 |
|
|
+
|
11295 |
|
|
+/* definition for the registers */
|
11296 |
|
|
+typedef struct regs
|
11297 |
|
|
+ {
|
11298 |
|
|
+ short type; /* PicoBlaze have only REG_GPR */
|
11299 |
|
|
+ short rIdx; /* index into register table */
|
11300 |
|
|
+ char *name; /* name */
|
11301 |
|
|
+ symbol *currSymbol; /* current symbol in the register */
|
11302 |
|
|
+ short offset; /* offset of the operand (if larger than 1B) */
|
11303 |
|
|
+ unsigned isFree:1; /* is currently unassigned */
|
11304 |
|
|
+ }
|
11305 |
|
|
+regs;
|
11306 |
|
|
+extern regs regsJSON[];
|
11307 |
|
|
+
|
11308 |
|
|
+//void assignReg (operand * op);
|
11309 |
|
|
+
|
11310 |
|
|
+regs *json_regWithIdx (int);
|
11311 |
|
|
+
|
11312 |
|
|
+#endif
|
11313 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/Makefile.in sdcc-src-3.1.0-pblaze/src/pblaze/Makefile.in
|
11314 |
|
|
--- sdcc-src-3.1.0/src/pblaze/Makefile.in 1970-01-01 01:00:00.000000000 +0100
|
11315 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/Makefile.in 2011-08-23 15:56:30.000000000 +0200
|
11316 |
|
|
@@ -0,0 +1,8 @@
|
11317 |
|
|
+VPATH = @srcdir@
|
11318 |
|
|
+srcdir = @srcdir@
|
11319 |
|
|
+top_builddir = @top_builddir@
|
11320 |
|
|
+top_srcdir = @top_srcdir@
|
11321 |
|
|
+
|
11322 |
|
|
+# Make all in this directory
|
11323 |
|
|
+include $(srcdir)/../port.mk
|
11324 |
|
|
+
|
11325 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/gen.c sdcc-src-3.1.0-pblaze/src/pblaze/gen.c
|
11326 |
|
|
--- sdcc-src-3.1.0/src/pblaze/gen.c 1970-01-01 01:00:00.000000000 +0100
|
11327 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/gen.c 2011-12-05 23:53:59.470216200 +0100
|
11328 |
|
|
@@ -0,0 +1,3628 @@
|
11329 |
|
|
+/*-------------------------------------------------------------------------
|
11330 |
|
|
+gen.c - source file for code generation for XILINX PICOBLAZE
|
11331 |
|
|
+
|
11332 |
|
|
+Author:
|
11333 |
|
|
+ Jakub Hornik, xhorni00<at>stud.fit.vutbr.cz
|
11334 |
|
|
+Master Thesis Project:
|
11335 |
|
|
+ Compiler Back-End of Subset of Language C for 8-Bit Processor
|
11336 |
|
|
+Date:
|
11337 |
|
|
+ 2011
|
11338 |
|
|
+
|
11339 |
|
|
+This program is free software; you can redistribute it and/or modify it
|
11340 |
|
|
+under the terms of the GNU General Public License as published by the
|
11341 |
|
|
+Free Software Foundation; either version 2, or (at your option) any
|
11342 |
|
|
+later version.
|
11343 |
|
|
+
|
11344 |
|
|
+This program is distributed in the hope that it will be useful,
|
11345 |
|
|
+but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11346 |
|
|
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11347 |
|
|
+GNU General Public License for more details.
|
11348 |
|
|
+
|
11349 |
|
|
+You should have received a copy of the GNU General Public License
|
11350 |
|
|
+along with this program; if not, write to the Free Software
|
11351 |
|
|
+Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
11352 |
|
|
+
|
11353 |
|
|
+In other words, you are welcome to use, share and improve this program.
|
11354 |
|
|
+You are forbidden to forbid anyone else to use, share and improve
|
11355 |
|
|
+what you give them. Help stamp out software-hoarding!
|
11356 |
|
|
+
|
11357 |
|
|
+
|
11358 |
|
|
+-------------------------------------------------------------------------*/
|
11359 |
|
|
+
|
11360 |
|
|
+#define D(x) do if (options.verboseAsm) {x;} while(0)
|
11361 |
|
|
+#define LBL_KEY(x) x->key+100
|
11362 |
|
|
+
|
11363 |
|
|
+#include <stdio.h>
|
11364 |
|
|
+#include <stdlib.h>
|
11365 |
|
|
+#include <string.h>
|
11366 |
|
|
+#include <ctype.h>
|
11367 |
|
|
+#include "SDCCglobl.h"
|
11368 |
|
|
+#include "newalloc.h"
|
11369 |
|
|
+
|
11370 |
|
|
+#include "common.h"
|
11371 |
|
|
+#include "SDCCpeeph.h"
|
11372 |
|
|
+#include "ralloc.h"
|
11373 |
|
|
+#include "gen.h"
|
11374 |
|
|
+
|
11375 |
|
|
+static struct {
|
11376 |
|
|
+ short onStack;
|
11377 |
|
|
+ short inLine;
|
11378 |
|
|
+ short debugLine;
|
11379 |
|
|
+ short isCalleSaves;
|
11380 |
|
|
+ short ptrOff;
|
11381 |
|
|
+ set *sendSet;
|
11382 |
|
|
+ set *inOutSet;
|
11383 |
|
|
+ bitVect *rUsedVect;
|
11384 |
|
|
+ iCode *current_iCode;
|
11385 |
|
|
+} _G;
|
11386 |
|
|
+
|
11387 |
|
|
+
|
11388 |
|
|
+static struct {
|
11389 |
|
|
+ short mschar;
|
11390 |
|
|
+ short muschar;
|
11391 |
|
|
+ short mint;
|
11392 |
|
|
+ short mlong;
|
11393 |
|
|
+ short dschar;
|
11394 |
|
|
+ short duschar;
|
11395 |
|
|
+ short modschar;
|
11396 |
|
|
+ short moduschar;
|
11397 |
|
|
+ short dsint;
|
11398 |
|
|
+ short dusint;
|
11399 |
|
|
+ short modsint;
|
11400 |
|
|
+ short modusint;
|
11401 |
|
|
+ short dslong;
|
11402 |
|
|
+ short duslong;
|
11403 |
|
|
+ short modslong;
|
11404 |
|
|
+ short moduslong;
|
11405 |
|
|
+} _GFunc;
|
11406 |
|
|
+
|
11407 |
|
|
+extern int allocInfo;
|
11408 |
|
|
+extern int pblaze_ptrRegReq;
|
11409 |
|
|
+extern int pblaze_nRegs;
|
11410 |
|
|
+extern struct dbuf_s *codeOutBuf;
|
11411 |
|
|
+
|
11412 |
|
|
+/* function return value registers - shared with send/receive */
|
11413 |
|
|
+char *fReturnPBLAZE[] = { "sB", "sC", "sD", "sE" };
|
11414 |
|
|
+
|
11415 |
|
|
+unsigned fPBLAZEReturnSize = 4; /* shared with ralloc.c */
|
11416 |
|
|
+char **fPBLAZEReturn = fReturnPBLAZE;
|
11417 |
|
|
+char buffValP[64];
|
11418 |
|
|
+char *buffVal = buffValP;
|
11419 |
|
|
+
|
11420 |
|
|
+static lineNode *lineHead = NULL;
|
11421 |
|
|
+static lineNode *lineCurr = NULL;
|
11422 |
|
|
+
|
11423 |
|
|
+static int recvCnt = 0;
|
11424 |
|
|
+short initGen = 0;
|
11425 |
|
|
+
|
11426 |
|
|
+/*-----------------------------------------------------------------*/
|
11427 |
|
|
+/* pblaze_emitcode - writes the code into a file */
|
11428 |
|
|
+/*-----------------------------------------------------------------*/
|
11429 |
|
|
+static void pblaze_emitcode(char *inst, char *fmt, ...)
|
11430 |
|
|
+{
|
11431 |
|
|
+ va_list ap;
|
11432 |
|
|
+ char lb[INITIAL_INLINEASM];
|
11433 |
|
|
+ char *lbp = lb;
|
11434 |
|
|
+
|
11435 |
|
|
+ va_start(ap, fmt);
|
11436 |
|
|
+
|
11437 |
|
|
+ if (inst && *inst) {
|
11438 |
|
|
+ if (fmt && *fmt)
|
11439 |
|
|
+ sprintf(lb, "%s\t", inst);
|
11440 |
|
|
+ else
|
11441 |
|
|
+ sprintf(lb, "%s", inst);
|
11442 |
|
|
+ vsprintf(lb + (strlen(lb)), fmt, ap);
|
11443 |
|
|
+ } else
|
11444 |
|
|
+ vsprintf(lb, fmt, ap);
|
11445 |
|
|
+
|
11446 |
|
|
+ while (isspace((unsigned char) *lbp))
|
11447 |
|
|
+ lbp++;
|
11448 |
|
|
+
|
11449 |
|
|
+ if (lbp && *lbp)
|
11450 |
|
|
+ lineCurr = (lineCurr ? connectLine(lineCurr, newLineNode(lb)) : (lineHead = newLineNode(lb)));
|
11451 |
|
|
+ lineCurr->isInline = _G.inLine;
|
11452 |
|
|
+ lineCurr->isDebug = _G.debugLine;
|
11453 |
|
|
+ lineCurr->ic = _G.current_iCode;
|
11454 |
|
|
+ va_end(ap);
|
11455 |
|
|
+}
|
11456 |
|
|
+
|
11457 |
|
|
+/*-----------------------------------------------------------------*/
|
11458 |
|
|
+/* dialectNum-convert a number to a string with the correct dialect */
|
11459 |
|
|
+/*-----------------------------------------------------------------*/
|
11460 |
|
|
+char *dialectNum(int num)
|
11461 |
|
|
+{
|
11462 |
|
|
+ char *s = buffVal;
|
11463 |
|
|
+ sprintf(s, "%s%02x", pblaze_options.dialect ? "" : "$", num);
|
11464 |
|
|
+ return Safe_strdup(s);
|
11465 |
|
|
+}
|
11466 |
|
|
+
|
11467 |
|
|
+
|
11468 |
|
|
+/*-----------------------------------------------------------------*/
|
11469 |
|
|
+/* addInOutRef - mark oper as IN/OUT pointer with given offset */
|
11470 |
|
|
+/*-----------------------------------------------------------------*/
|
11471 |
|
|
+void addInOutRef(operand * oper, operand * offset)
|
11472 |
|
|
+{
|
11473 |
|
|
+ unsigned long lit = 0L;
|
11474 |
|
|
+ inOutStruct_t *tmpInOut = Safe_alloc(sizeof(inOutStruct_t));
|
11475 |
|
|
+
|
11476 |
|
|
+ tmpInOut->name = Safe_strdup(OP_SYMBOL(oper)->name);
|
11477 |
|
|
+ tmpInOut->tempOper = oper;
|
11478 |
|
|
+ tmpInOut->liveFrom = OP_LIVEFROM(oper);
|
11479 |
|
|
+ tmpInOut->liveTo = OP_LIVETO(oper);
|
11480 |
|
|
+
|
11481 |
|
|
+ if (!offset) {
|
11482 |
|
|
+ tmpInOut->isNumOffset = 1;
|
11483 |
|
|
+ tmpInOut->regOffset = NULL;
|
11484 |
|
|
+ tmpInOut->numOffset = 0L;
|
11485 |
|
|
+
|
11486 |
|
|
+ } else if (isOperandLiteral(offset)) {
|
11487 |
|
|
+ lit = ulFromVal(OP_VALUE(offset));
|
11488 |
|
|
+ tmpInOut->isNumOffset = 1;
|
11489 |
|
|
+ tmpInOut->regOffset = NULL;
|
11490 |
|
|
+ tmpInOut->numOffset = lit;
|
11491 |
|
|
+ } else {
|
11492 |
|
|
+ tmpInOut->isNumOffset = 0;
|
11493 |
|
|
+ tmpInOut->regOffset = offset;
|
11494 |
|
|
+ }
|
11495 |
|
|
+ addSet(&_G.inOutSet, tmpInOut);
|
11496 |
|
|
+}
|
11497 |
|
|
+
|
11498 |
|
|
+/*-----------------------------------------------------------------*/
|
11499 |
|
|
+/* isInOutRef - test if the given operand is a IN/OUT pointer */
|
11500 |
|
|
+/*-----------------------------------------------------------------*/
|
11501 |
|
|
+int isInOutRef(operand * oper)
|
11502 |
|
|
+{
|
11503 |
|
|
+ char *name = OP_SYMBOL(oper)->name;
|
11504 |
|
|
+ if (strcmp(pblaze_options.portKw, name) == 0)
|
11505 |
|
|
+ return 1;
|
11506 |
|
|
+
|
11507 |
|
|
+ set *lp;
|
11508 |
|
|
+
|
11509 |
|
|
+ for (lp = _G.inOutSet; lp; lp = lp->next) {
|
11510 |
|
|
+ inOutStruct_t *p = lp->item;
|
11511 |
|
|
+ if (strcmp(p->name, name) == 0)
|
11512 |
|
|
+ return 1;
|
11513 |
|
|
+ }
|
11514 |
|
|
+ return 0;
|
11515 |
|
|
+}
|
11516 |
|
|
+
|
11517 |
|
|
+/*-----------------------------------------------------------------*/
|
11518 |
|
|
+/* getInOutRef - return io struct of the given operand */
|
11519 |
|
|
+/*-----------------------------------------------------------------*/
|
11520 |
|
|
+inOutStruct_t *getInOutRef(operand * oper)
|
11521 |
|
|
+{
|
11522 |
|
|
+ char *name = OP_SYMBOL(oper)->name;
|
11523 |
|
|
+ set *lp;
|
11524 |
|
|
+
|
11525 |
|
|
+ for (lp = _G.inOutSet; lp; lp = lp->next) {
|
11526 |
|
|
+ inOutStruct_t *p = lp->item;
|
11527 |
|
|
+ if (strcmp(p->name, name) == 0)
|
11528 |
|
|
+ break;
|
11529 |
|
|
+ }
|
11530 |
|
|
+ if (!lp)
|
11531 |
|
|
+ return NULL;
|
11532 |
|
|
+
|
11533 |
|
|
+ return lp->item;
|
11534 |
|
|
+}
|
11535 |
|
|
+
|
11536 |
|
|
+/*-------------------------------------------------------------------------*/
|
11537 |
|
|
+/* pblaze_emitcodeOutput - emit OUTPUT instruction with given params */
|
11538 |
|
|
+/*-------------------------------------------------------------------------*/
|
11539 |
|
|
+void pblaze_emitcodeOutputNum(char *l, char *r)
|
11540 |
|
|
+{
|
11541 |
|
|
+ if (pblaze_options.dialect)
|
11542 |
|
|
+ pblaze_emitcode("OUTPUT", "%s, %s", l, r);
|
11543 |
|
|
+ else
|
11544 |
|
|
+ pblaze_emitcode("OUT", "%s, %s", l, r);
|
11545 |
|
|
+}
|
11546 |
|
|
+
|
11547 |
|
|
+/*-------------------------------------------------------------------------*/
|
11548 |
|
|
+/* pblaze_emitcodeOutput - emit OUTPUT instruction with given params */
|
11549 |
|
|
+/*-------------------------------------------------------------------------*/
|
11550 |
|
|
+void pblaze_emitcodeOutputReg(char *l, char *r)
|
11551 |
|
|
+{
|
11552 |
|
|
+ if (pblaze_options.dialect)
|
11553 |
|
|
+ pblaze_emitcode("OUTPUT", "%s, (%s)", l, r);
|
11554 |
|
|
+ else
|
11555 |
|
|
+ pblaze_emitcode("OUT", "%s, %s", l, r);
|
11556 |
|
|
+}
|
11557 |
|
|
+
|
11558 |
|
|
+/*-------------------------------------------------------------------------*/
|
11559 |
|
|
+/* pblaze_emitcodeOutput - emit OUTPUT instruction with given params */
|
11560 |
|
|
+/*-------------------------------------------------------------------------*/
|
11561 |
|
|
+void pblaze_emitcodeOutput(iCode * ic, char *source, operand * to)
|
11562 |
|
|
+{
|
11563 |
|
|
+ inOutStruct_t *tmp;
|
11564 |
|
|
+ tmp = getInOutRef(to);
|
11565 |
|
|
+
|
11566 |
|
|
+ if (!tmp) {
|
11567 |
|
|
+ return;
|
11568 |
|
|
+ } else if (tmp->isNumOffset) {
|
11569 |
|
|
+ pblaze_emitcodeOutputNum(source, dialectNum((int) tmp->numOffset));
|
11570 |
|
|
+ } else {
|
11571 |
|
|
+ pblaze_emitcodeOutputReg(source, aopGetRegName(ic, tmp->regOffset, 0));
|
11572 |
|
|
+ }
|
11573 |
|
|
+}
|
11574 |
|
|
+
|
11575 |
|
|
+/*-------------------------------------------------------------------------*/
|
11576 |
|
|
+/* pblaze_emitcodeInputNum - emit INPUT instruction with given params */
|
11577 |
|
|
+/*-------------------------------------------------------------------------*/
|
11578 |
|
|
+void pblaze_emitcodeInputNum(char *l, char *r)
|
11579 |
|
|
+{
|
11580 |
|
|
+ if (pblaze_options.dialect)
|
11581 |
|
|
+ pblaze_emitcode("INPUT", "%s, %s", l, r);
|
11582 |
|
|
+ else
|
11583 |
|
|
+ pblaze_emitcode("IN", "%s, %s", l, r);
|
11584 |
|
|
+}
|
11585 |
|
|
+
|
11586 |
|
|
+/*-------------------------------------------------------------------------*/
|
11587 |
|
|
+/* pblaze_emitcodeInputReg - emit INPUT instruction with given params */
|
11588 |
|
|
+/*-------------------------------------------------------------------------*/
|
11589 |
|
|
+void pblaze_emitcodeInputReg(char *l, char *r)
|
11590 |
|
|
+{
|
11591 |
|
|
+ if (pblaze_options.dialect)
|
11592 |
|
|
+ pblaze_emitcode("INPUT", "%s, (%s)", l, r);
|
11593 |
|
|
+ else
|
11594 |
|
|
+ pblaze_emitcode("IN", "%s, %s", l, r);
|
11595 |
|
|
+}
|
11596 |
|
|
+
|
11597 |
|
|
+/*-----------------------------------------------------------------*/
|
11598 |
|
|
+/* pblaze_emitcodeInput - emit INPUT instruction with given params */
|
11599 |
|
|
+/*-----------------------------------------------------------------*/
|
11600 |
|
|
+void pblaze_emitcodeInput(iCode * ic, operand * result, int resOffset, operand * from)
|
11601 |
|
|
+{
|
11602 |
|
|
+ inOutStruct_t *tmp;
|
11603 |
|
|
+ tmp = getInOutRef(from);
|
11604 |
|
|
+
|
11605 |
|
|
+ if (!tmp) {
|
11606 |
|
|
+ return;
|
11607 |
|
|
+ } else if (tmp->isNumOffset) {
|
11608 |
|
|
+ pblaze_emitcodeInputNum(aopGetRegName(ic, result, resOffset), dialectNum((int) tmp->numOffset));
|
11609 |
|
|
+ } else {
|
11610 |
|
|
+ pblaze_emitcodeInputReg(aopGetRegName(ic, result, resOffset), aopGetRegName(ic, tmp->regOffset, 0));
|
11611 |
|
|
+ }
|
11612 |
|
|
+}
|
11613 |
|
|
+
|
11614 |
|
|
+
|
11615 |
|
|
+/*-----------------------------------------------------------------*/
|
11616 |
|
|
+/* emit functions */
|
11617 |
|
|
+/*-----------------------------------------------------------------*/
|
11618 |
|
|
+void pblaze_emitLabel(symbol * tlbl)
|
11619 |
|
|
+{
|
11620 |
|
|
+ pblaze_emitcode("", "_L%05d:", LBL_KEY(tlbl));
|
11621 |
|
|
+ lineCurr->isLabel = 1;
|
11622 |
|
|
+}
|
11623 |
|
|
+
|
11624 |
|
|
+void pblaze_emitLabelC(symbol * tlbl)
|
11625 |
|
|
+{
|
11626 |
|
|
+ pblaze_emitcode("", "_LC%05d:", LBL_KEY(tlbl));
|
11627 |
|
|
+ lineCurr->isLabel = 1;
|
11628 |
|
|
+}
|
11629 |
|
|
+
|
11630 |
|
|
+void pblaze_emitcodeADDCY(char *l, char *r)
|
11631 |
|
|
+{
|
11632 |
|
|
+ if (pblaze_options.dialect)
|
11633 |
|
|
+ pblaze_emitcode("ADDCY", "%s, %s", l, r);
|
11634 |
|
|
+ else
|
11635 |
|
|
+ pblaze_emitcode("ADDC", "%s, %s", l, r);
|
11636 |
|
|
+}
|
11637 |
|
|
+
|
11638 |
|
|
+void pblaze_emitcodeSUBCY(char *l, char *r)
|
11639 |
|
|
+{
|
11640 |
|
|
+ if (pblaze_options.dialect)
|
11641 |
|
|
+ pblaze_emitcode("SUBCY", "%s, %s", l, r);
|
11642 |
|
|
+ else
|
11643 |
|
|
+ pblaze_emitcode("SUBC", "%s, %s", l, r);
|
11644 |
|
|
+}
|
11645 |
|
|
+
|
11646 |
|
|
+void pblaze_emitcodeCompare(char *l, char *r)
|
11647 |
|
|
+{
|
11648 |
|
|
+ if (pblaze_options.dialect)
|
11649 |
|
|
+ pblaze_emitcode("COMPARE", "%s, %s", l, r);
|
11650 |
|
|
+ else
|
11651 |
|
|
+ pblaze_emitcode("COMP", "%s, %s", l, r);
|
11652 |
|
|
+}
|
11653 |
|
|
+
|
11654 |
|
|
+void pblaze_emitcodeStore(char *l, char *r)
|
11655 |
|
|
+{
|
11656 |
|
|
+ if (pblaze_options.dialect && r[0] == 's')
|
11657 |
|
|
+ pblaze_emitcode("STORE", "%s, (%s)", l, r);
|
11658 |
|
|
+ else
|
11659 |
|
|
+ pblaze_emitcode("STORE", "%s, %s", l, r);
|
11660 |
|
|
+}
|
11661 |
|
|
+
|
11662 |
|
|
+void pblaze_emitcodeFetch(char *l, char *r)
|
11663 |
|
|
+{
|
11664 |
|
|
+ if (pblaze_options.dialect && r[0] == 's')
|
11665 |
|
|
+ pblaze_emitcode("FETCH", "%s, (%s)", l, r);
|
11666 |
|
|
+ else
|
11667 |
|
|
+ pblaze_emitcode("FETCH", "%s, %s", l, r);
|
11668 |
|
|
+}
|
11669 |
|
|
+
|
11670 |
|
|
+/*-----------------------------------------------------------------*/
|
11671 |
|
|
+/* isOpVolatile - test if operand is volatile */
|
11672 |
|
|
+/*-----------------------------------------------------------------*/
|
11673 |
|
|
+int isOpVolatile(operand * oper)
|
11674 |
|
|
+{
|
11675 |
|
|
+ sym_link *type, *search;
|
11676 |
|
|
+ if (!oper || oper->type != SYMBOL || OP_LIVETO(oper) != 0)
|
11677 |
|
|
+ return 0;
|
11678 |
|
|
+
|
11679 |
|
|
+ if (operandType(oper)) {
|
11680 |
|
|
+ for (type = operandType(oper); type && type->next; type = type->next);
|
11681 |
|
|
+
|
11682 |
|
|
+ while (type) {
|
11683 |
|
|
+
|
11684 |
|
|
+ if (IS_DECL(type) && DCL_PTR_VOLATILE(type))
|
11685 |
|
|
+ return 2;
|
11686 |
|
|
+
|
11687 |
|
|
+ else if (!IS_DECL(type) && SPEC_VOLATILE(type))
|
11688 |
|
|
+ return 1;
|
11689 |
|
|
+
|
11690 |
|
|
+ for (search = operandType(oper); search && search->next != type;)
|
11691 |
|
|
+ search = search->next;
|
11692 |
|
|
+ type = search;
|
11693 |
|
|
+ }
|
11694 |
|
|
+
|
11695 |
|
|
+ }
|
11696 |
|
|
+ return 0;
|
11697 |
|
|
+}
|
11698 |
|
|
+
|
11699 |
|
|
+// debug, test
|
11700 |
|
|
+void testOp(operand * oper)
|
11701 |
|
|
+{
|
11702 |
|
|
+ if (isOperandLiteral(oper)) {
|
11703 |
|
|
+ return;
|
11704 |
|
|
+ }
|
11705 |
|
|
+ printf("%s, rname:%s\t", OP_SYMBOL(oper)->name, OP_SYMBOL(oper)->rname);
|
11706 |
|
|
+ if (IS_OP_VOLATILE(oper)) {
|
11707 |
|
|
+ printf(" volatile, ");
|
11708 |
|
|
+ }
|
11709 |
|
|
+
|
11710 |
|
|
+ if (oper->isaddr) {
|
11711 |
|
|
+ printf(" adress, ");
|
11712 |
|
|
+ }
|
11713 |
|
|
+
|
11714 |
|
|
+ if (IS_OP_GLOBAL(oper)) {
|
11715 |
|
|
+ printf(" global, ");
|
11716 |
|
|
+ }
|
11717 |
|
|
+
|
11718 |
|
|
+ if (IS_OP_POINTER(oper)) {
|
11719 |
|
|
+ printf(" pointer, ");
|
11720 |
|
|
+ }
|
11721 |
|
|
+
|
11722 |
|
|
+ if (IS_OP_PARM(oper)) {
|
11723 |
|
|
+ printf(" parm, ");
|
11724 |
|
|
+ }
|
11725 |
|
|
+
|
11726 |
|
|
+ if (IS_ITEMP(oper)) {
|
11727 |
|
|
+ printf(" itemp, ");
|
11728 |
|
|
+ }
|
11729 |
|
|
+
|
11730 |
|
|
+ if (IS_PTR(OP_SYMBOL(oper)->type)) {
|
11731 |
|
|
+ printf(" is_ptr, ");
|
11732 |
|
|
+ }
|
11733 |
|
|
+
|
11734 |
|
|
+ if (IS_VOLATILE(OP_SYMBOL(oper)->type)) {
|
11735 |
|
|
+ printf(" is_volatile, ");
|
11736 |
|
|
+ }
|
11737 |
|
|
+
|
11738 |
|
|
+ if (IS_CODE(OP_SYMBOL(oper)->type)) {
|
11739 |
|
|
+ printf(" is_code, ");
|
11740 |
|
|
+ }
|
11741 |
|
|
+
|
11742 |
|
|
+ if (IS_ABSOLUTE(OP_SYMBOL(oper)->type)) {
|
11743 |
|
|
+ printf(" is_absolute, ");
|
11744 |
|
|
+ }
|
11745 |
|
|
+
|
11746 |
|
|
+ if (IS_REGISTER(OP_SYMBOL(oper)->type)) {
|
11747 |
|
|
+ printf(" is_register, ");
|
11748 |
|
|
+ }
|
11749 |
|
|
+
|
11750 |
|
|
+ if (IS_STATIC(OP_SYMBOL(oper)->type)) {
|
11751 |
|
|
+ printf(" is_static, ");
|
11752 |
|
|
+ }
|
11753 |
|
|
+
|
11754 |
|
|
+ if (IS_SYMOP(oper) && IS_ARRAY(OP_SYM_TYPE(oper))) {
|
11755 |
|
|
+ printf(" is_array, ");
|
11756 |
|
|
+ }
|
11757 |
|
|
+
|
11758 |
|
|
+ if (IS_SYMOP(oper) && IS_STRUCT(OP_SYM_TYPE(oper))) {
|
11759 |
|
|
+ printf(" is_struct, ");
|
11760 |
|
|
+ }
|
11761 |
|
|
+
|
11762 |
|
|
+ if (IS_SYMOP(oper) && IS_TYPEDEF(OP_SYM_TYPE(oper))) {
|
11763 |
|
|
+ printf(" is_typedef, ");
|
11764 |
|
|
+ }
|
11765 |
|
|
+
|
11766 |
|
|
+ if (isOpVolatile(oper))
|
11767 |
|
|
+ printf(" isvolatile, ");
|
11768 |
|
|
+
|
11769 |
|
|
+ printf("\n");
|
11770 |
|
|
+
|
11771 |
|
|
+}
|
11772 |
|
|
+
|
11773 |
|
|
+
|
11774 |
|
|
+/*-----------------------------------------------------------------*/
|
11775 |
|
|
+/* pblaze_emitDebuggerSymbol - associate the current code location */
|
11776 |
|
|
+/* with a debugger symbol */
|
11777 |
|
|
+/*-----------------------------------------------------------------*/
|
11778 |
|
|
+void pblaze_emitDebuggerSymbol(const char *debugSym)
|
11779 |
|
|
+{
|
11780 |
|
|
+ _G.debugLine = 1;
|
11781 |
|
|
+ pblaze_emitcode("", "%s ==.", debugSym);
|
11782 |
|
|
+ _G.debugLine = 0;
|
11783 |
|
|
+}
|
11784 |
|
|
+
|
11785 |
|
|
+
|
11786 |
|
|
+/*-----------------------------------------------------------------*/
|
11787 |
|
|
+/* valueOffset */
|
11788 |
|
|
+/*-----------------------------------------------------------------*/
|
11789 |
|
|
+unsigned int valueOffset(unsigned long lit, int offset)
|
11790 |
|
|
+{
|
11791 |
|
|
+ return ((lit >> (offset * 8)) & 0x0FFL);
|
11792 |
|
|
+}
|
11793 |
|
|
+
|
11794 |
|
|
+
|
11795 |
|
|
+/*-----------------------------------------------------------------*/
|
11796 |
|
|
+/* emit STORE and FETCH functions */
|
11797 |
|
|
+/*-----------------------------------------------------------------*/
|
11798 |
|
|
+void emitStore(char *r, int mem)
|
11799 |
|
|
+{
|
11800 |
|
|
+ char *s;
|
11801 |
|
|
+ s = operName(mem);
|
11802 |
|
|
+ if (!s)
|
11803 |
|
|
+ pblaze_emitcode("STORE", "%s, %s%02x", r, pblaze_options.dialect ? "" : "$", mem);
|
11804 |
|
|
+ else
|
11805 |
|
|
+ pblaze_emitcode("STORE", "%s, %s", r, s);
|
11806 |
|
|
+}
|
11807 |
|
|
+
|
11808 |
|
|
+void emitStoreReg(char *r, char *adr)
|
11809 |
|
|
+{
|
11810 |
|
|
+ if (pblaze_options.dialect)
|
11811 |
|
|
+ pblaze_emitcode("STORE", "%s, (%s)", r, adr);
|
11812 |
|
|
+ else
|
11813 |
|
|
+ pblaze_emitcode("STORE", "%s, %s", r, adr);
|
11814 |
|
|
+}
|
11815 |
|
|
+
|
11816 |
|
|
+void emitFetch(char *r, int mem)
|
11817 |
|
|
+{
|
11818 |
|
|
+ char *s;
|
11819 |
|
|
+ s = operName(mem);
|
11820 |
|
|
+ if (!s)
|
11821 |
|
|
+ pblaze_emitcode("FETCH", "%s, %s%02x", r, pblaze_options.dialect ? "" : "$", mem);
|
11822 |
|
|
+ else
|
11823 |
|
|
+ pblaze_emitcode("FETCH", "%s, %s", r, s);
|
11824 |
|
|
+}
|
11825 |
|
|
+
|
11826 |
|
|
+void emitLoadNumb(char *r, int val)
|
11827 |
|
|
+{
|
11828 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s%02x", r, pblaze_options.dialect ? "" : "$", val);
|
11829 |
|
|
+}
|
11830 |
|
|
+
|
11831 |
|
|
+void emitLoad(char *l, char *r)
|
11832 |
|
|
+{
|
11833 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", l, r);
|
11834 |
|
|
+}
|
11835 |
|
|
+
|
11836 |
|
|
+void emitcodeADD(char *l, int val)
|
11837 |
|
|
+{
|
11838 |
|
|
+ pblaze_emitcode("ADD", "%s, %s%02x", l, pblaze_options.dialect ? "" : "$", val);
|
11839 |
|
|
+}
|
11840 |
|
|
+
|
11841 |
|
|
+void emitcodeSUB(char *l, int val)
|
11842 |
|
|
+{
|
11843 |
|
|
+ pblaze_emitcode("SUB", "%s, %s%02x", l, pblaze_options.dialect ? "" : "$", val);
|
11844 |
|
|
+}
|
11845 |
|
|
+
|
11846 |
|
|
+
|
11847 |
|
|
+
|
11848 |
|
|
+/*-----------------------------------------------------------------*/
|
11849 |
|
|
+/* bitVect functions */
|
11850 |
|
|
+/*-----------------------------------------------------------------*/
|
11851 |
|
|
+void setRegUsed(int r)
|
11852 |
|
|
+{
|
11853 |
|
|
+ bitVectSetBit(_G.rUsedVect, r);
|
11854 |
|
|
+}
|
11855 |
|
|
+
|
11856 |
|
|
+int isRegUsed(int r)
|
11857 |
|
|
+{
|
11858 |
|
|
+ return bitVectBitValue(_G.rUsedVect, r);
|
11859 |
|
|
+}
|
11860 |
|
|
+
|
11861 |
|
|
+void clearBitVect(bitVect * bv)
|
11862 |
|
|
+{
|
11863 |
|
|
+ int i;
|
11864 |
|
|
+ for (i = 0; i < bv->size; i++)
|
11865 |
|
|
+ bitVectUnSetBit(bv, i);
|
11866 |
|
|
+}
|
11867 |
|
|
+
|
11868 |
|
|
+short isCalleesaves(void)
|
11869 |
|
|
+{
|
11870 |
|
|
+ return _G.isCalleSaves;
|
11871 |
|
|
+}
|
11872 |
|
|
+
|
11873 |
|
|
+
|
11874 |
|
|
+
|
11875 |
|
|
+
|
11876 |
|
|
+
|
11877 |
|
|
+/*-----------------------------------------------------------------*/
|
11878 |
|
|
+/* Push given register onto the stack */
|
11879 |
|
|
+/*-----------------------------------------------------------------*/
|
11880 |
|
|
+void pushStack(int rdx, int c)
|
11881 |
|
|
+{
|
11882 |
|
|
+ reg_info *rStack;
|
11883 |
|
|
+ rStack = pblaze_regWithIdx(rdx);
|
11884 |
|
|
+ pblaze_emitcodeStore(rStack->name, "sF");
|
11885 |
|
|
+ pblaze_emitcode("SUB", "sF, %s", dialectNum(1));
|
11886 |
|
|
+
|
11887 |
|
|
+ _G.onStack++;
|
11888 |
|
|
+
|
11889 |
|
|
+ staticMemoryCheck(MEMSIZE - _G.onStack - 1);
|
11890 |
|
|
+}
|
11891 |
|
|
+
|
11892 |
|
|
+/*-----------------------------------------------------------------*/
|
11893 |
|
|
+/* Pop top of the the stack into given register */
|
11894 |
|
|
+/*-----------------------------------------------------------------*/
|
11895 |
|
|
+void popStack(int rdx, int c)
|
11896 |
|
|
+{
|
11897 |
|
|
+ reg_info *rStack;
|
11898 |
|
|
+ rStack = pblaze_regWithIdx(rdx);
|
11899 |
|
|
+
|
11900 |
|
|
+ pblaze_emitcode("ADD", "sF, %s", dialectNum(1));
|
11901 |
|
|
+ pblaze_emitcodeFetch(rStack->name, "sF");
|
11902 |
|
|
+
|
11903 |
|
|
+ _G.onStack--;
|
11904 |
|
|
+ staticMemoryCheck(MEMSIZE - _G.onStack - 1);
|
11905 |
|
|
+}
|
11906 |
|
|
+
|
11907 |
|
|
+
|
11908 |
|
|
+/*-----------------------------------------------------------------*/
|
11909 |
|
|
+/* regsInCommon - two operands have some registers in common */
|
11910 |
|
|
+/*-----------------------------------------------------------------*/
|
11911 |
|
|
+static bool regsInCommon(operand * op1, operand * op2)
|
11912 |
|
|
+{
|
11913 |
|
|
+ symbol *sym1, *sym2;
|
11914 |
|
|
+ int i;
|
11915 |
|
|
+
|
11916 |
|
|
+ /* if they have registers in common */
|
11917 |
|
|
+ if (!IS_SYMOP(op1) || !IS_SYMOP(op2))
|
11918 |
|
|
+ return FALSE;
|
11919 |
|
|
+
|
11920 |
|
|
+ sym1 = OP_SYMBOL(op1);
|
11921 |
|
|
+ sym2 = OP_SYMBOL(op2);
|
11922 |
|
|
+
|
11923 |
|
|
+ if (sym1->nRegs == 0 || sym2->nRegs == 0)
|
11924 |
|
|
+ return FALSE;
|
11925 |
|
|
+
|
11926 |
|
|
+ for (i = 0; i < sym1->nRegs; i++) {
|
11927 |
|
|
+ int j;
|
11928 |
|
|
+ if (!sym1->regs[i])
|
11929 |
|
|
+ continue;
|
11930 |
|
|
+
|
11931 |
|
|
+ for (j = 0; j < sym2->nRegs; j++) {
|
11932 |
|
|
+ if (!sym2->regs[j])
|
11933 |
|
|
+ continue;
|
11934 |
|
|
+
|
11935 |
|
|
+ if (sym2->regs[j] == sym1->regs[i])
|
11936 |
|
|
+ return TRUE;
|
11937 |
|
|
+ }
|
11938 |
|
|
+ }
|
11939 |
|
|
+
|
11940 |
|
|
+ return FALSE;
|
11941 |
|
|
+}
|
11942 |
|
|
+
|
11943 |
|
|
+/*-----------------------------------------------------------------*/
|
11944 |
|
|
+/* pblaze_operandsEqu - equivalent */
|
11945 |
|
|
+/*-----------------------------------------------------------------*/
|
11946 |
|
|
+bool pblaze_operandsEqu(operand * op1, operand * op2)
|
11947 |
|
|
+{
|
11948 |
|
|
+ symbol *sym1, *sym2;
|
11949 |
|
|
+
|
11950 |
|
|
+ /* if they not symbols */
|
11951 |
|
|
+ if (!IS_SYMOP(op1) || !IS_SYMOP(op2))
|
11952 |
|
|
+ return FALSE;
|
11953 |
|
|
+
|
11954 |
|
|
+ sym1 = OP_SYMBOL(op1);
|
11955 |
|
|
+ sym2 = OP_SYMBOL(op2);
|
11956 |
|
|
+
|
11957 |
|
|
+ /* if they are the same */
|
11958 |
|
|
+ if (sym1 == sym2)
|
11959 |
|
|
+ return TRUE;
|
11960 |
|
|
+
|
11961 |
|
|
+ if (strcmp(sym1->rname, sym2->rname) == 0)
|
11962 |
|
|
+ return TRUE;
|
11963 |
|
|
+
|
11964 |
|
|
+
|
11965 |
|
|
+ /* if left is a tmp & right is not */
|
11966 |
|
|
+ if (IS_ITEMP(op1) && !IS_ITEMP(op2) && sym1->isspilt && (sym1->usl.spillLoc == sym2))
|
11967 |
|
|
+ return TRUE;
|
11968 |
|
|
+
|
11969 |
|
|
+ if (IS_ITEMP(op2) && !IS_ITEMP(op1) && sym2->isspilt && sym1->level > 0 && (sym2->usl.spillLoc == sym1))
|
11970 |
|
|
+ return TRUE;
|
11971 |
|
|
+
|
11972 |
|
|
+ return FALSE;
|
11973 |
|
|
+}
|
11974 |
|
|
+
|
11975 |
|
|
+/*-----------------------------------------------------------------*/
|
11976 |
|
|
+/* pointerSetOpt - optimization of assigning a value via a pointer */
|
11977 |
|
|
+/*-----------------------------------------------------------------*/
|
11978 |
|
|
+int pointerSetOpt(iCode * ic, int currOffset)
|
11979 |
|
|
+{
|
11980 |
|
|
+ iCode *aic, *pic, *lic;
|
11981 |
|
|
+ int pOffset, nOffset;
|
11982 |
|
|
+
|
11983 |
|
|
+ if (!POINTER_SET(ic))
|
11984 |
|
|
+ return 0;
|
11985 |
|
|
+
|
11986 |
|
|
+ if (!ic->next || !ic->next->next || !ic->prev)
|
11987 |
|
|
+ return 0;
|
11988 |
|
|
+
|
11989 |
|
|
+ aic = ic->next;
|
11990 |
|
|
+ pic = aic->next;
|
11991 |
|
|
+ lic = ic->prev;
|
11992 |
|
|
+
|
11993 |
|
|
+ /* previous offset of the pointer */
|
11994 |
|
|
+ if (pblaze_operandsEqu(IC_RESULT(ic), IC_RESULT(lic)) && OP_LIVETO(IC_RESULT(ic)) == ic->seq) {
|
11995 |
|
|
+ if (lic->op == '+' && isOperandLiteral(IC_RIGHT(lic))) {
|
11996 |
|
|
+ pOffset = (int) ulFromVal(OP_VALUE(IC_RIGHT(lic)));
|
11997 |
|
|
+ } else if (lic->op == ADDRESS_OF)
|
11998 |
|
|
+ pOffset = 0;
|
11999 |
|
|
+ else
|
12000 |
|
|
+ return 0;
|
12001 |
|
|
+ } else
|
12002 |
|
|
+ return 0;
|
12003 |
|
|
+
|
12004 |
|
|
+ /* next offset of the pointer */
|
12005 |
|
|
+ if (aic->op == '+' && POINTER_SET(pic) && pblaze_operandsEqu(IC_RESULT(aic), IC_RESULT(pic))
|
12006 |
|
|
+ && OP_LIVETO(IC_RESULT(pic)) == ic->seq + 2) {
|
12007 |
|
|
+ if (isOperandLiteral(IC_RIGHT(aic))) {
|
12008 |
|
|
+ nOffset = (int) ulFromVal(OP_VALUE(IC_RIGHT(aic)));
|
12009 |
|
|
+ } else
|
12010 |
|
|
+ return 0;
|
12011 |
|
|
+ } else
|
12012 |
|
|
+ return 0;
|
12013 |
|
|
+
|
12014 |
|
|
+ /* set pointer to the correct location */
|
12015 |
|
|
+ assignOpt(ic, IC_RESULT(aic), IC_RESULT(ic));
|
12016 |
|
|
+ pblaze_emitcode("ADD", "%s, %s", aopGetRegName(ic, IC_RESULT(aic), 0), dialectNum(nOffset - pOffset - currOffset));
|
12017 |
|
|
+ aopUpdateOpInMem(ic, IC_RESULT(aic), 0);
|
12018 |
|
|
+ /* set next ADD instruction as generated */
|
12019 |
|
|
+ aic->generated = 1;
|
12020 |
|
|
+
|
12021 |
|
|
+ return 1;
|
12022 |
|
|
+}
|
12023 |
|
|
+
|
12024 |
|
|
+/*-----------------------------------------------------------------*/
|
12025 |
|
|
+/* Copy registers */
|
12026 |
|
|
+/*-----------------------------------------------------------------*/
|
12027 |
|
|
+void copyRegisters(iCode * ic, operand * opTo, operand * opFrom, int rFrom, int rTo)
|
12028 |
|
|
+{
|
12029 |
|
|
+ int i;
|
12030 |
|
|
+ int sizeT = getSize(operandType(opTo));
|
12031 |
|
|
+
|
12032 |
|
|
+ for (i = rFrom; i <= rTo; i++) {
|
12033 |
|
|
+ aopPutReg(ic, opTo, aopGetReg(ic, opFrom, i), i);
|
12034 |
|
|
+ }
|
12035 |
|
|
+ for (; i < sizeT; i++) {
|
12036 |
|
|
+ aopPutVal(ic, opTo, dialectNum(0), i);
|
12037 |
|
|
+ }
|
12038 |
|
|
+}
|
12039 |
|
|
+
|
12040 |
|
|
+/*-----------------------------------------------------------------*/
|
12041 |
|
|
+/* pblaze_assignResultValue - */
|
12042 |
|
|
+/*-----------------------------------------------------------------*/
|
12043 |
|
|
+void pblaze_assignResultValue(iCode * ic, operand * oper)
|
12044 |
|
|
+{
|
12045 |
|
|
+ int i = 0;
|
12046 |
|
|
+ int size = getSize(operandType(oper));
|
12047 |
|
|
+ while (size--) {
|
12048 |
|
|
+ aopPutVal(ic, oper, fPBLAZEReturn[i], i);
|
12049 |
|
|
+ i++;
|
12050 |
|
|
+ }
|
12051 |
|
|
+}
|
12052 |
|
|
+
|
12053 |
|
|
+/*-----------------------------------------------------------------*/
|
12054 |
|
|
+/* assignLiteral - */
|
12055 |
|
|
+/*-----------------------------------------------------------------*/
|
12056 |
|
|
+void assignLiteral(operand * result, operand * literal, iCode * ic)
|
12057 |
|
|
+{
|
12058 |
|
|
+ int size, sizeR;
|
12059 |
|
|
+ unsigned long lit = 0L;
|
12060 |
|
|
+ int i;
|
12061 |
|
|
+
|
12062 |
|
|
+ /* is a literal value */
|
12063 |
|
|
+ if (isOperandLiteral(literal)) {
|
12064 |
|
|
+ /* get value and size */
|
12065 |
|
|
+ lit = ulFromVal(OP_VALUE(literal));
|
12066 |
|
|
+ size = getSize(operandType(literal));
|
12067 |
|
|
+ sizeR = getSize(operandType(result));
|
12068 |
|
|
+ //size = sizeR > size ? size : sizeR;
|
12069 |
|
|
+
|
12070 |
|
|
+ if (IS_OP_GLOBAL(result)) {
|
12071 |
|
|
+ for (i = 0; i < size; i++) {
|
12072 |
|
|
+ aopPutVal(ic, result, dialectNum(valueOffset(lit, i)), i);
|
12073 |
|
|
+ }
|
12074 |
|
|
+ }
|
12075 |
|
|
+
|
12076 |
|
|
+ else if (POINTER_SET(ic)) {
|
12077 |
|
|
+
|
12078 |
|
|
+ if(isInOutRef(result) ){
|
12079 |
|
|
+ aopPutVal(ic, result, dialectNum(valueOffset(lit, 0)), 0);
|
12080 |
|
|
+ return;
|
12081 |
|
|
+ }
|
12082 |
|
|
+
|
12083 |
|
|
+ for (i = 0; i < size; i++) {
|
12084 |
|
|
+ aopPutVal(ic, result, dialectNum(valueOffset(lit, size - i - 1)), i);
|
12085 |
|
|
+
|
12086 |
|
|
+ if (i + 1 < size) {
|
12087 |
|
|
+ pblaze_emitcode("ADD", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(1));
|
12088 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
12089 |
|
|
+ }
|
12090 |
|
|
+ }
|
12091 |
|
|
+ /* pointer will be used later, return to the begining */
|
12092 |
|
|
+ if (!pointerSetOpt(ic, size - 1) && size > 1 && OP_LIVETO(result) > ic->seq) {
|
12093 |
|
|
+ pblaze_emitcode("SUB", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(size - 1));
|
12094 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
12095 |
|
|
+ }
|
12096 |
|
|
+ } else {
|
12097 |
|
|
+ for (i = 0; i < size; i++) {
|
12098 |
|
|
+ aopPutVal(ic, result, dialectNum(valueOffset(lit, i)), i);
|
12099 |
|
|
+ }
|
12100 |
|
|
+ }
|
12101 |
|
|
+ }
|
12102 |
|
|
+
|
12103 |
|
|
+}
|
12104 |
|
|
+
|
12105 |
|
|
+
|
12106 |
|
|
+/*-----------------------------------------------------------------*/
|
12107 |
|
|
+/* assignLiteralRegs - */
|
12108 |
|
|
+/*-----------------------------------------------------------------*/
|
12109 |
|
|
+void assignLiteralRegs(int size, char **regs, operand * literal)
|
12110 |
|
|
+{
|
12111 |
|
|
+ unsigned long lit = 0L;
|
12112 |
|
|
+ int i;
|
12113 |
|
|
+
|
12114 |
|
|
+ /* is a literal value */
|
12115 |
|
|
+ if (isOperandLiteral(literal)) {
|
12116 |
|
|
+
|
12117 |
|
|
+ /* get value and size */
|
12118 |
|
|
+ lit = ulFromVal(OP_VALUE(literal));
|
12119 |
|
|
+
|
12120 |
|
|
+ for (i = size - 1; i >= 0; i--) {
|
12121 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", regs[i], dialectNum(valueOffset(lit, i)));
|
12122 |
|
|
+ }
|
12123 |
|
|
+ }
|
12124 |
|
|
+}
|
12125 |
|
|
+
|
12126 |
|
|
+
|
12127 |
|
|
+
|
12128 |
|
|
+/*-----------------------------------------------------------------*/
|
12129 |
|
|
+/* toBoolean - emit code for comparision */
|
12130 |
|
|
+/*-----------------------------------------------------------------*/
|
12131 |
|
|
+reg_info *toBoolean(iCode * ic, operand * oper)
|
12132 |
|
|
+{
|
12133 |
|
|
+ int size = getSize(operandType(oper));
|
12134 |
|
|
+ int offset = 1;
|
12135 |
|
|
+ reg_info *r;
|
12136 |
|
|
+
|
12137 |
|
|
+ if (size == 1) {
|
12138 |
|
|
+ return aopGetReg(ic, oper, 0);
|
12139 |
|
|
+ }
|
12140 |
|
|
+
|
12141 |
|
|
+ else {
|
12142 |
|
|
+ r = getReg(ic);
|
12143 |
|
|
+ lockReg(r);
|
12144 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", r->name, aopGetRegName(ic, oper, 0));
|
12145 |
|
|
+
|
12146 |
|
|
+ while (--size) {
|
12147 |
|
|
+ pblaze_emitcode("OR", "%s, %s", r->name, aopGetRegName(ic, oper, offset));
|
12148 |
|
|
+ offset++;
|
12149 |
|
|
+ }
|
12150 |
|
|
+ unlockReg(r);
|
12151 |
|
|
+ }
|
12152 |
|
|
+ return r;
|
12153 |
|
|
+}
|
12154 |
|
|
+
|
12155 |
|
|
+/*-----------------------------------------------------------------*/
|
12156 |
|
|
+/* genNot - generate code for ! operation */
|
12157 |
|
|
+/*-----------------------------------------------------------------*/
|
12158 |
|
|
+static void genNot(iCode * ic)
|
12159 |
|
|
+{
|
12160 |
|
|
+ operand *result, *left;
|
12161 |
|
|
+ reg_info *r;
|
12162 |
|
|
+ D(pblaze_emitcode(";", "genNot"));
|
12163 |
|
|
+
|
12164 |
|
|
+ symbol *lbl = newiTempLabel(NULL);
|
12165 |
|
|
+
|
12166 |
|
|
+ result = IC_RESULT(ic);
|
12167 |
|
|
+ left = IC_LEFT(ic);
|
12168 |
|
|
+
|
12169 |
|
|
+ /* fill the result with zeros */
|
12170 |
|
|
+ aopPutVal(ic, result, dialectNum(0), 0);
|
12171 |
|
|
+
|
12172 |
|
|
+ r = toBoolean(ic, left);
|
12173 |
|
|
+ pblaze_emitcodeCompare(r->name, dialectNum(0));
|
12174 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _LC%05d", LBL_KEY(lbl));
|
12175 |
|
|
+ aopPutVal(ic, result, dialectNum(1), 0);
|
12176 |
|
|
+ pblaze_emitLabelC(lbl);
|
12177 |
|
|
+}
|
12178 |
|
|
+
|
12179 |
|
|
+
|
12180 |
|
|
+
|
12181 |
|
|
+
|
12182 |
|
|
+/*-----------------------------------------------------------------*/
|
12183 |
|
|
+/* genCpl - generate code for complement */
|
12184 |
|
|
+/*-----------------------------------------------------------------*/
|
12185 |
|
|
+static void genCpl(iCode * ic)
|
12186 |
|
|
+{
|
12187 |
|
|
+ int offset = 0;
|
12188 |
|
|
+ int size;
|
12189 |
|
|
+ operand *result, *left;
|
12190 |
|
|
+
|
12191 |
|
|
+ D(pblaze_emitcode(";", "genCpl"));
|
12192 |
|
|
+
|
12193 |
|
|
+ result = IC_RESULT(ic);
|
12194 |
|
|
+ left = IC_LEFT(ic);
|
12195 |
|
|
+ size = getSize(operandType(result));
|
12196 |
|
|
+
|
12197 |
|
|
+ /* the right symbol may ends at this position */
|
12198 |
|
|
+ if (ASSIGN_OPT(result, left) && assignOptTest(ic, IC_RESULT(ic))) {
|
12199 |
|
|
+ assignOpt(ic, result, left);
|
12200 |
|
|
+ } else {
|
12201 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
12202 |
|
|
+ }
|
12203 |
|
|
+
|
12204 |
|
|
+ while (size--) {
|
12205 |
|
|
+ pblaze_emitcode("XOR", "%s, %s", aopGetRegName(ic, result, offset), dialectNum(255));
|
12206 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
12207 |
|
|
+ offset++;
|
12208 |
|
|
+ }
|
12209 |
|
|
+
|
12210 |
|
|
+}
|
12211 |
|
|
+
|
12212 |
|
|
+/*-----------------------------------------------------------------*/
|
12213 |
|
|
+/* genUminus - unary minus code generation */
|
12214 |
|
|
+/*-----------------------------------------------------------------*/
|
12215 |
|
|
+static void genUminus(iCode * ic)
|
12216 |
|
|
+{
|
12217 |
|
|
+ operand *result, *left;
|
12218 |
|
|
+ int i, size;
|
12219 |
|
|
+
|
12220 |
|
|
+ D(pblaze_emitcode(";", "genUminus"));
|
12221 |
|
|
+
|
12222 |
|
|
+ result = IC_RESULT(ic);
|
12223 |
|
|
+ left = IC_LEFT(ic);
|
12224 |
|
|
+ size = getSize(operandType(result));
|
12225 |
|
|
+
|
12226 |
|
|
+ /* right symbol may ends at this position */
|
12227 |
|
|
+ if (ASSIGN_OPT(result, left) && assignOptTest(ic, IC_RESULT(ic))) {
|
12228 |
|
|
+ assignOpt(ic, result, left);
|
12229 |
|
|
+ } else {
|
12230 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
12231 |
|
|
+ }
|
12232 |
|
|
+
|
12233 |
|
|
+ /* invert bytes */
|
12234 |
|
|
+ for (i = 0; i < size; i++) {
|
12235 |
|
|
+ pblaze_emitcode("XOR", "%s, %s", aopGetRegName(ic, result, i), dialectNum(255));
|
12236 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
12237 |
|
|
+ }
|
12238 |
|
|
+
|
12239 |
|
|
+ /* add one */
|
12240 |
|
|
+ pblaze_emitcode("ADD", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(1));
|
12241 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
12242 |
|
|
+ for (i = 1; i < size; i++) {
|
12243 |
|
|
+ pblaze_emitcodeADDCY(aopGetRegName(ic, result, i), dialectNum(0));
|
12244 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
12245 |
|
|
+ }
|
12246 |
|
|
+
|
12247 |
|
|
+}
|
12248 |
|
|
+
|
12249 |
|
|
+/*-----------------------------------------------------------------*/
|
12250 |
|
|
+/* genIpush - genrate code for pushing */
|
12251 |
|
|
+/*-----------------------------------------------------------------*/
|
12252 |
|
|
+static void genIpush(iCode * ic)
|
12253 |
|
|
+{
|
12254 |
|
|
+ operand *left;
|
12255 |
|
|
+ int offset, size;
|
12256 |
|
|
+ unsigned long lit = 0L;
|
12257 |
|
|
+ reg_info *r;
|
12258 |
|
|
+ offset = 0;
|
12259 |
|
|
+
|
12260 |
|
|
+ left = IC_LEFT(ic);
|
12261 |
|
|
+ size = getSize(operandType(left));
|
12262 |
|
|
+
|
12263 |
|
|
+ D(pblaze_emitcode(";", "genIpush"));
|
12264 |
|
|
+ if (isOperandLiteral(left)) {
|
12265 |
|
|
+
|
12266 |
|
|
+ /* get value */
|
12267 |
|
|
+ lit = ulFromVal(OP_VALUE(left));
|
12268 |
|
|
+ /* needs to be loaded into registers first -> get a free register */
|
12269 |
|
|
+ r = getReg(ic);
|
12270 |
|
|
+
|
12271 |
|
|
+ while (size--) {
|
12272 |
|
|
+ /* first load into registers */
|
12273 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", r->name, dialectNum((unsigned int) ((lit >> (offset++ * 8)) & 0x0FFL)));
|
12274 |
|
|
+ /* push onto the stack */
|
12275 |
|
|
+ pushStack(r->rIdx, 1);
|
12276 |
|
|
+ }
|
12277 |
|
|
+
|
12278 |
|
|
+ } else {
|
12279 |
|
|
+
|
12280 |
|
|
+ while (size--) {
|
12281 |
|
|
+ pushStack(aopGetReg(ic, left, offset)->rIdx, 1);
|
12282 |
|
|
+ offset++;
|
12283 |
|
|
+ }
|
12284 |
|
|
+ }
|
12285 |
|
|
+
|
12286 |
|
|
+}
|
12287 |
|
|
+
|
12288 |
|
|
+/*-----------------------------------------------------------------*/
|
12289 |
|
|
+/* genIpop - recover the registers */
|
12290 |
|
|
+/*-----------------------------------------------------------------*/
|
12291 |
|
|
+static void genIpop(iCode * ic)
|
12292 |
|
|
+{
|
12293 |
|
|
+ operand *left;
|
12294 |
|
|
+ int offset, size;
|
12295 |
|
|
+
|
12296 |
|
|
+ left = IC_LEFT(ic);
|
12297 |
|
|
+ size = getSize(operandType(left));
|
12298 |
|
|
+ offset = size - 1;
|
12299 |
|
|
+
|
12300 |
|
|
+ D(pblaze_emitcode(";", "genIpop"));
|
12301 |
|
|
+
|
12302 |
|
|
+ if (isOperandLiteral(left)) {
|
12303 |
|
|
+ return;
|
12304 |
|
|
+ }
|
12305 |
|
|
+
|
12306 |
|
|
+ while (size--) {
|
12307 |
|
|
+ popStack(aopGetReg(ic, left, offset)->rIdx, 1);
|
12308 |
|
|
+ offset--;
|
12309 |
|
|
+ }
|
12310 |
|
|
+}
|
12311 |
|
|
+
|
12312 |
|
|
+
|
12313 |
|
|
+/*-----------------------------------------------------------------*/
|
12314 |
|
|
+/* testFuncCall - check whether it should called the MUL or DIV func*/
|
12315 |
|
|
+/*-----------------------------------------------------------------*/
|
12316 |
|
|
+int testFuncCall(char *name)
|
12317 |
|
|
+{
|
12318 |
|
|
+ int start = S0_IDX;
|
12319 |
|
|
+
|
12320 |
|
|
+ /* test if it is a mult or div function call */
|
12321 |
|
|
+ if (strcmp(name, MULUSCHAR) == 0) {
|
12322 |
|
|
+ _GFunc.muschar = 1;
|
12323 |
|
|
+ start = SB_IDX;
|
12324 |
|
|
+ } else if (strcmp(name, MULSCHAR) == 0) {
|
12325 |
|
|
+ _GFunc.mschar = 1;
|
12326 |
|
|
+ _GFunc.muschar = 1;
|
12327 |
|
|
+ start = SA_IDX;
|
12328 |
|
|
+ } else if (strcmp(name, MULINT) == 0) {
|
12329 |
|
|
+ _GFunc.mint = 1;
|
12330 |
|
|
+ start = S7_IDX;
|
12331 |
|
|
+ } else if (strcmp(name, MULLONG) == 0) {
|
12332 |
|
|
+ _GFunc.mlong = 1;
|
12333 |
|
|
+ start = S2_IDX;
|
12334 |
|
|
+ } else if (strcmp(name, DIVSCHAR) == 0) {
|
12335 |
|
|
+ _GFunc.dschar = 1;
|
12336 |
|
|
+ _GFunc.duschar = 1;
|
12337 |
|
|
+ start = SA_IDX;
|
12338 |
|
|
+ } else if (strcmp(name, DIVUSCHAR) == 0) {
|
12339 |
|
|
+ _GFunc.duschar = 1;
|
12340 |
|
|
+ start = SB_IDX;
|
12341 |
|
|
+ } else if (strcmp(name, DIVSINT) == 0) {
|
12342 |
|
|
+ _GFunc.dsint = 1;
|
12343 |
|
|
+ _GFunc.dusint = 1;
|
12344 |
|
|
+ start = S7_IDX;
|
12345 |
|
|
+ } else if (strcmp(name, DIVUSINT) == 0) {
|
12346 |
|
|
+ _GFunc.dusint = 1;
|
12347 |
|
|
+ start = S7_IDX;
|
12348 |
|
|
+ } else if (strcmp(name, DIVSLONG) == 0) {
|
12349 |
|
|
+ _GFunc.dslong = 1;
|
12350 |
|
|
+ _GFunc.duslong = 1;
|
12351 |
|
|
+ start = S2_IDX;
|
12352 |
|
|
+ } else if (strcmp(name, DIVUSLONG) == 0) {
|
12353 |
|
|
+ _GFunc.duslong = 1;
|
12354 |
|
|
+ start = S2_IDX;
|
12355 |
|
|
+ } else if (strcmp(name, MODSCHAR) == 0) {
|
12356 |
|
|
+ _GFunc.modschar = 1;
|
12357 |
|
|
+ _GFunc.dschar = 1;
|
12358 |
|
|
+ _GFunc.duschar = 1;
|
12359 |
|
|
+ start = SA_IDX;
|
12360 |
|
|
+ } else if (strcmp(name, MODUSCHAR) == 0) {
|
12361 |
|
|
+ _GFunc.moduschar = 1;
|
12362 |
|
|
+ _GFunc.duschar = 1;
|
12363 |
|
|
+ start = SB_IDX;
|
12364 |
|
|
+ } else if (strcmp(name, "_moduschar") == 0) {
|
12365 |
|
|
+ _GFunc.moduschar = 1;
|
12366 |
|
|
+ _GFunc.duschar = 1;
|
12367 |
|
|
+ start = SB_IDX;
|
12368 |
|
|
+ } else if (strcmp(name, MODSINT) == 0) {
|
12369 |
|
|
+ _GFunc.modsint = 1;
|
12370 |
|
|
+ _GFunc.dsint = 1;
|
12371 |
|
|
+ _GFunc.dusint = 1;
|
12372 |
|
|
+ start = S7_IDX;
|
12373 |
|
|
+ } else if (strcmp(name, MODUSINT) == 0) {
|
12374 |
|
|
+ _GFunc.modusint = 1;
|
12375 |
|
|
+ _GFunc.dusint = 1;
|
12376 |
|
|
+ start = S7_IDX;
|
12377 |
|
|
+ } else if (strcmp(name, MODSLONG) == 0) {
|
12378 |
|
|
+ _GFunc.modslong = 1;
|
12379 |
|
|
+ _GFunc.dslong = 1;
|
12380 |
|
|
+ _GFunc.duslong = 1;
|
12381 |
|
|
+ start = S2_IDX;
|
12382 |
|
|
+ } else if (strcmp(name, MODUSLONG) == 0) {
|
12383 |
|
|
+ _GFunc.moduslong = 1;
|
12384 |
|
|
+ _GFunc.duslong = 1;
|
12385 |
|
|
+ start = S2_IDX;
|
12386 |
|
|
+ }
|
12387 |
|
|
+
|
12388 |
|
|
+ return start;
|
12389 |
|
|
+}
|
12390 |
|
|
+
|
12391 |
|
|
+/*-----------------------------------------------------------------*/
|
12392 |
|
|
+/* genCall - generates a call statement */
|
12393 |
|
|
+/*-----------------------------------------------------------------*/
|
12394 |
|
|
+static void genCall(iCode * ic)
|
12395 |
|
|
+{
|
12396 |
|
|
+ int i, j;
|
12397 |
|
|
+ int size;
|
12398 |
|
|
+ reg_info *r;
|
12399 |
|
|
+ operand *sOp;
|
12400 |
|
|
+ iCode *sic;
|
12401 |
|
|
+ int rmax = SEND_REG_COUNT;
|
12402 |
|
|
+ int rfrst = SEND_REG_FIRST;
|
12403 |
|
|
+ int saveFrom;
|
12404 |
|
|
+ bitVect *rSaved;
|
12405 |
|
|
+ unsigned long lit = 0L;
|
12406 |
|
|
+
|
12407 |
|
|
+ D(pblaze_emitcode(";", "genCall"));
|
12408 |
|
|
+
|
12409 |
|
|
+ /* store globals. if changed */
|
12410 |
|
|
+ freeGlobalsFromReg();
|
12411 |
|
|
+
|
12412 |
|
|
+ rSaved = newBitVect(pblaze_nRegs);
|
12413 |
|
|
+
|
12414 |
|
|
+ /* test if its a multiply, div or mod call */
|
12415 |
|
|
+ saveFrom = testFuncCall(OP_SYMBOL(IC_LEFT(ic))->name);
|
12416 |
|
|
+
|
12417 |
|
|
+ /* caller-saves, push used registers onto the stack */
|
12418 |
|
|
+ if (!_G.isCalleSaves && !IFFUNC_CALLEESAVES(OP_SYMBOL(IC_LEFT(ic))->type)) {
|
12419 |
|
|
+ for (i = S0_IDX; i <= SF_IDX; i++) {
|
12420 |
|
|
+ r = pblaze_regWithIdx(i);
|
12421 |
|
|
+ if (i >= saveFrom && r->isFree == 0 && r->isReserved == 0 && r->currOper
|
12422 |
|
|
+ && OP_LIVETO(r->currOper) > ic->seq) {
|
12423 |
|
|
+ pushStack(i, 1);
|
12424 |
|
|
+ // noted that the registers were moved to the stack
|
12425 |
|
|
+ bitVectSetBit(rSaved, i);
|
12426 |
|
|
+ } else if (i >= saveFrom && isOpVolatile(r->currOper) && !IS_OP_GLOBAL(r->currOper)) {
|
12427 |
|
|
+ pushStack(i, 1);
|
12428 |
|
|
+ bitVectSetBit(rSaved, i);
|
12429 |
|
|
+ } else
|
12430 |
|
|
+ bitVectUnSetBit(rSaved, i);
|
12431 |
|
|
+ }
|
12432 |
|
|
+ }
|
12433 |
|
|
+ /////////////////////////////////////////////////////
|
12434 |
|
|
+
|
12435 |
|
|
+ /* if send set is not empty then assign */
|
12436 |
|
|
+ if (_G.sendSet) {
|
12437 |
|
|
+ D(pblaze_emitcode(";", "genSend"));
|
12438 |
|
|
+ _G.sendSet = reverseSet(_G.sendSet);
|
12439 |
|
|
+ // through all
|
12440 |
|
|
+ for (sic = setFirstItem(_G.sendSet); sic; sic = setNextItem(_G.sendSet)) {
|
12441 |
|
|
+ sOp = IC_LEFT(sic);
|
12442 |
|
|
+ size = getSize(operandType(sOp));
|
12443 |
|
|
+
|
12444 |
|
|
+ // enough free registers for SEND
|
12445 |
|
|
+ if (size <= rmax) {
|
12446 |
|
|
+ rmax -= size;
|
12447 |
|
|
+
|
12448 |
|
|
+ /* send operand is value */
|
12449 |
|
|
+ if (isOperandLiteral(sOp)) {
|
12450 |
|
|
+ /* get value */
|
12451 |
|
|
+ lit = ulFromVal(OP_VALUE(sOp));
|
12452 |
|
|
+ /* needs to be loaded into registers first */
|
12453 |
|
|
+ for (j = 0; j < size; j++) {
|
12454 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", pblaze_regWithIdx(rfrst)->name,
|
12455 |
|
|
+ dialectNum((unsigned int) ((lit >> ((j) * 8)) & 0x0FFL)));
|
12456 |
|
|
+ rfrst++;
|
12457 |
|
|
+ }
|
12458 |
|
|
+ }
|
12459 |
|
|
+
|
12460 |
|
|
+ /* send operand is symbol */
|
12461 |
|
|
+ else {
|
12462 |
|
|
+
|
12463 |
|
|
+ for (i = 0; i < size; i++) {
|
12464 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", pblaze_regWithIdx(rfrst)->name, aopGetRegName(sic, sOp, i));
|
12465 |
|
|
+ rfrst++;
|
12466 |
|
|
+ }
|
12467 |
|
|
+ }
|
12468 |
|
|
+ /* not enought free registers -> use stack */
|
12469 |
|
|
+ } else {
|
12470 |
|
|
+ /* send operand is value */
|
12471 |
|
|
+ if (isOperandLiteral(sOp)) {
|
12472 |
|
|
+ reg_info *r;
|
12473 |
|
|
+
|
12474 |
|
|
+ /* get value */
|
12475 |
|
|
+ lit = ulFromVal(OP_VALUE(sOp));
|
12476 |
|
|
+ /* needs to be loaded into registers first -> get a free register */
|
12477 |
|
|
+ r = getReg(ic);
|
12478 |
|
|
+
|
12479 |
|
|
+ for (j = 0; j < size; j++) {
|
12480 |
|
|
+ /* first load into a register */
|
12481 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", r->name,
|
12482 |
|
|
+ dialectNum((unsigned int) ((lit >> (j * 8)) & 0x0FFL)));
|
12483 |
|
|
+ /* push onto the stack */
|
12484 |
|
|
+ pushStack(r->rIdx, 1);
|
12485 |
|
|
+ }
|
12486 |
|
|
+ }
|
12487 |
|
|
+ /* send operand is symbol */
|
12488 |
|
|
+ else {
|
12489 |
|
|
+
|
12490 |
|
|
+ for (i = 0; i < size; i++) {
|
12491 |
|
|
+ /* push onto the stack */
|
12492 |
|
|
+ if (aopGetReg(sic, sOp, i)) {
|
12493 |
|
|
+ pushStack(OP_SYMBOL(sOp)->regs[i]->rIdx, 1);;
|
12494 |
|
|
+ }
|
12495 |
|
|
+ }
|
12496 |
|
|
+
|
12497 |
|
|
+ }
|
12498 |
|
|
+ _G.onStack -= (size - 1);
|
12499 |
|
|
+
|
12500 |
|
|
+ }
|
12501 |
|
|
+ }
|
12502 |
|
|
+ _G.sendSet = NULL;
|
12503 |
|
|
+ }
|
12504 |
|
|
+ ///////////////////////////////////////////////////////////////////
|
12505 |
|
|
+
|
12506 |
|
|
+ /* make the call */
|
12507 |
|
|
+ pblaze_emitcode("CALL", "%s",
|
12508 |
|
|
+ (OP_SYMBOL(IC_LEFT(ic))->rname[0] ? OP_SYMBOL(IC_LEFT(ic))->rname : OP_SYMBOL(IC_LEFT(ic))->name));
|
12509 |
|
|
+
|
12510 |
|
|
+ /* test if it is a mult or div function call */
|
12511 |
|
|
+ if (strcmp(OP_SYMBOL(IC_LEFT(ic))->name, MULUSCHAR) == 0)
|
12512 |
|
|
+ _GFunc.muschar = 1;
|
12513 |
|
|
+ if (strcmp(OP_SYMBOL(IC_LEFT(ic))->name, MULSCHAR) == 0) {
|
12514 |
|
|
+ _GFunc.mschar = 1;
|
12515 |
|
|
+ _GFunc.muschar = 1;
|
12516 |
|
|
+ }
|
12517 |
|
|
+ if (strcmp(OP_SYMBOL(IC_LEFT(ic))->name, MULINT) == 0)
|
12518 |
|
|
+ _GFunc.mint = 1;
|
12519 |
|
|
+ if (strcmp(OP_SYMBOL(IC_LEFT(ic))->name, MULLONG) == 0)
|
12520 |
|
|
+ _GFunc.mlong = 1;
|
12521 |
|
|
+
|
12522 |
|
|
+ if (strcmp(OP_SYMBOL(IC_LEFT(ic))->name, DIVSCHAR) == 0) {
|
12523 |
|
|
+ _GFunc.dschar = 1;
|
12524 |
|
|
+ _GFunc.duschar = 1;
|
12525 |
|
|
+ }
|
12526 |
|
|
+ if (strcmp(OP_SYMBOL(IC_LEFT(ic))->name, DIVUSCHAR) == 0)
|
12527 |
|
|
+ _GFunc.duschar = 1;
|
12528 |
|
|
+ if (strcmp(OP_SYMBOL(IC_LEFT(ic))->name, MODSCHAR) == 0) {
|
12529 |
|
|
+ _GFunc.modschar = 1;
|
12530 |
|
|
+ _GFunc.dschar = 1;
|
12531 |
|
|
+ _GFunc.duschar = 1;
|
12532 |
|
|
+ }
|
12533 |
|
|
+ if (strcmp(OP_SYMBOL(IC_LEFT(ic))->name, MODUSCHAR) == 0) {
|
12534 |
|
|
+ _GFunc.moduschar = 1;
|
12535 |
|
|
+ _GFunc.duschar = 1;
|
12536 |
|
|
+ }
|
12537 |
|
|
+ if (strcmp(OP_SYMBOL(IC_LEFT(ic))->name, "_moduschar") == 0) {
|
12538 |
|
|
+ _GFunc.moduschar = 1;
|
12539 |
|
|
+ _GFunc.duschar = 1;
|
12540 |
|
|
+ }
|
12541 |
|
|
+
|
12542 |
|
|
+ /* pop used registers into the registers */
|
12543 |
|
|
+ if (!_G.isCalleSaves && !IFFUNC_CALLEESAVES(OP_SYMBOL(IC_LEFT(ic))->type)) {
|
12544 |
|
|
+ for (i = SF_IDX; i >= S0_IDX; i--) {
|
12545 |
|
|
+ r = pblaze_regWithIdx(i);
|
12546 |
|
|
+ if (bitVectBitValue(rSaved, i)) {
|
12547 |
|
|
+ popStack(i, 1);
|
12548 |
|
|
+ }
|
12549 |
|
|
+ }
|
12550 |
|
|
+ }
|
12551 |
|
|
+
|
12552 |
|
|
+ /* if we need assign a result value */
|
12553 |
|
|
+ if (IS_ITEMP(IC_RESULT(ic)) && OP_SYMBOL(IC_RESULT(ic))->liveTo > ic->seq) {
|
12554 |
|
|
+ pblaze_assignResultValue(ic, IC_RESULT(ic));
|
12555 |
|
|
+
|
12556 |
|
|
+ }
|
12557 |
|
|
+
|
12558 |
|
|
+}
|
12559 |
|
|
+
|
12560 |
|
|
+/*-----------------------------------------------------------------*/
|
12561 |
|
|
+/* genPcall - generates a call by pointer statement */
|
12562 |
|
|
+/*-----------------------------------------------------------------*/
|
12563 |
|
|
+static void genPcall(iCode * ic)
|
12564 |
|
|
+{
|
12565 |
|
|
+ /* not easy to implement without access to the Instruction pointer */
|
12566 |
|
|
+ fprintf(stderr, "%s:%d: pblaze port error: function pointers are not supported\n", __FILE__, __LINE__);
|
12567 |
|
|
+ exit(1);
|
12568 |
|
|
+}
|
12569 |
|
|
+
|
12570 |
|
|
+
|
12571 |
|
|
+/*-----------------------------------------------------------------*/
|
12572 |
|
|
+/* genFunction - generated code for function entry */
|
12573 |
|
|
+/*-----------------------------------------------------------------*/
|
12574 |
|
|
+static void genFunction(iCode * ic)
|
12575 |
|
|
+{
|
12576 |
|
|
+ symbol *sym;
|
12577 |
|
|
+ sym_link *ftype;
|
12578 |
|
|
+
|
12579 |
|
|
+ sym = OP_SYMBOL(IC_LEFT(ic));
|
12580 |
|
|
+
|
12581 |
|
|
+ /* create the function header */
|
12582 |
|
|
+ D(pblaze_emitcode(";", "-----------------------------------------"));
|
12583 |
|
|
+ D(pblaze_emitcode(";", " function %s", sym->name));
|
12584 |
|
|
+ D(pblaze_emitcode(";", "-----------------------------------------"));
|
12585 |
|
|
+
|
12586 |
|
|
+ pblaze_emitcode("", "%s:", sym->rname);
|
12587 |
|
|
+ lineCurr->isLabel = 1;
|
12588 |
|
|
+ ftype = operandType(IC_LEFT(ic));
|
12589 |
|
|
+
|
12590 |
|
|
+ if (IFFUNC_CALLEESAVES(sym->type)) {
|
12591 |
|
|
+ _G.isCalleSaves = 1;
|
12592 |
|
|
+ }
|
12593 |
|
|
+
|
12594 |
|
|
+ /* is an interrupt function */
|
12595 |
|
|
+ if (IFFUNC_ISISR(sym->type)) {
|
12596 |
|
|
+
|
12597 |
|
|
+ if (!pblaze_interrupt)
|
12598 |
|
|
+ pblaze_interrupt = sym;
|
12599 |
|
|
+ else if (FUNC_INTNO(sym->type) > FUNC_INTNO(pblaze_interrupt->type))
|
12600 |
|
|
+ pblaze_interrupt = sym;
|
12601 |
|
|
+
|
12602 |
|
|
+ _G.isCalleSaves = 1;
|
12603 |
|
|
+ }
|
12604 |
|
|
+
|
12605 |
|
|
+ /* if critical function then turn interrupts off */
|
12606 |
|
|
+ if (IFFUNC_ISCRITICAL(ftype)) {
|
12607 |
|
|
+ if (pblaze_options.dialect) {
|
12608 |
|
|
+ pblaze_emitcode("DISABLE INTERRUPT", "");
|
12609 |
|
|
+ } else {
|
12610 |
|
|
+ pblaze_emitcode("DINT", "");
|
12611 |
|
|
+ }
|
12612 |
|
|
+ }
|
12613 |
|
|
+}
|
12614 |
|
|
+
|
12615 |
|
|
+/*-----------------------------------------------------------------*/
|
12616 |
|
|
+/* genEndFunction - generates epilogue for functions */
|
12617 |
|
|
+/*-----------------------------------------------------------------*/
|
12618 |
|
|
+static void genEndFunction(iCode * ic)
|
12619 |
|
|
+{
|
12620 |
|
|
+ int i;
|
12621 |
|
|
+
|
12622 |
|
|
+ D(pblaze_emitcode(";", "genEndFunction"));
|
12623 |
|
|
+
|
12624 |
|
|
+ symbol *sym = OP_SYMBOL(IC_LEFT(ic));
|
12625 |
|
|
+
|
12626 |
|
|
+ _G.isCalleSaves = 0;
|
12627 |
|
|
+
|
12628 |
|
|
+ /* interrupt routine or callee saves - pop saved registers back */
|
12629 |
|
|
+ if (IFFUNC_ISISR(sym->type) || IFFUNC_CALLEESAVES(sym->type)) {
|
12630 |
|
|
+
|
12631 |
|
|
+ for (i = pblaze_nRegs - 1; i >= 0; i--) {
|
12632 |
|
|
+ if (bitVectBitValue(_G.rUsedVect, i))
|
12633 |
|
|
+ popStack(i, 0);
|
12634 |
|
|
+ }
|
12635 |
|
|
+ clearBitVect(_G.rUsedVect);
|
12636 |
|
|
+ }
|
12637 |
|
|
+
|
12638 |
|
|
+ /* store globals. if changed */
|
12639 |
|
|
+ freeGlobalsFromReg();
|
12640 |
|
|
+
|
12641 |
|
|
+ if (options.debug && currFunc) {
|
12642 |
|
|
+ debugFile->writeEndFunction(currFunc, ic, 1);
|
12643 |
|
|
+ }
|
12644 |
|
|
+
|
12645 |
|
|
+ if (pblaze_options.dialect) {
|
12646 |
|
|
+ if (IFFUNC_ISCRITICAL(sym->type))
|
12647 |
|
|
+ pblaze_emitcode("ENABLE INTERRUPT", "");
|
12648 |
|
|
+
|
12649 |
|
|
+ if (IFFUNC_ISISR(sym->type)) {
|
12650 |
|
|
+ pblaze_emitcode("RETURNI ENABLE", "");
|
12651 |
|
|
+ } else {
|
12652 |
|
|
+ pblaze_emitcode("RETURN", "");
|
12653 |
|
|
+ }
|
12654 |
|
|
+ } else {
|
12655 |
|
|
+ if (IFFUNC_ISCRITICAL(sym->type))
|
12656 |
|
|
+ pblaze_emitcode("EINT", "");
|
12657 |
|
|
+
|
12658 |
|
|
+ if (IFFUNC_ISISR(sym->type)) {
|
12659 |
|
|
+ pblaze_emitcode("RETI ENABLE", "");
|
12660 |
|
|
+ } else {
|
12661 |
|
|
+ pblaze_emitcode("RET", "");
|
12662 |
|
|
+ }
|
12663 |
|
|
+
|
12664 |
|
|
+ }
|
12665 |
|
|
+ // clear
|
12666 |
|
|
+ clearMemEndFunc();
|
12667 |
|
|
+}
|
12668 |
|
|
+
|
12669 |
|
|
+/*-----------------------------------------------------------------*/
|
12670 |
|
|
+/* genRet - generate code for return statement */
|
12671 |
|
|
+/*-----------------------------------------------------------------*/
|
12672 |
|
|
+static void genRet(iCode * ic)
|
12673 |
|
|
+{
|
12674 |
|
|
+ int size, i;
|
12675 |
|
|
+ operand *left;
|
12676 |
|
|
+ char *s;
|
12677 |
|
|
+
|
12678 |
|
|
+ D(pblaze_emitcode(";", "genRet"));
|
12679 |
|
|
+
|
12680 |
|
|
+ /* we have something to return then move the return value into place */
|
12681 |
|
|
+ if (IC_LEFT(ic)) {
|
12682 |
|
|
+ left = IC_LEFT(ic);
|
12683 |
|
|
+ size = getSize(operandType(left));
|
12684 |
|
|
+
|
12685 |
|
|
+ if (isOperandLiteral(left)) {
|
12686 |
|
|
+ assignLiteralRegs(size, fPBLAZEReturn, left);
|
12687 |
|
|
+ } else {
|
12688 |
|
|
+ for (i = size - 1; i >= 0; i--) {
|
12689 |
|
|
+ s = aopGetRegName(ic, left, i);
|
12690 |
|
|
+ if (strcmp(s, fPBLAZEReturn[i]) != 0)
|
12691 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", fPBLAZEReturn[i], s);
|
12692 |
|
|
+ }
|
12693 |
|
|
+ }
|
12694 |
|
|
+ }
|
12695 |
|
|
+
|
12696 |
|
|
+ /*
|
12697 |
|
|
+ if (!(ic->next && ic->next->op == LABEL &&
|
12698 |
|
|
+ IC_LABEL (ic->next) == returnLabel))
|
12699 |
|
|
+
|
12700 |
|
|
+ pblaze_emitcode ("JUMP", "_L%05d", LBL_KEY(returnLabel) );
|
12701 |
|
|
+ */
|
12702 |
|
|
+}
|
12703 |
|
|
+
|
12704 |
|
|
+/*-----------------------------------------------------------------*/
|
12705 |
|
|
+/* genLabel - generates a label */
|
12706 |
|
|
+/*-----------------------------------------------------------------*/
|
12707 |
|
|
+static void genLabel(iCode * ic)
|
12708 |
|
|
+{
|
12709 |
|
|
+ if (strcmp(IC_LABEL(ic)->name, entryLabel->name) == 0)
|
12710 |
|
|
+ return;
|
12711 |
|
|
+
|
12712 |
|
|
+ pblaze_emitLabel(IC_LABEL(ic));
|
12713 |
|
|
+}
|
12714 |
|
|
+
|
12715 |
|
|
+/*-----------------------------------------------------------------*/
|
12716 |
|
|
+/* genGoto - generates a jmp */
|
12717 |
|
|
+/*-----------------------------------------------------------------*/
|
12718 |
|
|
+static void genGoto(iCode * ic)
|
12719 |
|
|
+{
|
12720 |
|
|
+ D(pblaze_emitcode(";", "genGoto"));
|
12721 |
|
|
+ pblaze_emitcode("JUMP", "_L%05d", LBL_KEY(IC_LABEL(ic)));
|
12722 |
|
|
+}
|
12723 |
|
|
+
|
12724 |
|
|
+
|
12725 |
|
|
+/*-----------------------------------------------------------------*/
|
12726 |
|
|
+/* genPlus - generates code for addition */
|
12727 |
|
|
+/*-----------------------------------------------------------------*/
|
12728 |
|
|
+static void genPlus(iCode * ic)
|
12729 |
|
|
+{
|
12730 |
|
|
+ if (isInOutRef(IC_LEFT(ic))) {
|
12731 |
|
|
+ addInOutRef(IC_RESULT(ic), IC_RIGHT(ic));
|
12732 |
|
|
+ return;
|
12733 |
|
|
+ }
|
12734 |
|
|
+
|
12735 |
|
|
+ int size, sizeL;
|
12736 |
|
|
+ int i;
|
12737 |
|
|
+ bool swappedLR = FALSE, loadOpt = FALSE;
|
12738 |
|
|
+ unsigned long lit = 0L;
|
12739 |
|
|
+ operand *leftOp, *rightOp, *result;
|
12740 |
|
|
+ int optim = 0;
|
12741 |
|
|
+
|
12742 |
|
|
+ D(pblaze_emitcode(";", "genPlus"));
|
12743 |
|
|
+
|
12744 |
|
|
+ /* optimize assigment before adding */
|
12745 |
|
|
+ if (ic->next && ic->next->op == '=' && !isOperandLiteral(IC_LEFT(ic)) && OP_LIVETO(IC_RESULT(ic)) == ic->next->seq
|
12746 |
|
|
+ && pblaze_operandsEqu(IC_RESULT(ic), IC_RIGHT(ic->next))
|
12747 |
|
|
+ && pblaze_operandsEqu(IC_LEFT(ic), IC_RESULT(ic->next))) {
|
12748 |
|
|
+ IC_RESULT(ic) = IC_LEFT(ic);
|
12749 |
|
|
+ ic->next->generated = 1;
|
12750 |
|
|
+ optim = 1;
|
12751 |
|
|
+ } else if (ic->next && ic->next->op == '=' && !isOperandLiteral(IC_RIGHT(ic))
|
12752 |
|
|
+ && OP_LIVETO(IC_RESULT(ic)) == ic->next->seq && pblaze_operandsEqu(IC_RESULT(ic), IC_RIGHT(ic->next))
|
12753 |
|
|
+ && pblaze_operandsEqu(IC_RIGHT(ic), IC_RESULT(ic->next))) {
|
12754 |
|
|
+ operand *t = IC_RIGHT(ic);
|
12755 |
|
|
+ IC_RIGHT(ic) = IC_LEFT(ic);
|
12756 |
|
|
+ IC_LEFT(ic) = t;
|
12757 |
|
|
+ IC_RESULT(ic) = IC_LEFT(ic);
|
12758 |
|
|
+ ic->next->generated = 1;
|
12759 |
|
|
+ optim = 1;
|
12760 |
|
|
+ } else if (isOperandLiteral(IC_LEFT(ic)) || pblaze_operandsEqu(IC_RESULT(ic), IC_RIGHT(ic)) ||
|
12761 |
|
|
+ (IC_LEFT(ic)->type == SYMBOL && !isOpInReg(IC_LEFT(ic)) && IC_RIGHT(ic)->type == SYMBOL
|
12762 |
|
|
+ && isOpInReg(IC_RIGHT(ic))) || (IS_OP_GLOBAL(IC_LEFT(ic)) && !IS_OP_GLOBAL(IC_RIGHT(ic))
|
12763 |
|
|
+ && !isOperandLiteral(IC_RIGHT(ic)))) {
|
12764 |
|
|
+ operand *t = IC_RIGHT(ic);
|
12765 |
|
|
+ IC_RIGHT(ic) = IC_LEFT(ic);
|
12766 |
|
|
+ IC_LEFT(ic) = t;
|
12767 |
|
|
+ swappedLR = TRUE;
|
12768 |
|
|
+ }
|
12769 |
|
|
+
|
12770 |
|
|
+ result = IC_RESULT(ic);
|
12771 |
|
|
+ rightOp = IC_RIGHT(ic);
|
12772 |
|
|
+ leftOp = IC_LEFT(ic);
|
12773 |
|
|
+
|
12774 |
|
|
+
|
12775 |
|
|
+ /* left and result operands aren't the same */
|
12776 |
|
|
+ if (!pblaze_operandsEqu(IC_RESULT(ic), IC_LEFT(ic))) {
|
12777 |
|
|
+
|
12778 |
|
|
+ /* assign optimalization (left symbol may ends at this position) */
|
12779 |
|
|
+ if (ASSIGN_OPT(result, leftOp)) {
|
12780 |
|
|
+ assignOpt(ic, result, leftOp);
|
12781 |
|
|
+ loadOpt = TRUE;
|
12782 |
|
|
+ }
|
12783 |
|
|
+
|
12784 |
|
|
+ sizeL = getSize(operandType(leftOp));
|
12785 |
|
|
+ size = getSize(operandType(result));
|
12786 |
|
|
+
|
12787 |
|
|
+ if (!loadOpt) {
|
12788 |
|
|
+ copyRegisters(ic, result, leftOp, 0, size - 1);
|
12789 |
|
|
+ }
|
12790 |
|
|
+
|
12791 |
|
|
+ }
|
12792 |
|
|
+
|
12793 |
|
|
+ /* right operand is value */
|
12794 |
|
|
+ if (isOperandLiteral(rightOp)) {
|
12795 |
|
|
+
|
12796 |
|
|
+ /* get value and size */
|
12797 |
|
|
+ lit = ulFromVal(OP_VALUE(rightOp));
|
12798 |
|
|
+ size = getSize(operandType(result));
|
12799 |
|
|
+
|
12800 |
|
|
+ pblaze_emitcode("ADD", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(valueOffset(lit, 0)));
|
12801 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
12802 |
|
|
+ for (i = 1; i < size; i++) {
|
12803 |
|
|
+ pblaze_emitcodeADDCY(aopGetRegName(ic, result, i), dialectNum(valueOffset(lit, i)));
|
12804 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
12805 |
|
|
+ }
|
12806 |
|
|
+ }
|
12807 |
|
|
+
|
12808 |
|
|
+ /* right operand is symbol */
|
12809 |
|
|
+ else if (OP_SYMBOL(rightOp)) {
|
12810 |
|
|
+
|
12811 |
|
|
+ size = getSize(operandType(result));
|
12812 |
|
|
+ sizeL = getSize(operandType(rightOp));
|
12813 |
|
|
+
|
12814 |
|
|
+ pblaze_emitcode("ADD", "%s, %s", aopGetRegName(ic, result, 0), aopGetRegName(ic, rightOp, 0));
|
12815 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
12816 |
|
|
+ for (i = 1; i < size; i++) {
|
12817 |
|
|
+ if (i < sizeL) {
|
12818 |
|
|
+ pblaze_emitcodeADDCY(aopGetRegName(ic, result, i), aopGetRegName(ic, rightOp, i));
|
12819 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
12820 |
|
|
+ } else {
|
12821 |
|
|
+ pblaze_emitcodeADDCY(aopGetRegName(ic, result, i), dialectNum(0));
|
12822 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
12823 |
|
|
+ }
|
12824 |
|
|
+ }
|
12825 |
|
|
+
|
12826 |
|
|
+ }
|
12827 |
|
|
+ if (optim && IS_OP_GLOBAL(result))
|
12828 |
|
|
+ globalChanged(result, IN_REG);
|
12829 |
|
|
+
|
12830 |
|
|
+}
|
12831 |
|
|
+
|
12832 |
|
|
+/*-----------------------------------------------------------------*/
|
12833 |
|
|
+/* genMinus - generates code for subtraction */
|
12834 |
|
|
+/*-----------------------------------------------------------------*/
|
12835 |
|
|
+static void genMinus(iCode * ic)
|
12836 |
|
|
+{
|
12837 |
|
|
+ if (isInOutRef(IC_LEFT(ic))) {
|
12838 |
|
|
+ addInOutRef(IC_RESULT(ic), IC_RIGHT(ic));
|
12839 |
|
|
+ return;
|
12840 |
|
|
+ }
|
12841 |
|
|
+
|
12842 |
|
|
+ operand *leftOp, *rightOp, *result;
|
12843 |
|
|
+ int i, size, sizeR;
|
12844 |
|
|
+ unsigned long lit = 0L;
|
12845 |
|
|
+
|
12846 |
|
|
+ D(pblaze_emitcode(";", "genMinus"));
|
12847 |
|
|
+
|
12848 |
|
|
+ if (ic->next && ic->next->op == '=' && !isOperandLiteral(IC_LEFT(ic)) && OP_LIVETO(IC_RESULT(ic)) == ic->next->seq
|
12849 |
|
|
+ && pblaze_operandsEqu(IC_RESULT(ic), IC_RIGHT(ic->next))
|
12850 |
|
|
+ && pblaze_operandsEqu(IC_LEFT(ic), IC_RESULT(ic->next))) {
|
12851 |
|
|
+ IC_RESULT(ic) = IC_LEFT(ic);
|
12852 |
|
|
+ ic->next->generated = 1;
|
12853 |
|
|
+ }
|
12854 |
|
|
+
|
12855 |
|
|
+ result = IC_RESULT(ic);
|
12856 |
|
|
+ rightOp = IC_RIGHT(ic);
|
12857 |
|
|
+ leftOp = IC_LEFT(ic);
|
12858 |
|
|
+ size = getSize(operandType(result));
|
12859 |
|
|
+
|
12860 |
|
|
+ /* left and result operands aren't the same */
|
12861 |
|
|
+ if (!pblaze_operandsEqu(IC_RESULT(ic), IC_LEFT(ic))) {
|
12862 |
|
|
+ /* left operand is a literal */
|
12863 |
|
|
+ if (isOperandLiteral(leftOp)) {
|
12864 |
|
|
+ assignLiteral(result, leftOp, ic);
|
12865 |
|
|
+ }
|
12866 |
|
|
+
|
12867 |
|
|
+ /* assign optimalization (left symbol may ends at this position) */
|
12868 |
|
|
+ else if (ASSIGN_OPT(result, leftOp)) {
|
12869 |
|
|
+ assignOpt(ic, result, leftOp);
|
12870 |
|
|
+ }
|
12871 |
|
|
+ /* copy left operand into result operand */
|
12872 |
|
|
+ else {
|
12873 |
|
|
+ copyRegisters(ic, result, leftOp, 0, size - 1);
|
12874 |
|
|
+ }
|
12875 |
|
|
+ }
|
12876 |
|
|
+
|
12877 |
|
|
+ /* right operand is a value */
|
12878 |
|
|
+ if (isOperandLiteral(rightOp)) {
|
12879 |
|
|
+
|
12880 |
|
|
+ /* get value and size */
|
12881 |
|
|
+ lit = ulFromVal(OP_VALUE(rightOp));
|
12882 |
|
|
+ size = getSize(operandType(result));
|
12883 |
|
|
+
|
12884 |
|
|
+ pblaze_emitcode("SUB", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(valueOffset(lit, 0)));
|
12885 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
12886 |
|
|
+ for (i = 1; i < size; i++) {
|
12887 |
|
|
+ pblaze_emitcodeSUBCY(aopGetRegName(ic, result, i), dialectNum(valueOffset(lit, i)));
|
12888 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
12889 |
|
|
+ }
|
12890 |
|
|
+ }
|
12891 |
|
|
+
|
12892 |
|
|
+ /* right operand is a symbol */
|
12893 |
|
|
+ else if (OP_SYMBOL(rightOp)) {
|
12894 |
|
|
+
|
12895 |
|
|
+ size = getSize(operandType(result));
|
12896 |
|
|
+ sizeR = getSize(operandType(rightOp));
|
12897 |
|
|
+
|
12898 |
|
|
+ pblaze_emitcode("SUB", "%s, %s", aopGetRegName(ic, result, 0), aopGetRegName(ic, rightOp, 0));
|
12899 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
12900 |
|
|
+ for (i = 1; i < size; i++) {
|
12901 |
|
|
+ if (i < sizeR) {
|
12902 |
|
|
+ pblaze_emitcodeSUBCY(aopGetRegName(ic, result, i), aopGetRegName(ic, rightOp, i));
|
12903 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
12904 |
|
|
+ } else {
|
12905 |
|
|
+ pblaze_emitcodeSUBCY(aopGetRegName(ic, result, i), dialectNum(0));
|
12906 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
12907 |
|
|
+ }
|
12908 |
|
|
+ }
|
12909 |
|
|
+ }
|
12910 |
|
|
+}
|
12911 |
|
|
+
|
12912 |
|
|
+
|
12913 |
|
|
+/*-----------------------------------------------------------------*/
|
12914 |
|
|
+/* genMult - generates code for multiplication */
|
12915 |
|
|
+/*-----------------------------------------------------------------*/
|
12916 |
|
|
+static void genMult(iCode * ic)
|
12917 |
|
|
+{
|
12918 |
|
|
+ /* should have been converted to function call */
|
12919 |
|
|
+ assert(0);
|
12920 |
|
|
+}
|
12921 |
|
|
+
|
12922 |
|
|
+
|
12923 |
|
|
+
|
12924 |
|
|
+/*-----------------------------------------------------------------*/
|
12925 |
|
|
+/* genDiv - generates code for division */
|
12926 |
|
|
+/*-----------------------------------------------------------------*/
|
12927 |
|
|
+static void genDiv(iCode * ic)
|
12928 |
|
|
+{
|
12929 |
|
|
+ /* should have been converted to function call */
|
12930 |
|
|
+ assert(0);
|
12931 |
|
|
+}
|
12932 |
|
|
+
|
12933 |
|
|
+/*-----------------------------------------------------------------*/
|
12934 |
|
|
+/* genMod - generates code for division */
|
12935 |
|
|
+/*-----------------------------------------------------------------*/
|
12936 |
|
|
+static void genMod(iCode * ic)
|
12937 |
|
|
+{
|
12938 |
|
|
+ /* should have been converted to function call */
|
12939 |
|
|
+ assert(0);
|
12940 |
|
|
+
|
12941 |
|
|
+}
|
12942 |
|
|
+
|
12943 |
|
|
+
|
12944 |
|
|
+
|
12945 |
|
|
+/*-----------------------------------------------------------------*/
|
12946 |
|
|
+/* genMulDivFunc - generates function for multiply and division */
|
12947 |
|
|
+/*-----------------------------------------------------------------*/
|
12948 |
|
|
+void genMulDivFunc(FILE * of)
|
12949 |
|
|
+{
|
12950 |
|
|
+ if (_GFunc.mschar)
|
12951 |
|
|
+ genMultChar(of);
|
12952 |
|
|
+ if (_GFunc.muschar)
|
12953 |
|
|
+ genMultUnsignedChar(of);
|
12954 |
|
|
+ if (_GFunc.mint)
|
12955 |
|
|
+ genMultInt(of);
|
12956 |
|
|
+ if (_GFunc.mlong)
|
12957 |
|
|
+ genMultLong(of);
|
12958 |
|
|
+
|
12959 |
|
|
+ if (_GFunc.modschar)
|
12960 |
|
|
+ genModChar(of);
|
12961 |
|
|
+ if (_GFunc.moduschar)
|
12962 |
|
|
+ genModUnsignedChar(of);
|
12963 |
|
|
+ if (_GFunc.dschar)
|
12964 |
|
|
+ genDivChar(of);
|
12965 |
|
|
+ if (_GFunc.duschar)
|
12966 |
|
|
+ genDivUnsignedChar(of);
|
12967 |
|
|
+
|
12968 |
|
|
+ if (_GFunc.modsint)
|
12969 |
|
|
+ genModInt(of);
|
12970 |
|
|
+ if (_GFunc.modusint)
|
12971 |
|
|
+ genModUnsignedInt(of);
|
12972 |
|
|
+ if (_GFunc.dsint)
|
12973 |
|
|
+ genDivInt(of);
|
12974 |
|
|
+ if (_GFunc.dusint)
|
12975 |
|
|
+ genDivUnsignedInt(of);
|
12976 |
|
|
+
|
12977 |
|
|
+ if (_GFunc.modslong)
|
12978 |
|
|
+ genModLong(of);
|
12979 |
|
|
+ if (_GFunc.moduslong)
|
12980 |
|
|
+ genModUnsignedLong(of);
|
12981 |
|
|
+ if (_GFunc.dslong)
|
12982 |
|
|
+ genDivLong(of);
|
12983 |
|
|
+ if (_GFunc.duslong)
|
12984 |
|
|
+ genDivUnsignedLong(of);
|
12985 |
|
|
+}
|
12986 |
|
|
+
|
12987 |
|
|
+
|
12988 |
|
|
+/*-----------------------------------------------------------------*/
|
12989 |
|
|
+/* genCmp - compare left < right */
|
12990 |
|
|
+/*-----------------------------------------------------------------*/
|
12991 |
|
|
+static void genCmp(iCode * ic, operand * left, operand * right, operand * result, iCode * ifx)
|
12992 |
|
|
+{
|
12993 |
|
|
+ int size;
|
12994 |
|
|
+ unsigned long lit = 0L;
|
12995 |
|
|
+ value *aop_lit = NULL;
|
12996 |
|
|
+ symbol *lblo, *lble;
|
12997 |
|
|
+
|
12998 |
|
|
+ D(pblaze_emitcode(";", "genCompare"));
|
12999 |
|
|
+
|
13000 |
|
|
+ size = max(getSize(operandType(left)), getSize(operandType(right)));
|
13001 |
|
|
+
|
13002 |
|
|
+ /* next operation is IFX */
|
13003 |
|
|
+ if (ifx) {
|
13004 |
|
|
+ /* right operand is a literal value */
|
13005 |
|
|
+ if (isOperandLiteral(right)) {
|
13006 |
|
|
+ /* get value and size */
|
13007 |
|
|
+ lit = ulFromVal(OP_VALUE(right));
|
13008 |
|
|
+
|
13009 |
|
|
+ /* true label will be generated */
|
13010 |
|
|
+ if (IC_TRUE(ifx)) {
|
13011 |
|
|
+
|
13012 |
|
|
+ while (size--) {
|
13013 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, size), dialectNum(valueOffset(lit, size)));
|
13014 |
|
|
+ pblaze_emitcode("JUMP", "C, _L%05d", LBL_KEY(IC_TRUE(ifx)));
|
13015 |
|
|
+ }
|
13016 |
|
|
+ }
|
13017 |
|
|
+
|
13018 |
|
|
+ /* false label will be generated */
|
13019 |
|
|
+ else {
|
13020 |
|
|
+ lble = newiTempLabel(NULL);
|
13021 |
|
|
+
|
13022 |
|
|
+ while (size--) {
|
13023 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, size), dialectNum(valueOffset(lit, size)));
|
13024 |
|
|
+ pblaze_emitcode("JUMP", "C, _LC%05d", LBL_KEY(lble));
|
13025 |
|
|
+ }
|
13026 |
|
|
+
|
13027 |
|
|
+ pblaze_emitcode("JUMP", "_L%05d", LBL_KEY(IC_FALSE(ifx)));
|
13028 |
|
|
+ pblaze_emitLabelC(lble);
|
13029 |
|
|
+ }
|
13030 |
|
|
+ }
|
13031 |
|
|
+ /* left operand is a literal value */
|
13032 |
|
|
+ else if (isOperandLiteral(left)) {
|
13033 |
|
|
+ reg_info *reg;
|
13034 |
|
|
+ aop_lit = OP_VALUE(left);
|
13035 |
|
|
+ reg = getReg(ic);
|
13036 |
|
|
+ lockReg(reg);
|
13037 |
|
|
+ /* get value and size */
|
13038 |
|
|
+ lit = ulFromVal(aop_lit);
|
13039 |
|
|
+
|
13040 |
|
|
+ /* true label will be generated */
|
13041 |
|
|
+ if (IC_TRUE(ifx)) {
|
13042 |
|
|
+ while (size--) {
|
13043 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", reg->name, dialectNum(valueOffset(lit, size)));
|
13044 |
|
|
+ pblaze_emitcodeCompare(reg->name, aopGetRegName(ic, right, size));
|
13045 |
|
|
+ pblaze_emitcode("JUMP", "C, _L%05d", LBL_KEY(IC_TRUE(ifx)));
|
13046 |
|
|
+ }
|
13047 |
|
|
+ }
|
13048 |
|
|
+
|
13049 |
|
|
+ /* false label will be generated */
|
13050 |
|
|
+ else {
|
13051 |
|
|
+ lble = newiTempLabel(NULL);
|
13052 |
|
|
+
|
13053 |
|
|
+ while (size--) {
|
13054 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", reg->name, dialectNum(valueOffset(lit, size)));
|
13055 |
|
|
+ pblaze_emitcodeCompare(reg->name, aopGetRegName(ic, right, size));
|
13056 |
|
|
+ pblaze_emitcode("JUMP", "C, _LC%05d", LBL_KEY(lble));
|
13057 |
|
|
+ }
|
13058 |
|
|
+
|
13059 |
|
|
+ pblaze_emitcode("JUMP", "_L%05d", LBL_KEY(IC_FALSE(ifx)));
|
13060 |
|
|
+ pblaze_emitLabelC(lble);
|
13061 |
|
|
+ }
|
13062 |
|
|
+ unlockReg(reg);
|
13063 |
|
|
+ }
|
13064 |
|
|
+ /* both are in the registers */
|
13065 |
|
|
+ else {
|
13066 |
|
|
+ /* true label will be generated */
|
13067 |
|
|
+ if (IC_TRUE(ifx)) {
|
13068 |
|
|
+
|
13069 |
|
|
+ while (size--) {
|
13070 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, size), aopGetRegName(ic, right, size));
|
13071 |
|
|
+ pblaze_emitcode("JUMP", "C, _L%05d", LBL_KEY(IC_TRUE(ifx)));
|
13072 |
|
|
+ }
|
13073 |
|
|
+
|
13074 |
|
|
+ }
|
13075 |
|
|
+ /* false label will be generated */
|
13076 |
|
|
+ else {
|
13077 |
|
|
+ lble = newiTempLabel(NULL);
|
13078 |
|
|
+
|
13079 |
|
|
+ while (size--) {
|
13080 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, size), aopGetRegName(ic, right, size));
|
13081 |
|
|
+ pblaze_emitcode("JUMP", "C, _LC%05d", LBL_KEY(lble));
|
13082 |
|
|
+ }
|
13083 |
|
|
+
|
13084 |
|
|
+ pblaze_emitcode("JUMP", "_L%05d", LBL_KEY(IC_FALSE(ifx)));
|
13085 |
|
|
+ pblaze_emitLabelC(lble);
|
13086 |
|
|
+ }
|
13087 |
|
|
+ }
|
13088 |
|
|
+
|
13089 |
|
|
+ ifx->generated = 1;
|
13090 |
|
|
+
|
13091 |
|
|
+ }
|
13092 |
|
|
+ /* next instruction is not IFX */
|
13093 |
|
|
+ else {
|
13094 |
|
|
+
|
13095 |
|
|
+ aopPutVal(ic, result, dialectNum(0), 0);
|
13096 |
|
|
+
|
13097 |
|
|
+ if (size == 1) {
|
13098 |
|
|
+
|
13099 |
|
|
+ if (isOperandLiteral(right))
|
13100 |
|
|
+ aop_lit = OP_VALUE(right);
|
13101 |
|
|
+ if (isOperandLiteral(left))
|
13102 |
|
|
+ aop_lit = OP_VALUE(left);
|
13103 |
|
|
+
|
13104 |
|
|
+ lit = ulFromVal(aop_lit);
|
13105 |
|
|
+
|
13106 |
|
|
+ /* right side is a literal value */
|
13107 |
|
|
+ if (isOperandLiteral(right))
|
13108 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, 0), dialectNum(valueOffset(lit, 0)));
|
13109 |
|
|
+
|
13110 |
|
|
+ /* left side is a literal value */
|
13111 |
|
|
+ else if (isOperandLiteral(left)) {
|
13112 |
|
|
+ reg_info *reg;
|
13113 |
|
|
+ reg = getReg(ic);
|
13114 |
|
|
+ lockReg(reg);
|
13115 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", reg->name, dialectNum(valueOffset(lit, 0)));
|
13116 |
|
|
+ pblaze_emitcodeCompare(reg->name, aopGetRegName(ic, right, 0));
|
13117 |
|
|
+ unlockReg(reg);
|
13118 |
|
|
+ } else
|
13119 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, 0), aopGetRegName(ic, right, 0));
|
13120 |
|
|
+
|
13121 |
|
|
+ pblaze_emitcodeADDCY(aopGetRegName(ic, result, 0), dialectNum(0));
|
13122 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13123 |
|
|
+ } else {
|
13124 |
|
|
+ /* right side is a literal value */
|
13125 |
|
|
+ if (isOperandLiteral(right)) {
|
13126 |
|
|
+
|
13127 |
|
|
+ lblo = newiTempLabel(NULL);
|
13128 |
|
|
+ lble = newiTempLabel(NULL);
|
13129 |
|
|
+
|
13130 |
|
|
+ /* get value and size */
|
13131 |
|
|
+ lit = ulFromVal(OP_VALUE(right));
|
13132 |
|
|
+
|
13133 |
|
|
+ while (size--) {
|
13134 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, size), dialectNum(valueOffset(lit, size)));
|
13135 |
|
|
+ pblaze_emitcode("JUMP", "C, _LC%05d", LBL_KEY(lblo));
|
13136 |
|
|
+ }
|
13137 |
|
|
+
|
13138 |
|
|
+ pblaze_emitcode("JUMP", "_LC%05d", LBL_KEY(lble));
|
13139 |
|
|
+ pblaze_emitLabelC(lblo);
|
13140 |
|
|
+
|
13141 |
|
|
+ aopPutVal(ic, result, dialectNum(1), 0);
|
13142 |
|
|
+ pblaze_emitLabelC(lble);
|
13143 |
|
|
+ }
|
13144 |
|
|
+ /* left side is a literal value */
|
13145 |
|
|
+ else if (isOperandLiteral(left)) {
|
13146 |
|
|
+ reg_info *reg;
|
13147 |
|
|
+ lblo = newiTempLabel(NULL);
|
13148 |
|
|
+ lble = newiTempLabel(NULL);
|
13149 |
|
|
+ aop_lit = OP_VALUE(left);
|
13150 |
|
|
+ reg = getReg(ic);
|
13151 |
|
|
+ lockReg(reg);
|
13152 |
|
|
+ /* get value and size */
|
13153 |
|
|
+ lit = ulFromVal(aop_lit);
|
13154 |
|
|
+
|
13155 |
|
|
+ while (size--) {
|
13156 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", reg->name, dialectNum(valueOffset(lit, size)));
|
13157 |
|
|
+ pblaze_emitcodeCompare(reg->name, aopGetRegName(ic, right, size));
|
13158 |
|
|
+ pblaze_emitcode("JUMP", "C, _LC%05d", LBL_KEY(lblo));
|
13159 |
|
|
+ }
|
13160 |
|
|
+ unlockReg(reg);
|
13161 |
|
|
+
|
13162 |
|
|
+ pblaze_emitcode("JUMP", "_LC%05d", LBL_KEY(lble));
|
13163 |
|
|
+ pblaze_emitLabelC(lblo);
|
13164 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(1));
|
13165 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13166 |
|
|
+ pblaze_emitLabelC(lble);
|
13167 |
|
|
+
|
13168 |
|
|
+
|
13169 |
|
|
+ } else {
|
13170 |
|
|
+ lblo = newiTempLabel(NULL);
|
13171 |
|
|
+ lble = newiTempLabel(NULL);
|
13172 |
|
|
+
|
13173 |
|
|
+ while (size--) {
|
13174 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, size), aopGetRegName(ic, right, size));
|
13175 |
|
|
+ pblaze_emitcode("JUMP", "C, _LC%05d", LBL_KEY(lblo));
|
13176 |
|
|
+ }
|
13177 |
|
|
+
|
13178 |
|
|
+ pblaze_emitcode("JUMP", "_LC%05d", LBL_KEY(lble));
|
13179 |
|
|
+ pblaze_emitLabelC(lblo);
|
13180 |
|
|
+
|
13181 |
|
|
+ aopPutVal(ic, result, dialectNum(1), 0);
|
13182 |
|
|
+ pblaze_emitLabelC(lble);
|
13183 |
|
|
+
|
13184 |
|
|
+ }
|
13185 |
|
|
+ }
|
13186 |
|
|
+ }
|
13187 |
|
|
+}
|
13188 |
|
|
+
|
13189 |
|
|
+/*-----------------------------------------------------------------*/
|
13190 |
|
|
+/* genCmpGt :- greater than comparison */
|
13191 |
|
|
+/*-----------------------------------------------------------------*/
|
13192 |
|
|
+static void genCmpGt(iCode * ic, iCode * ifx)
|
13193 |
|
|
+{
|
13194 |
|
|
+ operand *left, *right, *result;
|
13195 |
|
|
+
|
13196 |
|
|
+ D(pblaze_emitcode(";", "genCmpGt"));
|
13197 |
|
|
+
|
13198 |
|
|
+ left = IC_LEFT(ic);
|
13199 |
|
|
+ right = IC_RIGHT(ic);
|
13200 |
|
|
+ result = IC_RESULT(ic);
|
13201 |
|
|
+
|
13202 |
|
|
+ genCmp(ic, right, left, result, ifx);
|
13203 |
|
|
+}
|
13204 |
|
|
+
|
13205 |
|
|
+/*-----------------------------------------------------------------*/
|
13206 |
|
|
+/* genCmpLt - less than comparisons */
|
13207 |
|
|
+/*-----------------------------------------------------------------*/
|
13208 |
|
|
+static void genCmpLt(iCode * ic, iCode * ifx)
|
13209 |
|
|
+{
|
13210 |
|
|
+ operand *left, *right, *result;
|
13211 |
|
|
+
|
13212 |
|
|
+ D(pblaze_emitcode(";", "genCmpLt"));
|
13213 |
|
|
+
|
13214 |
|
|
+ left = IC_LEFT(ic);
|
13215 |
|
|
+ right = IC_RIGHT(ic);
|
13216 |
|
|
+ result = IC_RESULT(ic);
|
13217 |
|
|
+
|
13218 |
|
|
+ genCmp(ic, left, right, result, ifx);
|
13219 |
|
|
+}
|
13220 |
|
|
+
|
13221 |
|
|
+/*-----------------------------------------------------------------*/
|
13222 |
|
|
+/* genCmpEq - generates code for equal to */
|
13223 |
|
|
+/*-----------------------------------------------------------------*/
|
13224 |
|
|
+static void genCmpEq(iCode * ic, iCode * ifx)
|
13225 |
|
|
+{
|
13226 |
|
|
+ operand *left, *right, *result;
|
13227 |
|
|
+ int size, sizeL, sizeR, offset = 0;
|
13228 |
|
|
+
|
13229 |
|
|
+ D(pblaze_emitcode(";", "genCmpEq"));
|
13230 |
|
|
+
|
13231 |
|
|
+
|
13232 |
|
|
+ if (isOperandLiteral(IC_LEFT(ic)) && !isOperandLiteral(IC_RIGHT(ic))) {
|
13233 |
|
|
+ operand *t = IC_RIGHT(ic);
|
13234 |
|
|
+ IC_RIGHT(ic) = IC_LEFT(ic);
|
13235 |
|
|
+ IC_LEFT(ic) = t;
|
13236 |
|
|
+ }
|
13237 |
|
|
+
|
13238 |
|
|
+ left = IC_LEFT(ic);
|
13239 |
|
|
+ right = IC_RIGHT(ic);
|
13240 |
|
|
+ result = IC_RESULT(ic);
|
13241 |
|
|
+
|
13242 |
|
|
+ sizeL = getSize(operandType(left));
|
13243 |
|
|
+ sizeR = getSize(operandType(right));
|
13244 |
|
|
+ size = max(sizeL, sizeR);
|
13245 |
|
|
+
|
13246 |
|
|
+ /* next operation is IFX */
|
13247 |
|
|
+ if (ifx) {
|
13248 |
|
|
+ /* true label exists */
|
13249 |
|
|
+ if (IC_TRUE(ifx)) {
|
13250 |
|
|
+
|
13251 |
|
|
+ symbol *lblfl = newiTempLabel(NULL);
|
13252 |
|
|
+ /* right operand is a literal */
|
13253 |
|
|
+ if (isOperandLiteral(right)) {
|
13254 |
|
|
+ unsigned long lit = ulFromVal(OP_VALUE(right));
|
13255 |
|
|
+
|
13256 |
|
|
+ while (size--) {
|
13257 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, offset), dialectNum(valueOffset(lit, offset)));
|
13258 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _LC%05d", LBL_KEY(lblfl));
|
13259 |
|
|
+ offset++;
|
13260 |
|
|
+ }
|
13261 |
|
|
+
|
13262 |
|
|
+ pblaze_emitcode("JUMP", "_L%05d", LBL_KEY(IC_TRUE(ifx)));
|
13263 |
|
|
+
|
13264 |
|
|
+ pblaze_emitLabelC(lblfl);
|
13265 |
|
|
+ }
|
13266 |
|
|
+
|
13267 |
|
|
+ /* right operand is in the registers */
|
13268 |
|
|
+ else {
|
13269 |
|
|
+ while (size--) {
|
13270 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, offset), aopGetRegName(ic, right, offset));
|
13271 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _LC%05d", LBL_KEY(lblfl));
|
13272 |
|
|
+ offset++;
|
13273 |
|
|
+ }
|
13274 |
|
|
+
|
13275 |
|
|
+ pblaze_emitcode("JUMP", "_L%05d", LBL_KEY(IC_TRUE(ifx)));
|
13276 |
|
|
+
|
13277 |
|
|
+ pblaze_emitLabelC(lblfl);
|
13278 |
|
|
+ }
|
13279 |
|
|
+ }
|
13280 |
|
|
+
|
13281 |
|
|
+ /* false label exists */
|
13282 |
|
|
+ else {
|
13283 |
|
|
+ /* right operand is a literal */
|
13284 |
|
|
+ if (isOperandLiteral(right)) {
|
13285 |
|
|
+ unsigned long lit = ulFromVal(OP_VALUE(right));
|
13286 |
|
|
+
|
13287 |
|
|
+ while (size--) {
|
13288 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, offset), dialectNum(valueOffset(lit, offset)));
|
13289 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _L%05d", LBL_KEY(IC_FALSE(ifx)));
|
13290 |
|
|
+ offset++;
|
13291 |
|
|
+ }
|
13292 |
|
|
+ }
|
13293 |
|
|
+
|
13294 |
|
|
+ /* right operand is in the registers */
|
13295 |
|
|
+ else {
|
13296 |
|
|
+
|
13297 |
|
|
+ while (size--) {
|
13298 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, offset), aopGetRegName(ic, right, offset));
|
13299 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _L%05d", LBL_KEY(IC_FALSE(ifx)));
|
13300 |
|
|
+ offset++;
|
13301 |
|
|
+ }
|
13302 |
|
|
+ }
|
13303 |
|
|
+ }
|
13304 |
|
|
+ ifx->generated = 1;
|
13305 |
|
|
+ }
|
13306 |
|
|
+
|
13307 |
|
|
+ /* next operation is not IFX */
|
13308 |
|
|
+ else {
|
13309 |
|
|
+ symbol *lblfl = newiTempLabel(NULL);
|
13310 |
|
|
+
|
13311 |
|
|
+ /* right operand is a literal */
|
13312 |
|
|
+ if (isOperandLiteral(right)) {
|
13313 |
|
|
+ unsigned long lit = ulFromVal(OP_VALUE(right));
|
13314 |
|
|
+
|
13315 |
|
|
+ aopPutVal(ic, result, dialectNum(0), 0);
|
13316 |
|
|
+
|
13317 |
|
|
+ while (size--) {
|
13318 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, offset), dialectNum(valueOffset(lit, offset)));
|
13319 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _LC%05d", LBL_KEY(lblfl));
|
13320 |
|
|
+ offset++;
|
13321 |
|
|
+ }
|
13322 |
|
|
+
|
13323 |
|
|
+ aopPutVal(ic, result, dialectNum(1), 0);
|
13324 |
|
|
+ pblaze_emitLabelC(lblfl);
|
13325 |
|
|
+ }
|
13326 |
|
|
+
|
13327 |
|
|
+ /* right operand is in the registers */
|
13328 |
|
|
+ else {
|
13329 |
|
|
+ aopPutVal(ic, result, dialectNum(0), 0);
|
13330 |
|
|
+
|
13331 |
|
|
+ while (size--) {
|
13332 |
|
|
+ pblaze_emitcodeCompare(aopGetRegName(ic, left, offset), aopGetRegName(ic, right, offset));
|
13333 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _LC%05d", LBL_KEY(lblfl));
|
13334 |
|
|
+ offset++;
|
13335 |
|
|
+ }
|
13336 |
|
|
+
|
13337 |
|
|
+ aopPutVal(ic, result, dialectNum(1), 0);
|
13338 |
|
|
+ pblaze_emitLabelC(lblfl);
|
13339 |
|
|
+ }
|
13340 |
|
|
+ }
|
13341 |
|
|
+}
|
13342 |
|
|
+
|
13343 |
|
|
+/*-----------------------------------------------------------------*/
|
13344 |
|
|
+/* ifxForOp - returns the icode containing the ifx for operand */
|
13345 |
|
|
+/*-----------------------------------------------------------------*/
|
13346 |
|
|
+static iCode *ifxForOp(operand * op, iCode * ic)
|
13347 |
|
|
+{
|
13348 |
|
|
+ /* if true symbol then needs to be assigned */
|
13349 |
|
|
+ if (IS_TRUE_SYMOP(op))
|
13350 |
|
|
+ return NULL;
|
13351 |
|
|
+
|
13352 |
|
|
+ /* if this has register type condition and
|
13353 |
|
|
+ the next instruction is ifx with the same operand
|
13354 |
|
|
+ and live to of the operand is upto the ifx only then */
|
13355 |
|
|
+ if (ic->next && ic->next->op == IFX && IC_COND(ic->next)->key == op->key && OP_SYMBOL(op)->liveTo <= ic->next->seq)
|
13356 |
|
|
+ return ic->next;
|
13357 |
|
|
+
|
13358 |
|
|
+ return NULL;
|
13359 |
|
|
+}
|
13360 |
|
|
+
|
13361 |
|
|
+/*-----------------------------------------------------------------*/
|
13362 |
|
|
+/* genAndOp - for && operation */
|
13363 |
|
|
+/*-----------------------------------------------------------------*/
|
13364 |
|
|
+static void genAndOp(iCode * ic)
|
13365 |
|
|
+{
|
13366 |
|
|
+ operand *left, *right, *result;
|
13367 |
|
|
+ symbol *tlbl;
|
13368 |
|
|
+ reg_info *r;
|
13369 |
|
|
+
|
13370 |
|
|
+ D(pblaze_emitcode(";", "genAnd"));
|
13371 |
|
|
+
|
13372 |
|
|
+ left = IC_LEFT(ic);
|
13373 |
|
|
+ right = IC_RIGHT(ic);
|
13374 |
|
|
+ result = IC_RESULT(ic);
|
13375 |
|
|
+
|
13376 |
|
|
+ tlbl = newiTempLabel(NULL);
|
13377 |
|
|
+
|
13378 |
|
|
+ /* only for size == 0 */
|
13379 |
|
|
+ aopPutVal(ic, result, dialectNum(0), 0);
|
13380 |
|
|
+
|
13381 |
|
|
+ r = toBoolean(ic, left);
|
13382 |
|
|
+ pblaze_emitcodeCompare(r->name, dialectNum(0));
|
13383 |
|
|
+ pblaze_emitcode("JUMP", "Z, _LC%05d", LBL_KEY(tlbl));
|
13384 |
|
|
+
|
13385 |
|
|
+ r = toBoolean(ic, right);
|
13386 |
|
|
+ pblaze_emitcodeCompare(r->name, dialectNum(0));
|
13387 |
|
|
+ pblaze_emitcode("JUMP", "Z, _LC%05d", LBL_KEY(tlbl));
|
13388 |
|
|
+
|
13389 |
|
|
+ aopPutVal(ic, result, dialectNum(1), 0);
|
13390 |
|
|
+ pblaze_emitLabelC(tlbl);
|
13391 |
|
|
+
|
13392 |
|
|
+}
|
13393 |
|
|
+
|
13394 |
|
|
+/*-----------------------------------------------------------------*/
|
13395 |
|
|
+/* genOrOp - for || operation */
|
13396 |
|
|
+/*-----------------------------------------------------------------*/
|
13397 |
|
|
+static void genOrOp(iCode * ic)
|
13398 |
|
|
+{
|
13399 |
|
|
+ operand *left, *right, *result;
|
13400 |
|
|
+ symbol *tlbl;
|
13401 |
|
|
+ reg_info *r;
|
13402 |
|
|
+
|
13403 |
|
|
+ D(pblaze_emitcode(";", "genOrOp"));
|
13404 |
|
|
+
|
13405 |
|
|
+ left = IC_LEFT(ic);
|
13406 |
|
|
+ right = IC_RIGHT(ic);
|
13407 |
|
|
+ result = IC_RESULT(ic);
|
13408 |
|
|
+ /* only size == 0 */
|
13409 |
|
|
+
|
13410 |
|
|
+ tlbl = newiTempLabel(NULL);
|
13411 |
|
|
+
|
13412 |
|
|
+ pblaze_emitcode("XOR", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(1));
|
13413 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13414 |
|
|
+
|
13415 |
|
|
+ r = toBoolean(ic, left);
|
13416 |
|
|
+ pblaze_emitcodeCompare(r->name, dialectNum(0));
|
13417 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _LC%05d", LBL_KEY(tlbl));
|
13418 |
|
|
+ r = toBoolean(ic, right);
|
13419 |
|
|
+ pblaze_emitcodeCompare(r->name, dialectNum(0));
|
13420 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _LC%05d", LBL_KEY(tlbl));
|
13421 |
|
|
+
|
13422 |
|
|
+ aopPutVal(ic, result, dialectNum(0), 0);
|
13423 |
|
|
+ pblaze_emitLabelC(tlbl);
|
13424 |
|
|
+}
|
13425 |
|
|
+
|
13426 |
|
|
+enum {
|
13427 |
|
|
+ PBLAZE_AND = 0, PBLAZE_OR, PBLAZE_XOR
|
13428 |
|
|
+};
|
13429 |
|
|
+
|
13430 |
|
|
+/*-----------------------------------------------------------------*/
|
13431 |
|
|
+/* genBitWise - generate bitwise operations */
|
13432 |
|
|
+/*-----------------------------------------------------------------*/
|
13433 |
|
|
+static void genBitWise(iCode * ic, iCode * ifx, int bitop)
|
13434 |
|
|
+{
|
13435 |
|
|
+ operand *left, *right, *result;
|
13436 |
|
|
+ int size, sizeL, sizeR, offset = 0;
|
13437 |
|
|
+
|
13438 |
|
|
+ D(pblaze_emitcode(";", "genBitWise"));
|
13439 |
|
|
+
|
13440 |
|
|
+
|
13441 |
|
|
+ if ((isOperandLiteral(IC_LEFT(ic)) && !isOperandLiteral(IC_RIGHT(ic))) ||
|
13442 |
|
|
+ (!isOperandLiteral(IC_RIGHT(ic)) && OP_LIVETO(IC_LEFT(ic)) > ic->seq && OP_LIVETO(IC_RIGHT(ic)) == ic->seq)) {
|
13443 |
|
|
+ operand *t = IC_RIGHT(ic);
|
13444 |
|
|
+ IC_RIGHT(ic) = IC_LEFT(ic);
|
13445 |
|
|
+ IC_LEFT(ic) = t;
|
13446 |
|
|
+ }
|
13447 |
|
|
+
|
13448 |
|
|
+ left = IC_LEFT(ic);
|
13449 |
|
|
+ right = IC_RIGHT(ic);
|
13450 |
|
|
+ result = IC_RESULT(ic);
|
13451 |
|
|
+
|
13452 |
|
|
+ sizeL = getSize(operandType(left));
|
13453 |
|
|
+ sizeR = getSize(operandType(right));
|
13454 |
|
|
+ size = max(sizeL, sizeR);
|
13455 |
|
|
+
|
13456 |
|
|
+
|
13457 |
|
|
+ /* right symbol may ends at this position */
|
13458 |
|
|
+ if (ASSIGN_OPT(result, left) && assignOptTest(ic, IC_RESULT(ic))) {
|
13459 |
|
|
+ assignOpt(ic, result, left);
|
13460 |
|
|
+ } else {
|
13461 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
13462 |
|
|
+ }
|
13463 |
|
|
+
|
13464 |
|
|
+ /* right operand is a literal value */
|
13465 |
|
|
+ if (isOperandLiteral(right)) {
|
13466 |
|
|
+ unsigned long lit = ulFromVal(OP_VALUE(right));
|
13467 |
|
|
+
|
13468 |
|
|
+ while (size--) {
|
13469 |
|
|
+ if (bitop == PBLAZE_AND) {
|
13470 |
|
|
+ pblaze_emitcode("AND", "%s, %s", aopGetRegName(ic, result, offset),
|
13471 |
|
|
+ dialectNum(valueOffset(lit, offset)));
|
13472 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
13473 |
|
|
+ }
|
13474 |
|
|
+
|
13475 |
|
|
+ else if (bitop == PBLAZE_OR) {
|
13476 |
|
|
+ pblaze_emitcode("OR", "%s, %s", aopGetRegName(ic, result, offset),
|
13477 |
|
|
+ dialectNum(valueOffset(lit, offset)));
|
13478 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
13479 |
|
|
+ } else if (bitop == PBLAZE_XOR) {
|
13480 |
|
|
+ pblaze_emitcode("XOR", "%s, %s", aopGetRegName(ic, result, offset),
|
13481 |
|
|
+ dialectNum(valueOffset(lit, offset)));
|
13482 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
13483 |
|
|
+ }
|
13484 |
|
|
+ offset++;
|
13485 |
|
|
+ }
|
13486 |
|
|
+ }
|
13487 |
|
|
+
|
13488 |
|
|
+ else {
|
13489 |
|
|
+ while (size--) {
|
13490 |
|
|
+ if (bitop == PBLAZE_AND) {
|
13491 |
|
|
+ pblaze_emitcode("AND", "%s, %s", aopGetRegName(ic, result, offset), aopGetRegName(ic, right, offset));
|
13492 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
13493 |
|
|
+ } else if (bitop == PBLAZE_OR) {
|
13494 |
|
|
+ pblaze_emitcode("OR", "%s, %s", aopGetRegName(ic, result, offset), aopGetRegName(ic, right, offset));
|
13495 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
13496 |
|
|
+ } else if (bitop == PBLAZE_XOR) {
|
13497 |
|
|
+ pblaze_emitcode("XOR", "%s, %s", aopGetRegName(ic, result, offset), aopGetRegName(ic, right, offset));
|
13498 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
13499 |
|
|
+ }
|
13500 |
|
|
+ offset++;
|
13501 |
|
|
+ }
|
13502 |
|
|
+ }
|
13503 |
|
|
+}
|
13504 |
|
|
+
|
13505 |
|
|
+/*-----------------------------------------------------------------*/
|
13506 |
|
|
+/* genAnd - code for and */
|
13507 |
|
|
+/*-----------------------------------------------------------------*/
|
13508 |
|
|
+static void genAnd(iCode * ic, iCode * ifx)
|
13509 |
|
|
+{
|
13510 |
|
|
+ D(pblaze_emitcode(";", "genAND"));
|
13511 |
|
|
+
|
13512 |
|
|
+ genBitWise(ic, ifx, PBLAZE_AND);
|
13513 |
|
|
+}
|
13514 |
|
|
+
|
13515 |
|
|
+/*-----------------------------------------------------------------*/
|
13516 |
|
|
+/* genOr - code for or */
|
13517 |
|
|
+/*-----------------------------------------------------------------*/
|
13518 |
|
|
+static void genOr(iCode * ic, iCode * ifx)
|
13519 |
|
|
+{
|
13520 |
|
|
+ D(pblaze_emitcode(";", "genOR"));
|
13521 |
|
|
+
|
13522 |
|
|
+ genBitWise(ic, ifx, PBLAZE_OR);
|
13523 |
|
|
+}
|
13524 |
|
|
+
|
13525 |
|
|
+/*-----------------------------------------------------------------*/
|
13526 |
|
|
+/* genXor - code for xclusive or */
|
13527 |
|
|
+/*-----------------------------------------------------------------*/
|
13528 |
|
|
+static void genXor(iCode * ic, iCode * ifx)
|
13529 |
|
|
+{
|
13530 |
|
|
+ D(pblaze_emitcode(";", "genXOR"));
|
13531 |
|
|
+
|
13532 |
|
|
+ genBitWise(ic, ifx, PBLAZE_XOR);
|
13533 |
|
|
+}
|
13534 |
|
|
+
|
13535 |
|
|
+/*-----------------------------------------------------------------*/
|
13536 |
|
|
+/* genInline - write the inline code out */
|
13537 |
|
|
+/*-----------------------------------------------------------------*/
|
13538 |
|
|
+static void genInline(iCode * ic)
|
13539 |
|
|
+{
|
13540 |
|
|
+ char *buffer, *bp, *bp1;
|
13541 |
|
|
+ bool inComment = FALSE;
|
13542 |
|
|
+
|
13543 |
|
|
+ D(pblaze_emitcode(";", "genInline"));
|
13544 |
|
|
+
|
13545 |
|
|
+ _G.inLine += (!options.asmpeep);
|
13546 |
|
|
+
|
13547 |
|
|
+ buffer = bp = bp1 = Safe_strdup(IC_INLINE(ic));
|
13548 |
|
|
+
|
13549 |
|
|
+ /* emit each line as a code */
|
13550 |
|
|
+ while (*bp) {
|
13551 |
|
|
+ switch (*bp) {
|
13552 |
|
|
+ case ';':
|
13553 |
|
|
+ inComment = TRUE;
|
13554 |
|
|
+ ++bp;
|
13555 |
|
|
+ break;
|
13556 |
|
|
+
|
13557 |
|
|
+ case '\n':
|
13558 |
|
|
+ inComment = FALSE;
|
13559 |
|
|
+ *bp++ = '\0';
|
13560 |
|
|
+ pblaze_emitcode(bp1, "");
|
13561 |
|
|
+ bp1 = bp;
|
13562 |
|
|
+ break;
|
13563 |
|
|
+
|
13564 |
|
|
+ default:
|
13565 |
|
|
+ if (!inComment && (*bp == ':') && (isspace((unsigned char) bp[1]))) {
|
13566 |
|
|
+ ++bp;
|
13567 |
|
|
+ *bp = '\0';
|
13568 |
|
|
+ ++bp;
|
13569 |
|
|
+ pblaze_emitcode(bp1, "");
|
13570 |
|
|
+ bp1 = bp;
|
13571 |
|
|
+ } else
|
13572 |
|
|
+ ++bp;
|
13573 |
|
|
+ break;
|
13574 |
|
|
+ }
|
13575 |
|
|
+ }
|
13576 |
|
|
+ if (bp1 != bp)
|
13577 |
|
|
+ pblaze_emitcode(bp1, "");
|
13578 |
|
|
+
|
13579 |
|
|
+ Safe_free(buffer);
|
13580 |
|
|
+
|
13581 |
|
|
+ _G.inLine -= (!options.asmpeep);
|
13582 |
|
|
+}
|
13583 |
|
|
+
|
13584 |
|
|
+/*-----------------------------------------------------------------*/
|
13585 |
|
|
+/* genRRC - rotate right with carry */
|
13586 |
|
|
+/*-----------------------------------------------------------------*/
|
13587 |
|
|
+static void genRRC(iCode * ic)
|
13588 |
|
|
+{
|
13589 |
|
|
+ int offset = 0;
|
13590 |
|
|
+ int size;
|
13591 |
|
|
+ operand *result, *left;
|
13592 |
|
|
+
|
13593 |
|
|
+ D(pblaze_emitcode(";", "genRRC"));
|
13594 |
|
|
+
|
13595 |
|
|
+ result = IC_RESULT(ic);
|
13596 |
|
|
+ left = IC_LEFT(ic);
|
13597 |
|
|
+ size = getSize(operandType(result));
|
13598 |
|
|
+
|
13599 |
|
|
+ /* left and result operands aren't the same */
|
13600 |
|
|
+ if (!pblaze_operandsEqu(IC_RESULT(ic), IC_LEFT(ic))) {
|
13601 |
|
|
+ /* assign optimalization (left symbol may ends at this position) */
|
13602 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
13603 |
|
|
+ assignOpt(ic, result, left);
|
13604 |
|
|
+ }
|
13605 |
|
|
+ /* assign left operand into result operand */
|
13606 |
|
|
+ else {
|
13607 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
13608 |
|
|
+ }
|
13609 |
|
|
+ }
|
13610 |
|
|
+
|
13611 |
|
|
+ if (size == 1) {
|
13612 |
|
|
+ pblaze_emitcode("RR", "%s", aopGetRegName(ic, result, 0));
|
13613 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13614 |
|
|
+ } else {
|
13615 |
|
|
+ pblaze_emitcode("TEST", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(1));
|
13616 |
|
|
+
|
13617 |
|
|
+ while (size--) {
|
13618 |
|
|
+ pblaze_emitcode("SRA", "%s", aopGetRegName(ic, result, offset));
|
13619 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
13620 |
|
|
+ offset++;
|
13621 |
|
|
+ }
|
13622 |
|
|
+
|
13623 |
|
|
+ }
|
13624 |
|
|
+}
|
13625 |
|
|
+
|
13626 |
|
|
+/*-----------------------------------------------------------------*/
|
13627 |
|
|
+/* genRLC - generate code for rotate left with carry */
|
13628 |
|
|
+/*-----------------------------------------------------------------*/
|
13629 |
|
|
+static void genRLC(iCode * ic)
|
13630 |
|
|
+{
|
13631 |
|
|
+ int offset = 0;
|
13632 |
|
|
+ int size;
|
13633 |
|
|
+ operand *result, *left;
|
13634 |
|
|
+
|
13635 |
|
|
+ D(pblaze_emitcode(";", "genRLC"));
|
13636 |
|
|
+
|
13637 |
|
|
+ result = IC_RESULT(ic);
|
13638 |
|
|
+ left = IC_LEFT(ic);
|
13639 |
|
|
+ size = getSize(operandType(result));
|
13640 |
|
|
+
|
13641 |
|
|
+ /* left and result operands aren't the same */
|
13642 |
|
|
+ if (!pblaze_operandsEqu(IC_RESULT(ic), IC_LEFT(ic))) {
|
13643 |
|
|
+ /* assign optimalization (left symbol may ends at this position) */
|
13644 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
13645 |
|
|
+ assignOpt(ic, result, left);
|
13646 |
|
|
+ }
|
13647 |
|
|
+ /* assign left operand into result operand */
|
13648 |
|
|
+ else {
|
13649 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
13650 |
|
|
+ }
|
13651 |
|
|
+ }
|
13652 |
|
|
+
|
13653 |
|
|
+ if (size == 1) {
|
13654 |
|
|
+ pblaze_emitcode("RL", "%s", aopGetRegName(ic, result, 0));
|
13655 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13656 |
|
|
+ } else {
|
13657 |
|
|
+ pblaze_emitcode("TEST", "%s, %s", aopGetRegName(ic, result, size - 1), dialectNum(128));
|
13658 |
|
|
+
|
13659 |
|
|
+ while (size--) {
|
13660 |
|
|
+ pblaze_emitcode("SLA", "%s", aopGetRegName(ic, result, offset));
|
13661 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
13662 |
|
|
+ offset++;
|
13663 |
|
|
+ }
|
13664 |
|
|
+
|
13665 |
|
|
+ }
|
13666 |
|
|
+}
|
13667 |
|
|
+
|
13668 |
|
|
+/*-----------------------------------------------------------------*/
|
13669 |
|
|
+/* genGetHbit - generates code get highest order bit */
|
13670 |
|
|
+/*-----------------------------------------------------------------*/
|
13671 |
|
|
+static void genGetHbit(iCode * ic)
|
13672 |
|
|
+{
|
13673 |
|
|
+ int offset = 0;
|
13674 |
|
|
+ int size, sizeL;
|
13675 |
|
|
+ operand *result, *left;
|
13676 |
|
|
+
|
13677 |
|
|
+ D(pblaze_emitcode(";", "genGetHBit"));
|
13678 |
|
|
+
|
13679 |
|
|
+ result = IC_RESULT(ic);
|
13680 |
|
|
+ left = IC_LEFT(ic);
|
13681 |
|
|
+ size = getSize(operandType(result));
|
13682 |
|
|
+ sizeL = getSize(operandType(left));
|
13683 |
|
|
+
|
13684 |
|
|
+ while (size--) {
|
13685 |
|
|
+ pblaze_emitcode("XOR", "%s, %s", aopGetRegName(ic, result, offset), aopGetRegName(ic, result, offset));
|
13686 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
13687 |
|
|
+
|
13688 |
|
|
+ if (size == 0) {
|
13689 |
|
|
+ pblaze_emitcode("TEST", "%s, %s", aopGetRegName(ic, left, sizeL - 1), dialectNum(128));
|
13690 |
|
|
+ pblaze_emitcodeADDCY(aopGetRegName(ic, result, 0), dialectNum(0));
|
13691 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13692 |
|
|
+ }
|
13693 |
|
|
+
|
13694 |
|
|
+ offset++;
|
13695 |
|
|
+ }
|
13696 |
|
|
+}
|
13697 |
|
|
+
|
13698 |
|
|
+/*-----------------------------------------------------------------*/
|
13699 |
|
|
+/* leftMaskNumber - generates bit mask for AND operation */
|
13700 |
|
|
+/*-----------------------------------------------------------------*/
|
13701 |
|
|
+int leftMaskNumber(int ones)
|
13702 |
|
|
+{
|
13703 |
|
|
+ int num = 0;
|
13704 |
|
|
+ if (ones >= 1)
|
13705 |
|
|
+ num += 128;
|
13706 |
|
|
+ if (ones >= 2)
|
13707 |
|
|
+ num += 64;
|
13708 |
|
|
+ if (ones >= 3)
|
13709 |
|
|
+ num += 32;
|
13710 |
|
|
+ if (ones >= 4)
|
13711 |
|
|
+ num += 16;
|
13712 |
|
|
+ if (ones >= 5)
|
13713 |
|
|
+ num += 8;
|
13714 |
|
|
+ if (ones >= 6)
|
13715 |
|
|
+ num += 4;
|
13716 |
|
|
+ if (ones >= 7)
|
13717 |
|
|
+ num += 2;
|
13718 |
|
|
+ if (ones >= 8)
|
13719 |
|
|
+ num += 1;
|
13720 |
|
|
+ return num;
|
13721 |
|
|
+}
|
13722 |
|
|
+
|
13723 |
|
|
+/*-----------------------------------------------------------------*/
|
13724 |
|
|
+/* rightMaskNumber - generates bit mask for AND operation */
|
13725 |
|
|
+/*-----------------------------------------------------------------*/
|
13726 |
|
|
+int rightMaskNumber(int ones)
|
13727 |
|
|
+{
|
13728 |
|
|
+ int num = 0;
|
13729 |
|
|
+ if (ones >= 1)
|
13730 |
|
|
+ num += 1;
|
13731 |
|
|
+ if (ones >= 2)
|
13732 |
|
|
+ num += 2;
|
13733 |
|
|
+ if (ones >= 3)
|
13734 |
|
|
+ num += 4;
|
13735 |
|
|
+ if (ones >= 4)
|
13736 |
|
|
+ num += 8;
|
13737 |
|
|
+ if (ones >= 5)
|
13738 |
|
|
+ num += 16;
|
13739 |
|
|
+ if (ones >= 6)
|
13740 |
|
|
+ num += 32;
|
13741 |
|
|
+ if (ones >= 7)
|
13742 |
|
|
+ num += 64;
|
13743 |
|
|
+ if (ones >= 8)
|
13744 |
|
|
+ num += 128;
|
13745 |
|
|
+ return num;
|
13746 |
|
|
+}
|
13747 |
|
|
+
|
13748 |
|
|
+/*-----------------------------------------------------------------*/
|
13749 |
|
|
+/* genShiftLeftLit - shift left by a known amount */
|
13750 |
|
|
+/*-----------------------------------------------------------------*/
|
13751 |
|
|
+static void genShiftLeftLit(iCode * ic)
|
13752 |
|
|
+{
|
13753 |
|
|
+ operand *left, *right, *result;
|
13754 |
|
|
+ int i, size, shCount, lByteZ, offset = 0;
|
13755 |
|
|
+
|
13756 |
|
|
+ D(pblaze_emitcode(";", "genShiftLeftLit"));
|
13757 |
|
|
+
|
13758 |
|
|
+ result = IC_RESULT(ic);
|
13759 |
|
|
+ right = IC_RIGHT(ic);
|
13760 |
|
|
+ left = IC_LEFT(ic);
|
13761 |
|
|
+ size = getSize(operandType(result));
|
13762 |
|
|
+
|
13763 |
|
|
+ shCount = (int) ulFromVal(OP_VALUE(right));
|
13764 |
|
|
+
|
13765 |
|
|
+ /* shift count = 0 */
|
13766 |
|
|
+ if (shCount == 0) {
|
13767 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
13768 |
|
|
+ assignOpt(ic, result, left);
|
13769 |
|
|
+ } else {
|
13770 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
13771 |
|
|
+ }
|
13772 |
|
|
+ return;
|
13773 |
|
|
+ }
|
13774 |
|
|
+
|
13775 |
|
|
+ /* shift count > size */
|
13776 |
|
|
+ if (shCount >= (size * 8)) {
|
13777 |
|
|
+ while (size--)
|
13778 |
|
|
+ aopPutVal(ic, result, dialectNum(0), offset++);
|
13779 |
|
|
+ return;
|
13780 |
|
|
+ }
|
13781 |
|
|
+ offset = 0;
|
13782 |
|
|
+
|
13783 |
|
|
+ switch (size) {
|
13784 |
|
|
+ case 1:
|
13785 |
|
|
+
|
13786 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
13787 |
|
|
+ assignOpt(ic, result, left);
|
13788 |
|
|
+ }
|
13789 |
|
|
+ /* assign left operand into result operand */
|
13790 |
|
|
+ else {
|
13791 |
|
|
+ copyRegisters(ic, result, left, 0, 0);
|
13792 |
|
|
+ }
|
13793 |
|
|
+
|
13794 |
|
|
+ if (shCount <= 4) {
|
13795 |
|
|
+ while (shCount--) {
|
13796 |
|
|
+ pblaze_emitcode("SL0", "%s", aopGetRegName(ic, result, 0));
|
13797 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13798 |
|
|
+ }
|
13799 |
|
|
+ }
|
13800 |
|
|
+ // shift left more than 4 times can be converted to RR & AND (less instructions requied)
|
13801 |
|
|
+ else {
|
13802 |
|
|
+ i = shCount = 8 - shCount;
|
13803 |
|
|
+ while (shCount--) {
|
13804 |
|
|
+ pblaze_emitcode("RR", "%s", aopGetRegName(ic, result, 0));
|
13805 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13806 |
|
|
+ }
|
13807 |
|
|
+ pblaze_emitcode("AND", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(leftMaskNumber(i)));
|
13808 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13809 |
|
|
+ }
|
13810 |
|
|
+ break;
|
13811 |
|
|
+
|
13812 |
|
|
+ case 2:
|
13813 |
|
|
+
|
13814 |
|
|
+ if (shCount >= 8) {
|
13815 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(0));
|
13816 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13817 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 1), aopGetRegName(ic, left, 0));
|
13818 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
13819 |
|
|
+
|
13820 |
|
|
+ shCount -= 8;
|
13821 |
|
|
+
|
13822 |
|
|
+ while (shCount--) {
|
13823 |
|
|
+ pblaze_emitcode("SL0", "%s", aopGetRegName(ic, result, 1));
|
13824 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
13825 |
|
|
+ }
|
13826 |
|
|
+ } else {
|
13827 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
13828 |
|
|
+ assignOpt(ic, result, left);
|
13829 |
|
|
+ } else {
|
13830 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
13831 |
|
|
+ }
|
13832 |
|
|
+
|
13833 |
|
|
+ while (shCount--) {
|
13834 |
|
|
+ pblaze_emitcode("SL0", "%s", aopGetRegName(ic, result, 0));
|
13835 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13836 |
|
|
+ pblaze_emitcode("SLA", "%s", aopGetRegName(ic, result, 1));
|
13837 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
13838 |
|
|
+ }
|
13839 |
|
|
+ }
|
13840 |
|
|
+ break;
|
13841 |
|
|
+
|
13842 |
|
|
+ case 3:
|
13843 |
|
|
+ assert("unknown type\n");
|
13844 |
|
|
+ break;
|
13845 |
|
|
+
|
13846 |
|
|
+ case 4:
|
13847 |
|
|
+ lByteZ = 0;
|
13848 |
|
|
+ if (shCount >= 24) {
|
13849 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(0));
|
13850 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13851 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 1), dialectNum(0));
|
13852 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
13853 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 2), dialectNum(0));
|
13854 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
13855 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 3), aopGetRegName(ic, left, 0));
|
13856 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
13857 |
|
|
+ lByteZ = 3;
|
13858 |
|
|
+ shCount -= 24;
|
13859 |
|
|
+ }
|
13860 |
|
|
+ if (shCount >= 16) {
|
13861 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(0));
|
13862 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13863 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 1), dialectNum(0));
|
13864 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
13865 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 2), aopGetRegName(ic, left, 0));
|
13866 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
13867 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 3), aopGetRegName(ic, left, 1));
|
13868 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
13869 |
|
|
+ lByteZ = 2;
|
13870 |
|
|
+ shCount -= 16;
|
13871 |
|
|
+ }
|
13872 |
|
|
+
|
13873 |
|
|
+ if (shCount >= 8) {
|
13874 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(0));
|
13875 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13876 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 1), aopGetRegName(ic, left, 0));
|
13877 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
13878 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 2), aopGetRegName(ic, left, 1));
|
13879 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
13880 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 3), aopGetRegName(ic, left, 2));
|
13881 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
13882 |
|
|
+ lByteZ = 1;
|
13883 |
|
|
+ shCount -= 8;
|
13884 |
|
|
+ }
|
13885 |
|
|
+
|
13886 |
|
|
+ if (lByteZ == 0) {
|
13887 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
13888 |
|
|
+ assignOpt(ic, result, left);
|
13889 |
|
|
+ } else {
|
13890 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
13891 |
|
|
+ }
|
13892 |
|
|
+ }
|
13893 |
|
|
+ if (shCount) {
|
13894 |
|
|
+ switch (lByteZ) {
|
13895 |
|
|
+ case 0:
|
13896 |
|
|
+ while (shCount--) {
|
13897 |
|
|
+ pblaze_emitcode("SL0", "%s", aopGetRegName(ic, result, 0));
|
13898 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
13899 |
|
|
+ pblaze_emitcode("SLA", "%s", aopGetRegName(ic, result, 1));
|
13900 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
13901 |
|
|
+ pblaze_emitcode("SLA", "%s", aopGetRegName(ic, result, 2));
|
13902 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
13903 |
|
|
+ pblaze_emitcode("SLA", "%s", aopGetRegName(ic, result, 3));
|
13904 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
13905 |
|
|
+ }
|
13906 |
|
|
+ break;
|
13907 |
|
|
+
|
13908 |
|
|
+ case 1:
|
13909 |
|
|
+ while (shCount--) {
|
13910 |
|
|
+ pblaze_emitcode("SL0", "%s", aopGetRegName(ic, result, 1));
|
13911 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
13912 |
|
|
+ pblaze_emitcode("SLA", "%s", aopGetRegName(ic, result, 2));
|
13913 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
13914 |
|
|
+ pblaze_emitcode("SLA", "%s", aopGetRegName(ic, result, 3));
|
13915 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
13916 |
|
|
+ }
|
13917 |
|
|
+ break;
|
13918 |
|
|
+
|
13919 |
|
|
+ case 2:
|
13920 |
|
|
+ while (shCount--) {
|
13921 |
|
|
+ pblaze_emitcode("SL0", "%s", aopGetRegName(ic, result, 2));
|
13922 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
13923 |
|
|
+ pblaze_emitcode("SLA", "%s", aopGetRegName(ic, result, 3));
|
13924 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
13925 |
|
|
+ }
|
13926 |
|
|
+ break;
|
13927 |
|
|
+
|
13928 |
|
|
+ case 3:
|
13929 |
|
|
+ while (shCount--) {
|
13930 |
|
|
+ pblaze_emitcode("SL0", "%s", aopGetRegName(ic, result, 3));
|
13931 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
13932 |
|
|
+ }
|
13933 |
|
|
+ break;
|
13934 |
|
|
+ }
|
13935 |
|
|
+ }
|
13936 |
|
|
+ break;
|
13937 |
|
|
+ }
|
13938 |
|
|
+}
|
13939 |
|
|
+
|
13940 |
|
|
+/*-----------------------------------------------------------------*/
|
13941 |
|
|
+/* genLeftShift - generates code for left shifting */
|
13942 |
|
|
+/*-----------------------------------------------------------------*/
|
13943 |
|
|
+static void genLeftShift(iCode * ic)
|
13944 |
|
|
+{
|
13945 |
|
|
+ operand *left, *right, *result;
|
13946 |
|
|
+ int size, offset = 0;
|
13947 |
|
|
+ symbol *slbl, *elbl;
|
13948 |
|
|
+ reg_info *reg;
|
13949 |
|
|
+ int notTemp;
|
13950 |
|
|
+
|
13951 |
|
|
+ D(pblaze_emitcode(";", "genShiftLeft"));
|
13952 |
|
|
+
|
13953 |
|
|
+ if (isOperandLiteral(IC_RIGHT(ic))) {
|
13954 |
|
|
+ genShiftLeftLit(ic);
|
13955 |
|
|
+ return;
|
13956 |
|
|
+ }
|
13957 |
|
|
+
|
13958 |
|
|
+ result = IC_RESULT(ic);
|
13959 |
|
|
+ right = IC_RIGHT(ic);
|
13960 |
|
|
+ left = IC_LEFT(ic);
|
13961 |
|
|
+ size = getSize(operandType(result));
|
13962 |
|
|
+
|
13963 |
|
|
+
|
13964 |
|
|
+ /* left and result operands aren't the same */
|
13965 |
|
|
+ if (!pblaze_operandsEqu(result, left)) {
|
13966 |
|
|
+ /* assign optimalization (left symbol may ends at this position) */
|
13967 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
13968 |
|
|
+ assignOpt(ic, result, left);
|
13969 |
|
|
+ }
|
13970 |
|
|
+ /* assign left operand into result operand */
|
13971 |
|
|
+ else {
|
13972 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
13973 |
|
|
+ }
|
13974 |
|
|
+ }
|
13975 |
|
|
+
|
13976 |
|
|
+ /* shift count is unknown then we have to form a loop
|
13977 |
|
|
+ Note: we take only the lower order byte since shifting
|
13978 |
|
|
+ more that 32 bits make no sense anyway, */
|
13979 |
|
|
+
|
13980 |
|
|
+ if (ic->seq >= OP_SYMBOL(right)->liveTo) {
|
13981 |
|
|
+ reg = aopGetReg(ic, right, 0);
|
13982 |
|
|
+ notTemp = 1;
|
13983 |
|
|
+ } else {
|
13984 |
|
|
+ reg = getReg(ic);
|
13985 |
|
|
+ lockReg(reg);
|
13986 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", reg->name, aopGetRegName(ic, right, 0));
|
13987 |
|
|
+ notTemp = 0;
|
13988 |
|
|
+ }
|
13989 |
|
|
+
|
13990 |
|
|
+
|
13991 |
|
|
+ elbl = newiTempLabel(NULL);
|
13992 |
|
|
+ slbl = newiTempLabel(NULL);
|
13993 |
|
|
+
|
13994 |
|
|
+ pblaze_emitLabelC(slbl);
|
13995 |
|
|
+
|
13996 |
|
|
+ pblaze_emitcodeCompare(reg->name, dialectNum(0));
|
13997 |
|
|
+ pblaze_emitcode("JUMP", "Z, _LC%05d", LBL_KEY(elbl));
|
13998 |
|
|
+
|
13999 |
|
|
+ pblaze_emitcode("SUB", "%s, %s", reg->name, dialectNum(1));
|
14000 |
|
|
+ if (notTemp)
|
14001 |
|
|
+ aopUpdateOpInMem(ic, right, 0);
|
14002 |
|
|
+ // zero carry flag
|
14003 |
|
|
+ pblaze_emitcode("AND", "sB, sB");
|
14004 |
|
|
+
|
14005 |
|
|
+ while (size--) {
|
14006 |
|
|
+ pblaze_emitcode("SLA", "%s", aopGetRegName(ic, result, offset++));
|
14007 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
14008 |
|
|
+ }
|
14009 |
|
|
+
|
14010 |
|
|
+ pblaze_emitcode("JUMP", "_LC%05d", LBL_KEY(slbl));
|
14011 |
|
|
+
|
14012 |
|
|
+ pblaze_emitLabelC(elbl);
|
14013 |
|
|
+
|
14014 |
|
|
+ unlockReg(reg);
|
14015 |
|
|
+}
|
14016 |
|
|
+
|
14017 |
|
|
+/*-----------------------------------------------------------------*/
|
14018 |
|
|
+/* genShiftRightLit - generate for right shift with known count */
|
14019 |
|
|
+/*-----------------------------------------------------------------*/
|
14020 |
|
|
+static void genShiftRightLit(iCode * ic)
|
14021 |
|
|
+{
|
14022 |
|
|
+ operand *left, *right, *result;
|
14023 |
|
|
+ int i, size, shCount, hByteZ, offset = 0;
|
14024 |
|
|
+
|
14025 |
|
|
+ D(pblaze_emitcode(";", "genShiftRightLit"));
|
14026 |
|
|
+
|
14027 |
|
|
+ result = IC_RESULT(ic);
|
14028 |
|
|
+ right = IC_RIGHT(ic);
|
14029 |
|
|
+ left = IC_LEFT(ic);
|
14030 |
|
|
+ size = getSize(operandType(result));
|
14031 |
|
|
+
|
14032 |
|
|
+ shCount = (int) ulFromVal(OP_VALUE(right));
|
14033 |
|
|
+ if (shCount == 0) {
|
14034 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
14035 |
|
|
+ assignOpt(ic, result, left);
|
14036 |
|
|
+ } else {
|
14037 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
14038 |
|
|
+ }
|
14039 |
|
|
+ return;
|
14040 |
|
|
+ }
|
14041 |
|
|
+
|
14042 |
|
|
+ if (shCount >= (size * 8)) {
|
14043 |
|
|
+ while (size--) {
|
14044 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, offset), dialectNum(0));
|
14045 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
14046 |
|
|
+ offset++;
|
14047 |
|
|
+ }
|
14048 |
|
|
+ return;
|
14049 |
|
|
+ }
|
14050 |
|
|
+ offset = 0;
|
14051 |
|
|
+ switch (size) {
|
14052 |
|
|
+ case 1:
|
14053 |
|
|
+
|
14054 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
14055 |
|
|
+ assignOpt(ic, result, left);
|
14056 |
|
|
+ }
|
14057 |
|
|
+ /* assign left operand into result operand */
|
14058 |
|
|
+ else {
|
14059 |
|
|
+ copyRegisters(ic, result, left, 0, 0);
|
14060 |
|
|
+ }
|
14061 |
|
|
+
|
14062 |
|
|
+ if (shCount <= 4) {
|
14063 |
|
|
+ while (shCount--) {
|
14064 |
|
|
+ pblaze_emitcode("SR0", "%s", aopGetRegName(ic, result, 0));
|
14065 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14066 |
|
|
+ }
|
14067 |
|
|
+ }
|
14068 |
|
|
+ // shift right more than 4 times can be converted to RL & AND (less instructions requied)
|
14069 |
|
|
+ else {
|
14070 |
|
|
+ i = shCount = 8 - shCount;
|
14071 |
|
|
+ while (shCount--) {
|
14072 |
|
|
+ pblaze_emitcode("RL", "%s", aopGetRegName(ic, result, 0));
|
14073 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14074 |
|
|
+ }
|
14075 |
|
|
+ pblaze_emitcode("AND", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(rightMaskNumber(i)));
|
14076 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14077 |
|
|
+ }
|
14078 |
|
|
+ break;
|
14079 |
|
|
+
|
14080 |
|
|
+ case 2:
|
14081 |
|
|
+
|
14082 |
|
|
+ if (shCount >= 8) {
|
14083 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 0), aopGetRegName(ic, left, 1));
|
14084 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14085 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 1), dialectNum(1));
|
14086 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
14087 |
|
|
+
|
14088 |
|
|
+ shCount -= 8;
|
14089 |
|
|
+
|
14090 |
|
|
+ while (shCount--) {
|
14091 |
|
|
+ pblaze_emitcode("SR0", "%s", aopGetRegName(ic, result, 0));
|
14092 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14093 |
|
|
+ }
|
14094 |
|
|
+ } else {
|
14095 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
14096 |
|
|
+ assignOpt(ic, result, left);
|
14097 |
|
|
+ } else {
|
14098 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
14099 |
|
|
+ }
|
14100 |
|
|
+
|
14101 |
|
|
+ while (shCount--) {
|
14102 |
|
|
+ pblaze_emitcode("SR0", "%s", aopGetRegName(ic, result, 1));
|
14103 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
14104 |
|
|
+ pblaze_emitcode("SRA", "%s", aopGetRegName(ic, result, 0));
|
14105 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14106 |
|
|
+ }
|
14107 |
|
|
+ }
|
14108 |
|
|
+ break;
|
14109 |
|
|
+
|
14110 |
|
|
+ case 3:
|
14111 |
|
|
+ assert("unknown type\n");
|
14112 |
|
|
+ break;
|
14113 |
|
|
+
|
14114 |
|
|
+ case 4:
|
14115 |
|
|
+ hByteZ = 0;
|
14116 |
|
|
+ if (shCount >= 24) {
|
14117 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 0), aopGetRegName(ic, left, 3));
|
14118 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14119 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 1), dialectNum(0));
|
14120 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
14121 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 2), dialectNum(0));
|
14122 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
14123 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 3), dialectNum(0));
|
14124 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
14125 |
|
|
+
|
14126 |
|
|
+ hByteZ = 3;
|
14127 |
|
|
+ shCount -= 24;
|
14128 |
|
|
+ }
|
14129 |
|
|
+ if (shCount >= 16) {
|
14130 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 0), aopGetRegName(ic, left, 2));
|
14131 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14132 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 1), aopGetRegName(ic, left, 3));
|
14133 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
14134 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 2), dialectNum(0));
|
14135 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
14136 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 3), dialectNum(0));
|
14137 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
14138 |
|
|
+
|
14139 |
|
|
+ hByteZ = 2;
|
14140 |
|
|
+ shCount -= 16;
|
14141 |
|
|
+ }
|
14142 |
|
|
+
|
14143 |
|
|
+ if (shCount >= 8) {
|
14144 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 0), aopGetRegName(ic, left, 1));
|
14145 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14146 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 1), aopGetRegName(ic, left, 2));
|
14147 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
14148 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 2), aopGetRegName(ic, left, 3));
|
14149 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
14150 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, 3), dialectNum(0));
|
14151 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
14152 |
|
|
+
|
14153 |
|
|
+ hByteZ = 1;
|
14154 |
|
|
+ shCount -= 8;
|
14155 |
|
|
+ }
|
14156 |
|
|
+
|
14157 |
|
|
+ if (hByteZ == 0) {
|
14158 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
14159 |
|
|
+ assignOpt(ic, result, left);
|
14160 |
|
|
+ } else {
|
14161 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
14162 |
|
|
+ }
|
14163 |
|
|
+ }
|
14164 |
|
|
+ if (shCount) {
|
14165 |
|
|
+ switch (hByteZ) {
|
14166 |
|
|
+ case 0:
|
14167 |
|
|
+ while (shCount--) {
|
14168 |
|
|
+ pblaze_emitcode("SR0", "%s", aopGetRegName(ic, result, 3));
|
14169 |
|
|
+ aopUpdateOpInMem(ic, result, 3);
|
14170 |
|
|
+ pblaze_emitcode("SRA", "%s", aopGetRegName(ic, result, 2));
|
14171 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
14172 |
|
|
+ pblaze_emitcode("SRA", "%s", aopGetRegName(ic, result, 1));
|
14173 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
14174 |
|
|
+ pblaze_emitcode("SRA", "%s", aopGetRegName(ic, result, 0));
|
14175 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14176 |
|
|
+ }
|
14177 |
|
|
+ break;
|
14178 |
|
|
+
|
14179 |
|
|
+ case 1:
|
14180 |
|
|
+ while (shCount--) {
|
14181 |
|
|
+ pblaze_emitcode("SR0", "%s", aopGetRegName(ic, result, 2));
|
14182 |
|
|
+ aopUpdateOpInMem(ic, result, 2);
|
14183 |
|
|
+ pblaze_emitcode("SRA", "%s", aopGetRegName(ic, result, 1));
|
14184 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
14185 |
|
|
+ pblaze_emitcode("SRA", "%s", aopGetRegName(ic, result, 0));
|
14186 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14187 |
|
|
+ }
|
14188 |
|
|
+ break;
|
14189 |
|
|
+
|
14190 |
|
|
+ case 2:
|
14191 |
|
|
+ while (shCount--) {
|
14192 |
|
|
+ pblaze_emitcode("SR0", "%s", aopGetRegName(ic, result, 1));
|
14193 |
|
|
+ aopUpdateOpInMem(ic, result, 1);
|
14194 |
|
|
+ pblaze_emitcode("SRA", "%s", aopGetRegName(ic, result, 0));
|
14195 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14196 |
|
|
+ }
|
14197 |
|
|
+ break;
|
14198 |
|
|
+
|
14199 |
|
|
+ case 3:
|
14200 |
|
|
+ while (shCount--) {
|
14201 |
|
|
+ pblaze_emitcode("SR0", "%s", aopGetRegName(ic, result, 0));
|
14202 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14203 |
|
|
+ }
|
14204 |
|
|
+ break;
|
14205 |
|
|
+ }
|
14206 |
|
|
+ }
|
14207 |
|
|
+ break;
|
14208 |
|
|
+ }
|
14209 |
|
|
+
|
14210 |
|
|
+}
|
14211 |
|
|
+
|
14212 |
|
|
+/*-----------------------------------------------------------------*/
|
14213 |
|
|
+/* genRightShift - generate code for right shifting */
|
14214 |
|
|
+/*-----------------------------------------------------------------*/
|
14215 |
|
|
+static void genRightShift(iCode * ic)
|
14216 |
|
|
+{
|
14217 |
|
|
+ operand *left, *right, *result;
|
14218 |
|
|
+ int size;
|
14219 |
|
|
+ symbol *slbl, *elbl;
|
14220 |
|
|
+ reg_info *reg;
|
14221 |
|
|
+ int notTemp;
|
14222 |
|
|
+
|
14223 |
|
|
+ D(pblaze_emitcode(";", "genShiftRight"));
|
14224 |
|
|
+
|
14225 |
|
|
+ if (isOperandLiteral(IC_RIGHT(ic))) {
|
14226 |
|
|
+ genShiftRightLit(ic);
|
14227 |
|
|
+ return;
|
14228 |
|
|
+ }
|
14229 |
|
|
+
|
14230 |
|
|
+ result = IC_RESULT(ic);
|
14231 |
|
|
+ right = IC_RIGHT(ic);
|
14232 |
|
|
+ left = IC_LEFT(ic);
|
14233 |
|
|
+ size = getSize(operandType(result));
|
14234 |
|
|
+
|
14235 |
|
|
+
|
14236 |
|
|
+ /* left and result operands aren't the same */
|
14237 |
|
|
+ if (!pblaze_operandsEqu(result, left)) {
|
14238 |
|
|
+ /* assign optimalization (left symbol may ends at this position) */
|
14239 |
|
|
+ if (ASSIGN_OPT(result, left)) {
|
14240 |
|
|
+ assignOpt(ic, result, left);
|
14241 |
|
|
+ }
|
14242 |
|
|
+ /* assign left operand into result operand */
|
14243 |
|
|
+ else {
|
14244 |
|
|
+ copyRegisters(ic, result, left, 0, size - 1);
|
14245 |
|
|
+ }
|
14246 |
|
|
+ }
|
14247 |
|
|
+
|
14248 |
|
|
+ /* shift count is unknown then we have to form a loop
|
14249 |
|
|
+ Note: we take only the lower order byte since shifting
|
14250 |
|
|
+ more that 32 bits make no sense anyway, */
|
14251 |
|
|
+
|
14252 |
|
|
+ if (ic->seq >= OP_SYMBOL(right)->liveTo) {
|
14253 |
|
|
+ reg = aopGetReg(ic, right, 0);
|
14254 |
|
|
+ notTemp = 1;
|
14255 |
|
|
+ } else {
|
14256 |
|
|
+ reg = getReg(ic);
|
14257 |
|
|
+ lockReg(reg);
|
14258 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", reg->name, aopGetRegName(ic, right, 0));
|
14259 |
|
|
+ notTemp = 0;
|
14260 |
|
|
+ }
|
14261 |
|
|
+
|
14262 |
|
|
+
|
14263 |
|
|
+ elbl = newiTempLabel(NULL);
|
14264 |
|
|
+ slbl = newiTempLabel(NULL);
|
14265 |
|
|
+
|
14266 |
|
|
+ pblaze_emitLabelC(slbl);
|
14267 |
|
|
+
|
14268 |
|
|
+ pblaze_emitcodeCompare(reg->name, dialectNum(0));
|
14269 |
|
|
+ pblaze_emitcode("JUMP", "Z, _LC%05d", LBL_KEY(elbl));
|
14270 |
|
|
+
|
14271 |
|
|
+ pblaze_emitcode("SUB", "%s, %s", reg->name, dialectNum(1));
|
14272 |
|
|
+ if (notTemp)
|
14273 |
|
|
+ aopUpdateOpInMem(ic, right, 0);
|
14274 |
|
|
+
|
14275 |
|
|
+ // zero carry flag
|
14276 |
|
|
+ pblaze_emitcode("AND", "sB, sB");
|
14277 |
|
|
+
|
14278 |
|
|
+ while (size--) {
|
14279 |
|
|
+ pblaze_emitcode("SRA", "%s", aopGetRegName(ic, result, size));
|
14280 |
|
|
+ aopUpdateOpInMem(ic, result, size);
|
14281 |
|
|
+ }
|
14282 |
|
|
+
|
14283 |
|
|
+ pblaze_emitcode("JUMP", "_LC%05d", LBL_KEY(slbl));
|
14284 |
|
|
+
|
14285 |
|
|
+ pblaze_emitLabelC(elbl);
|
14286 |
|
|
+
|
14287 |
|
|
+ unlockReg(reg);
|
14288 |
|
|
+}
|
14289 |
|
|
+
|
14290 |
|
|
+/*-----------------------------------------------------------------*/
|
14291 |
|
|
+/* genIfx - generate code for Ifx statement */
|
14292 |
|
|
+/*-----------------------------------------------------------------*/
|
14293 |
|
|
+static void genIfx(iCode * ic, iCode * popIc)
|
14294 |
|
|
+{
|
14295 |
|
|
+ operand *cond = IC_COND(ic);
|
14296 |
|
|
+ symbol *lbl;
|
14297 |
|
|
+ reg_info *reg;
|
14298 |
|
|
+
|
14299 |
|
|
+ D(pblaze_emitcode(";", "genIFX"));
|
14300 |
|
|
+
|
14301 |
|
|
+ lbl = newiTempLabel(NULL);
|
14302 |
|
|
+
|
14303 |
|
|
+ reg = toBoolean(ic, cond);
|
14304 |
|
|
+ pblaze_emitcodeCompare(reg->name, dialectNum(0));
|
14305 |
|
|
+
|
14306 |
|
|
+ if (IC_TRUE(ic)) {
|
14307 |
|
|
+ pblaze_emitcode("JUMP", "Z, _LC%05d", LBL_KEY(lbl));
|
14308 |
|
|
+ pblaze_emitcode("JUMP", "_L%05d", LBL_KEY(IC_TRUE(ic)));
|
14309 |
|
|
+ pblaze_emitLabelC(lbl);
|
14310 |
|
|
+ }
|
14311 |
|
|
+
|
14312 |
|
|
+ else {
|
14313 |
|
|
+ pblaze_emitcode("JUMP", "NZ, _LC%05d", LBL_KEY(lbl));
|
14314 |
|
|
+ pblaze_emitcode("JUMP", "_L%05d", LBL_KEY(IC_FALSE(ic)));
|
14315 |
|
|
+ pblaze_emitLabelC(lbl);
|
14316 |
|
|
+ }
|
14317 |
|
|
+
|
14318 |
|
|
+}
|
14319 |
|
|
+
|
14320 |
|
|
+/*-----------------------------------------------------------------*/
|
14321 |
|
|
+/* genAddrOf - generates code for address of */
|
14322 |
|
|
+/*-----------------------------------------------------------------*/
|
14323 |
|
|
+static void genAddrOf(iCode * ic)
|
14324 |
|
|
+{
|
14325 |
|
|
+ D(pblaze_emitcode(";", "genAddrOf"));
|
14326 |
|
|
+
|
14327 |
|
|
+ operand *result, *left;
|
14328 |
|
|
+ int size, inR;
|
14329 |
|
|
+ memMap *mAddr;
|
14330 |
|
|
+
|
14331 |
|
|
+ result = IC_RESULT(ic);
|
14332 |
|
|
+ left = IC_LEFT(ic);
|
14333 |
|
|
+
|
14334 |
|
|
+ if (isInOutRef(left)) {
|
14335 |
|
|
+ addInOutRef(result, NULL);
|
14336 |
|
|
+ return;
|
14337 |
|
|
+ }
|
14338 |
|
|
+
|
14339 |
|
|
+ size = getSize(operandType(result));
|
14340 |
|
|
+
|
14341 |
|
|
+ mAddr = isOpInMem(left);
|
14342 |
|
|
+ inR = isOpInReg(left);
|
14343 |
|
|
+
|
14344 |
|
|
+ if (!mAddr && inR) {
|
14345 |
|
|
+ moveOpToMem(left);
|
14346 |
|
|
+ mAddr = isOpInMem(left);
|
14347 |
|
|
+ }
|
14348 |
|
|
+ else if (!mAddr) {
|
14349 |
|
|
+ mAddr = firstFreeMem();
|
14350 |
|
|
+ }
|
14351 |
|
|
+ if (!mAddr) {
|
14352 |
|
|
+ fprintf(stderr, "%s:%d: pblaze port error: operand not in the memory\n", __FILE__, __LINE__);
|
14353 |
|
|
+ exit(1);
|
14354 |
|
|
+ }
|
14355 |
|
|
+ if (!operName(mAddr->addr))
|
14356 |
|
|
+ aopPutVal(ic, result, dialectNum(mAddr->addr), 0);
|
14357 |
|
|
+ else
|
14358 |
|
|
+ aopPutVal(ic, result, operName(mAddr->addr), 0);
|
14359 |
|
|
+
|
14360 |
|
|
+ _G.ptrOff = 0;
|
14361 |
|
|
+}
|
14362 |
|
|
+
|
14363 |
|
|
+/*-----------------------------------------------------------------*/
|
14364 |
|
|
+/* genValueAtAddr - generates code for value at addres */
|
14365 |
|
|
+/*-----------------------------------------------------------------*/
|
14366 |
|
|
+static void genValueAtAddr(iCode * ic)
|
14367 |
|
|
+{
|
14368 |
|
|
+ D(pblaze_emitcode(";", "genValueAtAddr"));
|
14369 |
|
|
+
|
14370 |
|
|
+ int size, i;
|
14371 |
|
|
+ unsigned long lit = 0L;
|
14372 |
|
|
+ operand *result, *left;
|
14373 |
|
|
+
|
14374 |
|
|
+ result = IC_RESULT(ic);
|
14375 |
|
|
+ left = IC_LEFT(ic);
|
14376 |
|
|
+ size = getSize(operandType(result));
|
14377 |
|
|
+
|
14378 |
|
|
+ /* address given as a literal value */
|
14379 |
|
|
+ if (isOperandLiteral(left)) {
|
14380 |
|
|
+
|
14381 |
|
|
+ lit = ulFromVal(OP_VALUE(left));
|
14382 |
|
|
+
|
14383 |
|
|
+ for (i = size - 1; i >= 0; i--) {
|
14384 |
|
|
+ pblaze_emitcodeFetch(aopGetRegName(ic, result, i), dialectNum(valueOffset(lit, 0)));
|
14385 |
|
|
+ lit++;
|
14386 |
|
|
+ }
|
14387 |
|
|
+
|
14388 |
|
|
+ } else {
|
14389 |
|
|
+
|
14390 |
|
|
+ if (size == 1) {
|
14391 |
|
|
+ /* left operand is an INPUT reference */
|
14392 |
|
|
+ if (isInOutRef(left)) {
|
14393 |
|
|
+ pblaze_emitcodeInput(ic, result, 0, left);
|
14394 |
|
|
+ } else {
|
14395 |
|
|
+ pblaze_emitcodeFetch(aopGetRegName(ic, result, 0), aopGetRegName(ic, left, 0));
|
14396 |
|
|
+ }
|
14397 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14398 |
|
|
+ } else if (size > 1) {
|
14399 |
|
|
+ /* left operand is an INPUT reference */
|
14400 |
|
|
+ if (isInOutRef(left)) {
|
14401 |
|
|
+ pblaze_emitcodeInput(ic, result, 0, left);
|
14402 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14403 |
|
|
+ for (i = 1; i < size; i++) {
|
14404 |
|
|
+ aopPutVal(ic, result, dialectNum(0), i);
|
14405 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
14406 |
|
|
+ }
|
14407 |
|
|
+
|
14408 |
|
|
+ } else {
|
14409 |
|
|
+
|
14410 |
|
|
+ for (i = size - 1; i >= 0; i--) {
|
14411 |
|
|
+ pblaze_emitcodeFetch(aopGetRegName(ic, result, i), aopGetRegName(ic, left, 0));
|
14412 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
14413 |
|
|
+
|
14414 |
|
|
+ if (i != 0) {
|
14415 |
|
|
+ pblaze_emitcode("ADD", "%s, %s", aopGetRegName(ic, left, 0), dialectNum(1));
|
14416 |
|
|
+ aopUpdateOpInMem(ic, left, 0);
|
14417 |
|
|
+ }
|
14418 |
|
|
+ }
|
14419 |
|
|
+
|
14420 |
|
|
+ /* pointer will be used later, return to the begining */
|
14421 |
|
|
+ if (OP_LIVETO(left) > ic->seq) {
|
14422 |
|
|
+ pblaze_emitcode("SUB", "%s, %s", aopGetRegName(ic, left, 0), dialectNum(size - 1));
|
14423 |
|
|
+ aopUpdateOpInMem(ic, left, 0);
|
14424 |
|
|
+ }
|
14425 |
|
|
+ }
|
14426 |
|
|
+ }
|
14427 |
|
|
+ }
|
14428 |
|
|
+}
|
14429 |
|
|
+
|
14430 |
|
|
+/*-----------------------------------------------------------------*/
|
14431 |
|
|
+/* genAssign - generate code for assignment */
|
14432 |
|
|
+/*-----------------------------------------------------------------*/
|
14433 |
|
|
+static void genAssign(iCode * ic)
|
14434 |
|
|
+{
|
14435 |
|
|
+ operand *result, *right;
|
14436 |
|
|
+ int size, offset;
|
14437 |
|
|
+ int i;
|
14438 |
|
|
+ memMap *mem;
|
14439 |
|
|
+
|
14440 |
|
|
+ D(pblaze_emitcode(";", "genAssign"));
|
14441 |
|
|
+
|
14442 |
|
|
+ result = IC_RESULT(ic);
|
14443 |
|
|
+ right = IC_RIGHT(ic);
|
14444 |
|
|
+
|
14445 |
|
|
+ /* if they are the same */
|
14446 |
|
|
+ if (pblaze_operandsEqu(result, right))
|
14447 |
|
|
+ return;
|
14448 |
|
|
+
|
14449 |
|
|
+ size = getSize(operandType(result));
|
14450 |
|
|
+
|
14451 |
|
|
+ /* assign from memory */
|
14452 |
|
|
+ if (IS_OP_GLOBALVOLATILE(right) || right->isaddr) {
|
14453 |
|
|
+
|
14454 |
|
|
+ if(isInOutRef(result)) {
|
14455 |
|
|
+ pblaze_emitcodeOutput(ic, aopGetRegName(ic, right, 0), result);
|
14456 |
|
|
+ } else {
|
14457 |
|
|
+ for (i = 0; i < size; i++) {
|
14458 |
|
|
+ aopMoveReg(ic, result, aopGetReg(ic, right, i), i);
|
14459 |
|
|
+ }
|
14460 |
|
|
+ }
|
14461 |
|
|
+ }
|
14462 |
|
|
+
|
14463 |
|
|
+ /* right side is a literal value */
|
14464 |
|
|
+ else if (isOperandLiteral(right)) {
|
14465 |
|
|
+ /* assign literal values into registers */
|
14466 |
|
|
+ assignLiteral(result, right, ic);
|
14467 |
|
|
+ }
|
14468 |
|
|
+
|
14469 |
|
|
+ /* should be on the stack */
|
14470 |
|
|
+ else if (IS_OP_PARM(right) && strlen(OP_SYMBOL(right)->rname) == 0) {
|
14471 |
|
|
+ size = getSize(operandType(right));
|
14472 |
|
|
+ offset = size - 1;
|
14473 |
|
|
+
|
14474 |
|
|
+ while (size--) {
|
14475 |
|
|
+ popStack(aopGetReg(ic, result, offset)->rIdx, 1);
|
14476 |
|
|
+ offset--;
|
14477 |
|
|
+ }
|
14478 |
|
|
+ }
|
14479 |
|
|
+
|
14480 |
|
|
+ /* right side is a symbol */
|
14481 |
|
|
+ else if (OP_SYMBOL(right)) {
|
14482 |
|
|
+ size = getSize(operandType(right));
|
14483 |
|
|
+
|
14484 |
|
|
+ /* result is a pointer into memory */
|
14485 |
|
|
+ if (POINTER_SET(ic)) {
|
14486 |
|
|
+
|
14487 |
|
|
+ for (i = size - 1; i >= 0; i--) {
|
14488 |
|
|
+ aopPutReg(ic, result, aopGetReg(ic, right, i), i);
|
14489 |
|
|
+ if (i > 0) {
|
14490 |
|
|
+ pblaze_emitcode("ADD", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(1));
|
14491 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14492 |
|
|
+ }
|
14493 |
|
|
+ }
|
14494 |
|
|
+ /* pointer will be used later, return to the begining */
|
14495 |
|
|
+ if (size > 1 && OP_LIVETO(result) > ic->seq) {
|
14496 |
|
|
+ pblaze_emitcode("SUB", "%s, %s", aopGetRegName(ic, result, 0), dialectNum(size - 1));
|
14497 |
|
|
+ aopUpdateOpInMem(ic, result, 0);
|
14498 |
|
|
+ }
|
14499 |
|
|
+
|
14500 |
|
|
+ }
|
14501 |
|
|
+
|
14502 |
|
|
+ /* assign optimalization (right symbol may ends at this position) */
|
14503 |
|
|
+ else if (ASSIGN_OPT(result, right) && assignOptTest(ic, IC_RESULT(ic))) {
|
14504 |
|
|
+ assignOpt(ic, result, right);
|
14505 |
|
|
+ }
|
14506 |
|
|
+
|
14507 |
|
|
+ /* assign registers */
|
14508 |
|
|
+ else if (size == getSize(operandType(result))) {
|
14509 |
|
|
+ /* copy values from the right operand into the result operand */
|
14510 |
|
|
+ copyRegisters(ic, result, right, 0, size - 1);
|
14511 |
|
|
+ }
|
14512 |
|
|
+ //
|
14513 |
|
|
+ else {
|
14514 |
|
|
+ fprintf(stderr, "pblaze port error: genAssign unknown error\n");
|
14515 |
|
|
+ exit(1);
|
14516 |
|
|
+ }
|
14517 |
|
|
+ }
|
14518 |
|
|
+
|
14519 |
|
|
+ if (IS_OP_GLOBAL(result) && !isOpVolatile(result)) {
|
14520 |
|
|
+
|
14521 |
|
|
+ /* probably global value assigment */
|
14522 |
|
|
+ if (GLOB_ASSIGN) {
|
14523 |
|
|
+ size = getSize(operandType(result));
|
14524 |
|
|
+
|
14525 |
|
|
+ for (i = size - 1; i >= 0; i--) {
|
14526 |
|
|
+ if (OP_SYMBOL(result)->regs[i] && (mem = isOffsetInMem(result, i)) != NULL)
|
14527 |
|
|
+ pblaze_emitcodeStore(OP_SYMBOL(result)->regs[i]->name, operName(mem->addr));
|
14528 |
|
|
+ }
|
14529 |
|
|
+ } else {
|
14530 |
|
|
+ globalChanged(result, IN_REG);
|
14531 |
|
|
+ }
|
14532 |
|
|
+ }
|
14533 |
|
|
+}
|
14534 |
|
|
+
|
14535 |
|
|
+/*-----------------------------------------------------------------*/
|
14536 |
|
|
+/* genJumpTab - genrates code for jump table */
|
14537 |
|
|
+/*-----------------------------------------------------------------*/
|
14538 |
|
|
+static void genJumpTab(iCode * ic)
|
14539 |
|
|
+{
|
14540 |
|
|
+ // D (pblaze_emitcode (";", "genJumpTab"));
|
14541 |
|
|
+ /* not easy to implement without access to the Instruction pointer */
|
14542 |
|
|
+ assert(0);
|
14543 |
|
|
+}
|
14544 |
|
|
+
|
14545 |
|
|
+/*-----------------------------------------------------------------*/
|
14546 |
|
|
+/* genCast - gen code for casting */
|
14547 |
|
|
+/*-----------------------------------------------------------------*/
|
14548 |
|
|
+static void genCast(iCode * ic)
|
14549 |
|
|
+{
|
14550 |
|
|
+ D(pblaze_emitcode(";", "genCast"));
|
14551 |
|
|
+
|
14552 |
|
|
+ operand *result = IC_RESULT(ic);
|
14553 |
|
|
+
|
14554 |
|
|
+ sym_link *rtype = operandType(IC_RIGHT(ic));
|
14555 |
|
|
+ operand *right = IC_RIGHT(ic);
|
14556 |
|
|
+ int sizeRes, sizeRight, i, opt = 0;
|
14557 |
|
|
+
|
14558 |
|
|
+ sizeRes = getSize(operandType(result));
|
14559 |
|
|
+ sizeRight = getSize(operandType(right));
|
14560 |
|
|
+
|
14561 |
|
|
+ /* if they are equivalent then do nothing */
|
14562 |
|
|
+ if (pblaze_operandsEqu(IC_RESULT(ic), IC_RIGHT(ic)))
|
14563 |
|
|
+ return;
|
14564 |
|
|
+
|
14565 |
|
|
+ //literal and bool
|
14566 |
|
|
+ if (isOperandLiteral(right)) {
|
14567 |
|
|
+
|
14568 |
|
|
+ }
|
14569 |
|
|
+
|
14570 |
|
|
+ else if (IS_PTR(rtype)) {
|
14571 |
|
|
+ if (OP_LIVETO(right) > ic->seq)
|
14572 |
|
|
+ copyRegisters(ic, result, right, 0, 0);
|
14573 |
|
|
+ else
|
14574 |
|
|
+ assignOpt(ic, result, right);
|
14575 |
|
|
+ }
|
14576 |
|
|
+
|
14577 |
|
|
+ /* if they are the same size or less */
|
14578 |
|
|
+ else if (sizeRes <= sizeRight) {
|
14579 |
|
|
+
|
14580 |
|
|
+ /* right symbol may ends at this position */
|
14581 |
|
|
+ if (ASSIGN_OPT(result, right) && assignOptTest(ic, IC_RESULT(ic))) {
|
14582 |
|
|
+ assignOpt(ic, result, right);
|
14583 |
|
|
+ } else {
|
14584 |
|
|
+ /* assign the casted value */
|
14585 |
|
|
+ copyRegisters(ic, result, right, 0, sizeRes - 1);
|
14586 |
|
|
+ }
|
14587 |
|
|
+ }
|
14588 |
|
|
+
|
14589 |
|
|
+ /* the size of destination is greater than the size of the source */
|
14590 |
|
|
+ else {
|
14591 |
|
|
+
|
14592 |
|
|
+ /* right symbol may ends at this position */
|
14593 |
|
|
+ if (ASSIGN_OPT(result, right) && assignOptTest(ic, IC_RESULT(ic))) {
|
14594 |
|
|
+ assignOpt(ic, result, right);
|
14595 |
|
|
+ opt = 1;
|
14596 |
|
|
+ } else {
|
14597 |
|
|
+
|
14598 |
|
|
+ copyRegisters(ic, result, right, 0, sizeRight - 1);
|
14599 |
|
|
+ }
|
14600 |
|
|
+
|
14601 |
|
|
+ /* we need to extend the sign */
|
14602 |
|
|
+ if (opt)
|
14603 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, sizeRight), dialectNum(0));
|
14604 |
|
|
+ aopUpdateOpInMem(ic, result, sizeRight);
|
14605 |
|
|
+ pblaze_emitcode("TEST", "%s, %s", aopGetRegName(ic, result, sizeRight - 1), dialectNum(128));
|
14606 |
|
|
+ pblaze_emitcodeSUBCY(aopGetRegName(ic, result, sizeRight), dialectNum(0));
|
14607 |
|
|
+ aopUpdateOpInMem(ic, result, sizeRight);
|
14608 |
|
|
+
|
14609 |
|
|
+ for (i = sizeRight + 1; i < sizeRes; i++) {
|
14610 |
|
|
+ pblaze_emitcode("LOAD", "%s, %s", aopGetRegName(ic, result, i), aopGetRegName(ic, result, sizeRight));
|
14611 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
14612 |
|
|
+ }
|
14613 |
|
|
+ }
|
14614 |
|
|
+
|
14615 |
|
|
+}
|
14616 |
|
|
+
|
14617 |
|
|
+/*-----------------------------------------------------------------*/
|
14618 |
|
|
+/* genReceive - generate code for a receive iCode */
|
14619 |
|
|
+/*-----------------------------------------------------------------*/
|
14620 |
|
|
+static void genReceive(iCode * ic)
|
14621 |
|
|
+{
|
14622 |
|
|
+ operand *result, *left;
|
14623 |
|
|
+ symbol *name;
|
14624 |
|
|
+ reg_info *r;
|
14625 |
|
|
+ value *val;
|
14626 |
|
|
+ char *valName;
|
14627 |
|
|
+ int size, params;
|
14628 |
|
|
+ int i;
|
14629 |
|
|
+ int rMax = SEND_REG_COUNT;
|
14630 |
|
|
+ int rfrst = SEND_REG_FIRST;
|
14631 |
|
|
+
|
14632 |
|
|
+ D(pblaze_emitcode(";", "genReceive"));
|
14633 |
|
|
+
|
14634 |
|
|
+ result = IC_RESULT(ic);
|
14635 |
|
|
+ left = IC_LEFT(ic);
|
14636 |
|
|
+ size = getSize(operandType(result));
|
14637 |
|
|
+ params = 0;
|
14638 |
|
|
+
|
14639 |
|
|
+ /* test parameter */
|
14640 |
|
|
+ if (result && left) {
|
14641 |
|
|
+
|
14642 |
|
|
+ name = OP_SYMBOL(left);
|
14643 |
|
|
+ val = FUNC_ARGS(name->type);
|
14644 |
|
|
+
|
14645 |
|
|
+ if (SPIL_LOC(result))
|
14646 |
|
|
+ valName = SPIL_LOC(result)->rname;
|
14647 |
|
|
+ else
|
14648 |
|
|
+ valName = OP_SYMBOL(result)->rname;
|
14649 |
|
|
+ /* find parameter position */
|
14650 |
|
|
+ while (val) {
|
14651 |
|
|
+ sprintf(buffer, "%s%s_", name->rname, val->name);
|
14652 |
|
|
+ if (strstr(valName, buffer))
|
14653 |
|
|
+ break;
|
14654 |
|
|
+
|
14655 |
|
|
+ params += getSize(val->type);
|
14656 |
|
|
+ val = val->next;
|
14657 |
|
|
+ }
|
14658 |
|
|
+
|
14659 |
|
|
+ recvCnt = params;
|
14660 |
|
|
+ }
|
14661 |
|
|
+
|
14662 |
|
|
+ /* symbol is in the registers */
|
14663 |
|
|
+ if (recvCnt <= rMax && (rMax - recvCnt) >= size) {
|
14664 |
|
|
+ for (i = 0; i < size; i++) {
|
14665 |
|
|
+ aopPutReg(ic, result, pblaze_regWithIdx(rfrst + recvCnt), i);
|
14666 |
|
|
+ recvCnt++;
|
14667 |
|
|
+ }
|
14668 |
|
|
+ }
|
14669 |
|
|
+ /* not enough registers -> is in the stack */
|
14670 |
|
|
+ else {
|
14671 |
|
|
+ if (OP_LIVETO(result) > ic->seq) {
|
14672 |
|
|
+ for (i = size - 1; i >= 0; i--) {
|
14673 |
|
|
+ if (isOpVolatile(result)) {
|
14674 |
|
|
+ r = getReg(ic);
|
14675 |
|
|
+ lockReg(r);
|
14676 |
|
|
+ popStack(r->rIdx, 0);
|
14677 |
|
|
+ aopPutReg(ic, result, r, i);
|
14678 |
|
|
+ unlockReg(r);
|
14679 |
|
|
+ } else {
|
14680 |
|
|
+ aopGetReg(ic, result, i);
|
14681 |
|
|
+ popStack(OP_SYMBOL(result)->regs[i]->rIdx, 0);
|
14682 |
|
|
+ aopUpdateOpInMem(ic, result, i);
|
14683 |
|
|
+ }
|
14684 |
|
|
+ }
|
14685 |
|
|
+ } else {
|
14686 |
|
|
+ pblaze_emitcode("ADD", "sF, %s", dialectNum(size));
|
14687 |
|
|
+ }
|
14688 |
|
|
+ }
|
14689 |
|
|
+
|
14690 |
|
|
+}
|
14691 |
|
|
+
|
14692 |
|
|
+
|
14693 |
|
|
+
|
14694 |
|
|
+/*-----------------------------------------------------------------*/
|
14695 |
|
|
+/* genDummyRead - generate code for dummy read of volatiles */
|
14696 |
|
|
+/*-----------------------------------------------------------------*/
|
14697 |
|
|
+static void genDummyRead(iCode * ic)
|
14698 |
|
|
+{
|
14699 |
|
|
+ pblaze_emitcode("; genDummyRead", "");
|
14700 |
|
|
+ pblaze_emitcode("; not implemented", "");
|
14701 |
|
|
+
|
14702 |
|
|
+ ic = ic;
|
14703 |
|
|
+}
|
14704 |
|
|
+
|
14705 |
|
|
+/*-----------------------------------------------------------------*/
|
14706 |
|
|
+/* genPBLAZECode - generate code for XILINX PicoBlaze controllers */
|
14707 |
|
|
+/*-----------------------------------------------------------------*/
|
14708 |
|
|
+void genPBLAZECode(iCode * lic)
|
14709 |
|
|
+{
|
14710 |
|
|
+ iCode *ic;
|
14711 |
|
|
+ int cln = 0;
|
14712 |
|
|
+ lineHead = lineCurr = NULL;
|
14713 |
|
|
+ deleteSet(&_G.inOutSet);
|
14714 |
|
|
+
|
14715 |
|
|
+ if (!initGen) {
|
14716 |
|
|
+ _G.rUsedVect = newBitVect(pblaze_nRegs);
|
14717 |
|
|
+ clearBitVect(_G.rUsedVect);
|
14718 |
|
|
+ _G.isCalleSaves = 0;
|
14719 |
|
|
+ _G.onStack = 0;
|
14720 |
|
|
+ _GFunc.mschar = 0;
|
14721 |
|
|
+ _GFunc.muschar = 0;
|
14722 |
|
|
+ _GFunc.mint = 0;
|
14723 |
|
|
+ _GFunc.mlong = 0;
|
14724 |
|
|
+ _GFunc.dschar = 0;
|
14725 |
|
|
+ _GFunc.duschar = 0;
|
14726 |
|
|
+ _GFunc.modschar = 0;
|
14727 |
|
|
+ _GFunc.moduschar = 0;
|
14728 |
|
|
+ _GFunc.dsint = 0;
|
14729 |
|
|
+ _GFunc.dusint = 0;
|
14730 |
|
|
+ _GFunc.modsint = 0;
|
14731 |
|
|
+ _GFunc.modusint = 0;
|
14732 |
|
|
+ _GFunc.dslong = 0;
|
14733 |
|
|
+ _GFunc.duslong = 0;
|
14734 |
|
|
+ _GFunc.modslong = 0;
|
14735 |
|
|
+ _GFunc.moduslong = 0;
|
14736 |
|
|
+ initGen = 1;
|
14737 |
|
|
+ }
|
14738 |
|
|
+
|
14739 |
|
|
+ recvCnt = 0;
|
14740 |
|
|
+
|
14741 |
|
|
+ /* print the allocation information */
|
14742 |
|
|
+ //if (allocInfo && currFunc)
|
14743 |
|
|
+ // printAllocInfo (currFunc, codeOutBuf);
|
14744 |
|
|
+
|
14745 |
|
|
+ /* if debug information required */
|
14746 |
|
|
+ if (options.debug && currFunc) {
|
14747 |
|
|
+ debugFile->writeFunction(currFunc, lic);
|
14748 |
|
|
+ }
|
14749 |
|
|
+
|
14750 |
|
|
+ for (ic = lic; ic; ic = ic->next) {
|
14751 |
|
|
+ if (ic->generated)
|
14752 |
|
|
+ continue;
|
14753 |
|
|
+
|
14754 |
|
|
+ _G.current_iCode = ic;
|
14755 |
|
|
+
|
14756 |
|
|
+ if (ic->lineno && cln != ic->lineno) {
|
14757 |
|
|
+ if (options.debug) {
|
14758 |
|
|
+ debugFile->writeCLine(ic);
|
14759 |
|
|
+ }
|
14760 |
|
|
+ if (!options.noCcodeInAsm) {
|
14761 |
|
|
+ pblaze_emitcode(";", "%s:%d: %s", ic->filename, ic->lineno, printCLine(ic->filename, ic->lineno));
|
14762 |
|
|
+ }
|
14763 |
|
|
+ cln = ic->lineno;
|
14764 |
|
|
+ }
|
14765 |
|
|
+
|
14766 |
|
|
+ if (!(ic->op == CALL || ic->op == SEND)) {
|
14767 |
|
|
+ clearUnusedOpFromReg(ic);
|
14768 |
|
|
+ clearUnusedOpFromMem(ic);
|
14769 |
|
|
+
|
14770 |
|
|
+ }
|
14771 |
|
|
+
|
14772 |
|
|
+ /* depending on the operation */
|
14773 |
|
|
+ switch (ic->op) {
|
14774 |
|
|
+ case '!':
|
14775 |
|
|
+ genNot(ic);
|
14776 |
|
|
+ break;
|
14777 |
|
|
+
|
14778 |
|
|
+ case '~':
|
14779 |
|
|
+ genCpl(ic);
|
14780 |
|
|
+ break;
|
14781 |
|
|
+
|
14782 |
|
|
+ case UNARYMINUS:
|
14783 |
|
|
+ genUminus(ic);
|
14784 |
|
|
+ break;
|
14785 |
|
|
+
|
14786 |
|
|
+ case IPUSH:
|
14787 |
|
|
+ genIpush(ic);
|
14788 |
|
|
+ break;
|
14789 |
|
|
+
|
14790 |
|
|
+ case IPOP:
|
14791 |
|
|
+ genIpop(ic);
|
14792 |
|
|
+ break;
|
14793 |
|
|
+
|
14794 |
|
|
+ case CALL:
|
14795 |
|
|
+ genCall(ic);
|
14796 |
|
|
+ break;
|
14797 |
|
|
+
|
14798 |
|
|
+ case PCALL:
|
14799 |
|
|
+ genPcall(ic);
|
14800 |
|
|
+ break;
|
14801 |
|
|
+
|
14802 |
|
|
+ case FUNCTION:
|
14803 |
|
|
+ genFunction(ic);
|
14804 |
|
|
+ break;
|
14805 |
|
|
+
|
14806 |
|
|
+ case ENDFUNCTION:
|
14807 |
|
|
+ genEndFunction(ic);
|
14808 |
|
|
+ break;
|
14809 |
|
|
+
|
14810 |
|
|
+ case RETURN:
|
14811 |
|
|
+ genRet(ic);
|
14812 |
|
|
+ break;
|
14813 |
|
|
+
|
14814 |
|
|
+ case LABEL:
|
14815 |
|
|
+ genLabel(ic);
|
14816 |
|
|
+ break;
|
14817 |
|
|
+
|
14818 |
|
|
+ case GOTO:
|
14819 |
|
|
+ genGoto(ic);
|
14820 |
|
|
+ break;
|
14821 |
|
|
+
|
14822 |
|
|
+ case '+':
|
14823 |
|
|
+ genPlus(ic);
|
14824 |
|
|
+ break;
|
14825 |
|
|
+
|
14826 |
|
|
+ case '-':
|
14827 |
|
|
+ genMinus(ic);
|
14828 |
|
|
+ break;
|
14829 |
|
|
+
|
14830 |
|
|
+ case '*':
|
14831 |
|
|
+ genMult(ic);
|
14832 |
|
|
+ break;
|
14833 |
|
|
+
|
14834 |
|
|
+ case '/':
|
14835 |
|
|
+ genDiv(ic);
|
14836 |
|
|
+ break;
|
14837 |
|
|
+
|
14838 |
|
|
+ case '%':
|
14839 |
|
|
+ genMod(ic);
|
14840 |
|
|
+ break;
|
14841 |
|
|
+
|
14842 |
|
|
+ case '>':
|
14843 |
|
|
+ genCmpGt(ic, ifxForOp(IC_RESULT(ic), ic));
|
14844 |
|
|
+ break;
|
14845 |
|
|
+
|
14846 |
|
|
+ case '<':
|
14847 |
|
|
+ genCmpLt(ic, ifxForOp(IC_RESULT(ic), ic));
|
14848 |
|
|
+ break;
|
14849 |
|
|
+
|
14850 |
|
|
+ case LE_OP:
|
14851 |
|
|
+ case GE_OP:
|
14852 |
|
|
+ case NE_OP:
|
14853 |
|
|
+ /* note these two are xlated by algebraic equivalence
|
14854 |
|
|
+ in decorateType() in SDCCast.c */
|
14855 |
|
|
+ werror(E_INTERNAL_ERROR, __FILE__, __LINE__, "got '>=' or '<=' shouldn't have come here");
|
14856 |
|
|
+ break;
|
14857 |
|
|
+
|
14858 |
|
|
+ case EQ_OP:
|
14859 |
|
|
+ genCmpEq(ic, ifxForOp(IC_RESULT(ic), ic));
|
14860 |
|
|
+ break;
|
14861 |
|
|
+
|
14862 |
|
|
+ case AND_OP:
|
14863 |
|
|
+ genAndOp(ic);
|
14864 |
|
|
+ break;
|
14865 |
|
|
+
|
14866 |
|
|
+ case OR_OP:
|
14867 |
|
|
+ genOrOp(ic);
|
14868 |
|
|
+ break;
|
14869 |
|
|
+
|
14870 |
|
|
+ case '^':
|
14871 |
|
|
+ genXor(ic, ifxForOp(IC_RESULT(ic), ic));
|
14872 |
|
|
+ break;
|
14873 |
|
|
+
|
14874 |
|
|
+ case '|':
|
14875 |
|
|
+ genOr(ic, ifxForOp(IC_RESULT(ic), ic));
|
14876 |
|
|
+ break;
|
14877 |
|
|
+
|
14878 |
|
|
+ case BITWISEAND:
|
14879 |
|
|
+ genAnd(ic, ifxForOp(IC_RESULT(ic), ic));
|
14880 |
|
|
+ break;
|
14881 |
|
|
+
|
14882 |
|
|
+ case INLINEASM:
|
14883 |
|
|
+ genInline(ic);
|
14884 |
|
|
+ break;
|
14885 |
|
|
+
|
14886 |
|
|
+ case RRC:
|
14887 |
|
|
+ genRRC(ic);
|
14888 |
|
|
+ break;
|
14889 |
|
|
+
|
14890 |
|
|
+ case RLC:
|
14891 |
|
|
+ genRLC(ic);
|
14892 |
|
|
+ break;
|
14893 |
|
|
+
|
14894 |
|
|
+ case GETHBIT:
|
14895 |
|
|
+ genGetHbit(ic);
|
14896 |
|
|
+ break;
|
14897 |
|
|
+
|
14898 |
|
|
+ case LEFT_OP:
|
14899 |
|
|
+ genLeftShift(ic);
|
14900 |
|
|
+ break;
|
14901 |
|
|
+
|
14902 |
|
|
+ case RIGHT_OP:
|
14903 |
|
|
+ genRightShift(ic);
|
14904 |
|
|
+ break;
|
14905 |
|
|
+
|
14906 |
|
|
+ case '=':
|
14907 |
|
|
+ genAssign(ic);
|
14908 |
|
|
+ break;
|
14909 |
|
|
+
|
14910 |
|
|
+ case IFX:
|
14911 |
|
|
+ genIfx(ic, NULL);
|
14912 |
|
|
+ break;
|
14913 |
|
|
+
|
14914 |
|
|
+ case ADDRESS_OF:
|
14915 |
|
|
+ genAddrOf(ic);
|
14916 |
|
|
+ break;
|
14917 |
|
|
+
|
14918 |
|
|
+ case GET_VALUE_AT_ADDRESS:
|
14919 |
|
|
+ genValueAtAddr(ic);
|
14920 |
|
|
+ break;
|
14921 |
|
|
+
|
14922 |
|
|
+ case JUMPTABLE:
|
14923 |
|
|
+ genJumpTab(ic);
|
14924 |
|
|
+ break;
|
14925 |
|
|
+
|
14926 |
|
|
+ case CAST:
|
14927 |
|
|
+ genCast(ic);
|
14928 |
|
|
+ break;
|
14929 |
|
|
+
|
14930 |
|
|
+ case RECEIVE:
|
14931 |
|
|
+ genReceive(ic);
|
14932 |
|
|
+ break;
|
14933 |
|
|
+
|
14934 |
|
|
+ case SEND:
|
14935 |
|
|
+ addSet(&_G.sendSet, ic);
|
14936 |
|
|
+ break;
|
14937 |
|
|
+
|
14938 |
|
|
+ case DUMMY_READ_VOLATILE:
|
14939 |
|
|
+ genDummyRead(ic);
|
14940 |
|
|
+ break;
|
14941 |
|
|
+
|
14942 |
|
|
+ default:
|
14943 |
|
|
+ ic = ic;
|
14944 |
|
|
+ printf("nogen: %d\n", ic->op);
|
14945 |
|
|
+ }
|
14946 |
|
|
+ }
|
14947 |
|
|
+
|
14948 |
|
|
+ //now we are ready to call the peep hole optimizer
|
14949 |
|
|
+ if (!options.nopeep)
|
14950 |
|
|
+ peepHole(&lineHead);
|
14951 |
|
|
+
|
14952 |
|
|
+
|
14953 |
|
|
+ /* now do the actual printing */
|
14954 |
|
|
+ printLine(lineHead, codeOutBuf);
|
14955 |
|
|
+ return;
|
14956 |
|
|
+}
|
14957 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/gen.h sdcc-src-3.1.0-pblaze/src/pblaze/gen.h
|
14958 |
|
|
--- sdcc-src-3.1.0/src/pblaze/gen.h 1970-01-01 01:00:00.000000000 +0100
|
14959 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/gen.h 2011-12-05 23:50:29.120184900 +0100
|
14960 |
|
|
@@ -0,0 +1,139 @@
|
14961 |
|
|
+/*-------------------------------------------------------------------------
|
14962 |
|
|
+gen.h - header file for code generation for XILINX PICOBLAZE
|
14963 |
|
|
+
|
14964 |
|
|
+Author:
|
14965 |
|
|
+ Jakub Hornik, xhorni00<at>stud.fit.vutbr.cz
|
14966 |
|
|
+Master Thesis Project:
|
14967 |
|
|
+ Compiler Back-End of Subset of Language C for 8-Bit Processor
|
14968 |
|
|
+Date:
|
14969 |
|
|
+ 2011
|
14970 |
|
|
+
|
14971 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
14972 |
|
|
+ under the terms of the GNU General Public License as published by the
|
14973 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
14974 |
|
|
+ later version.
|
14975 |
|
|
+
|
14976 |
|
|
+ This program is distributed in the hope that it will be useful,
|
14977 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14978 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14979 |
|
|
+ GNU General Public License for more details.
|
14980 |
|
|
+
|
14981 |
|
|
+ You should have received a copy of the GNU General Public License
|
14982 |
|
|
+ along with this program; if not, write to the Free Software
|
14983 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
14984 |
|
|
+
|
14985 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
14986 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
14987 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
14988 |
|
|
+-------------------------------------------------------------------------*/
|
14989 |
|
|
+
|
14990 |
|
|
+#ifndef SDCCGENPBLAZE_H
|
14991 |
|
|
+#define SDCCGENPBLAZE_H
|
14992 |
|
|
+
|
14993 |
|
|
+#include "main.h"
|
14994 |
|
|
+
|
14995 |
|
|
+#define GLOB_ASSIGN (ic->next == NULL && ic->prev == NULL)
|
14996 |
|
|
+#define IS_OP_GLOBALVOLATILE(x) (IS_OP_GLOBAL( x ) && isOpVolatile( x ))
|
14997 |
|
|
+#define LOCAL_POINTER (!IS_OP_GLOBAL(result) && !isOpVolatile(result) && OP_LIVEFROM(result) == 0 && OP_LIVETO(result) == 0)
|
14998 |
|
|
+#define ASSIGN_OPT(x,y) ( !IS_OP_GLOBAL( y ) && \
|
14999 |
|
|
+ !IS_OP_VOLATILE(x) && !IS_OP_VOLATILE(y) && \
|
15000 |
|
|
+ OP_LIVETO(y) != 0 && ic->seq >= OP_LIVETO(y))
|
15001 |
|
|
+
|
15002 |
|
|
+
|
15003 |
|
|
+#define MULUSCHAR "_muluchar"
|
15004 |
|
|
+#define MULSCHAR "_mulschar"
|
15005 |
|
|
+#define MULINT "_mulint"
|
15006 |
|
|
+#define MULLONG "_mullong"
|
15007 |
|
|
+#define DIVSCHAR "_divschar"
|
15008 |
|
|
+#define DIVUSCHAR "_divuchar"
|
15009 |
|
|
+#define DIVSINT "_divsint"
|
15010 |
|
|
+#define DIVUSINT "_divuint"
|
15011 |
|
|
+#define DIVSLONG "_divslong"
|
15012 |
|
|
+#define DIVUSLONG "_divulong"
|
15013 |
|
|
+#define MODSCHAR "_modschar"
|
15014 |
|
|
+#define MODUSCHAR "_moduchar"
|
15015 |
|
|
+#define MODSINT "_modsint"
|
15016 |
|
|
+#define MODUSINT "_moduint"
|
15017 |
|
|
+#define MODSLONG "_modslong"
|
15018 |
|
|
+#define MODUSLONG "_modulong"
|
15019 |
|
|
+
|
15020 |
|
|
+
|
15021 |
|
|
+enum {
|
15022 |
|
|
+ AOP_LIT = 1,
|
15023 |
|
|
+ AOP_REG, AOP_DIR,
|
15024 |
|
|
+ AOP_STK, AOP_STR
|
15025 |
|
|
+};
|
15026 |
|
|
+
|
15027 |
|
|
+/* type asmop : a homogenised type for
|
15028 |
|
|
+ all the different spaces an operand can be
|
15029 |
|
|
+ in */
|
15030 |
|
|
+typedef struct asmop {
|
15031 |
|
|
+
|
15032 |
|
|
+ short type; /* can have values
|
15033 |
|
|
+ AOP_LIT - operand is a literal value
|
15034 |
|
|
+ AOP_REG - must be loaded into a register
|
15035 |
|
|
+ AOP_DIR - direct just a name
|
15036 |
|
|
+
|
15037 |
|
|
+ */
|
15038 |
|
|
+ short coff; /* current offset */
|
15039 |
|
|
+ short size; /* total size */
|
15040 |
|
|
+ unsigned freed:1; /* already freed */
|
15041 |
|
|
+ union {
|
15042 |
|
|
+ value *aop_lit; /* if literal */
|
15043 |
|
|
+ reg_info *aop_reg[4]; /* array of registers */
|
15044 |
|
|
+ char *aop_dir; /* if direct */
|
15045 |
|
|
+ } aopu;
|
15046 |
|
|
+} asmop;
|
15047 |
|
|
+
|
15048 |
|
|
+
|
15049 |
|
|
+typedef struct inOutStruct {
|
15050 |
|
|
+ char *name; /* IN/OUT operand name */
|
15051 |
|
|
+ operand *tempOper;
|
15052 |
|
|
+ int liveFrom;
|
15053 |
|
|
+ int liveTo;
|
15054 |
|
|
+ short isNumOffset; /* port address given as a number or an operand */
|
15055 |
|
|
+ unsigned long numOffset; /* port address given as a number */
|
15056 |
|
|
+ operand *regOffset; /* port address given as an indirect operand */
|
15057 |
|
|
+} inOutStruct_t;
|
15058 |
|
|
+
|
15059 |
|
|
+void testOp(operand * oper);
|
15060 |
|
|
+
|
15061 |
|
|
+void genPBLAZECode(iCode *);
|
15062 |
|
|
+void pblaze_emitDebuggerSymbol(const char *);
|
15063 |
|
|
+bool pblaze_operandsEqu(operand * op1, operand * op2);
|
15064 |
|
|
+int isOpVolatile(operand * oper);
|
15065 |
|
|
+void setRegUsed(int r);
|
15066 |
|
|
+int isRegUsed(int r);
|
15067 |
|
|
+short isCalleesaves(void);
|
15068 |
|
|
+void pushStack(int rdx, int c);
|
15069 |
|
|
+
|
15070 |
|
|
+void emitStore(char *r, int mem);
|
15071 |
|
|
+void emitStoreReg(char *r, char *adr);
|
15072 |
|
|
+void emitFetch(char *r, int mem);
|
15073 |
|
|
+void emitLoadNumb(char *r, int val);
|
15074 |
|
|
+void emitLoad(char *l, char *r);
|
15075 |
|
|
+void emitcodeADD(char *l, int val);
|
15076 |
|
|
+void emitcodeSUB(char *l, int val);
|
15077 |
|
|
+
|
15078 |
|
|
+int isInOutRef(operand * oper);
|
15079 |
|
|
+void pblaze_emitcodeOutput(iCode * ic, char *source, operand * to);
|
15080 |
|
|
+
|
15081 |
|
|
+void genMulDivFunc(FILE * of);
|
15082 |
|
|
+
|
15083 |
|
|
+void genMultChar(FILE * of);
|
15084 |
|
|
+void genMultUnsignedChar(FILE * of);
|
15085 |
|
|
+void genMultInt(FILE * of);
|
15086 |
|
|
+void genMultLong(FILE * of);
|
15087 |
|
|
+void genDivChar(FILE * of);
|
15088 |
|
|
+void genDivUnsignedChar(FILE * of);
|
15089 |
|
|
+void genModChar(FILE * of);
|
15090 |
|
|
+void genModUnsignedChar(FILE * of);
|
15091 |
|
|
+void genDivInt(FILE * of);
|
15092 |
|
|
+void genDivUnsignedInt(FILE * of);
|
15093 |
|
|
+void genModInt(FILE * of);
|
15094 |
|
|
+void genModUnsignedInt(FILE * of);
|
15095 |
|
|
+void genDivLong(FILE * of);
|
15096 |
|
|
+void genDivUnsignedLong(FILE * of);
|
15097 |
|
|
+void genModLong(FILE * of);
|
15098 |
|
|
+void genModUnsignedLong(FILE * of);
|
15099 |
|
|
+#endif
|
15100 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/genmuldiv.c sdcc-src-3.1.0-pblaze/src/pblaze/genmuldiv.c
|
15101 |
|
|
--- sdcc-src-3.1.0/src/pblaze/genmuldiv.c 1970-01-01 01:00:00.000000000 +0100
|
15102 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/genmuldiv.c 2011-08-23 15:56:30.000000000 +0200
|
15103 |
|
|
@@ -0,0 +1,685 @@
|
15104 |
|
|
+/*-------------------------------------------------------------------------
|
15105 |
|
|
+genmuldiv.c - source file for code generation of MUL/DIV operations for
|
15106 |
|
|
+ XILINX PICOBLAZE
|
15107 |
|
|
+
|
15108 |
|
|
+Author:
|
15109 |
|
|
+ Jakub Hornik, xhorni00<at>stud.fit.vutbr.cz
|
15110 |
|
|
+Master Thesis Project:
|
15111 |
|
|
+ Compiler Back-End of Subset of Language C for 8-Bit Processor
|
15112 |
|
|
+Date:
|
15113 |
|
|
+ 2011
|
15114 |
|
|
+
|
15115 |
|
|
+This program is free software; you can redistribute it and/or modify it
|
15116 |
|
|
+under the terms of the GNU General Public License as published by the
|
15117 |
|
|
+Free Software Foundation; either version 2, or (at your option) any
|
15118 |
|
|
+later version.
|
15119 |
|
|
+
|
15120 |
|
|
+This program is distributed in the hope that it will be useful,
|
15121 |
|
|
+but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15122 |
|
|
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15123 |
|
|
+GNU General Public License for more details.
|
15124 |
|
|
+
|
15125 |
|
|
+You should have received a copy of the GNU General Public License
|
15126 |
|
|
+along with this program; if not, write to the Free Software
|
15127 |
|
|
+Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15128 |
|
|
+
|
15129 |
|
|
+In other words, you are welcome to use, share and improve this program.
|
15130 |
|
|
+You are forbidden to forbid anyone else to use, share and improve
|
15131 |
|
|
+what you give them. Help stamp out software-hoarding!
|
15132 |
|
|
+
|
15133 |
|
|
+-------------------------------------------------------------------------*/
|
15134 |
|
|
+
|
15135 |
|
|
+#define LBL_KEY(x) x->key+10
|
15136 |
|
|
+
|
15137 |
|
|
+#include <stdio.h>
|
15138 |
|
|
+#include <stdlib.h>
|
15139 |
|
|
+#include <string.h>
|
15140 |
|
|
+#include <ctype.h>
|
15141 |
|
|
+#include "SDCCglobl.h"
|
15142 |
|
|
+#include "newalloc.h"
|
15143 |
|
|
+
|
15144 |
|
|
+#include "common.h"
|
15145 |
|
|
+#include "ralloc.h"
|
15146 |
|
|
+#include "main.h"
|
15147 |
|
|
+#include "gen.h"
|
15148 |
|
|
+
|
15149 |
|
|
+
|
15150 |
|
|
+/*-----------------------------------------------------------------*/
|
15151 |
|
|
+/* genMultChar - mult function 1B x 1B -> 2B */
|
15152 |
|
|
+/*-----------------------------------------------------------------*/
|
15153 |
|
|
+void genMultChar(FILE * of)
|
15154 |
|
|
+{
|
15155 |
|
|
+ symbol *lbls1 = newiTempLabel(NULL);
|
15156 |
|
|
+ symbol *lbls2 = newiTempLabel(NULL);
|
15157 |
|
|
+ symbol *lblend = newiTempLabel(NULL);
|
15158 |
|
|
+
|
15159 |
|
|
+ fprintf(of, "\n");
|
15160 |
|
|
+ fprintf(of, "__mulschar:\n");
|
15161 |
|
|
+ fprintf(of, "\tLOAD\tsA, %s00\n", pblaze_options.dialect ? "" : "$");
|
15162 |
|
|
+ fprintf(of, "\tTEST\tsB, %s80\n", pblaze_options.dialect ? "" : "$");
|
15163 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbls1));
|
15164 |
|
|
+ fprintf(of, "\tXOR\tsB, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15165 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15166 |
|
|
+ fprintf(of, "\tLOAD\tsA, %s01\n", pblaze_options.dialect ? "" : "$");
|
15167 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbls1));
|
15168 |
|
|
+ fprintf(of, "\tTEST\tsC, %s80\n", pblaze_options.dialect ? "" : "$");
|
15169 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbls2));
|
15170 |
|
|
+ fprintf(of, "\tXOR\tsC, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15171 |
|
|
+ fprintf(of, "\tADD\tsC, %s01\n", pblaze_options.dialect ? "" : "$");
|
15172 |
|
|
+ fprintf(of, "\tXOR\tsA, %s01\n", pblaze_options.dialect ? "" : "$");
|
15173 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbls2));
|
15174 |
|
|
+ fprintf(of, "\tCALL\t__muluchar\n");
|
15175 |
|
|
+ fprintf(of, "\tTEST\tsA, %s01\n", pblaze_options.dialect ? "" : "$");
|
15176 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lblend));
|
15177 |
|
|
+ fprintf(of, "\tXOR\tsB, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15178 |
|
|
+ fprintf(of, "\tXOR\tsC, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15179 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15180 |
|
|
+ fprintf(of, "\tADDC%s\tsC, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15181 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblend));
|
15182 |
|
|
+ if (pblaze_options.dialect)
|
15183 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15184 |
|
|
+ else
|
15185 |
|
|
+ fprintf(of, "\tRET\n");
|
15186 |
|
|
+}
|
15187 |
|
|
+
|
15188 |
|
|
+
|
15189 |
|
|
+/*-----------------------------------------------------------------*/
|
15190 |
|
|
+/* genMultUnsignedChar - mult function 1B x 1B -> 2B */
|
15191 |
|
|
+/*-----------------------------------------------------------------*/
|
15192 |
|
|
+void genMultUnsignedChar(FILE * of)
|
15193 |
|
|
+{
|
15194 |
|
|
+ symbol *lbladd = newiTempLabel(NULL);
|
15195 |
|
|
+ symbol *lblc = newiTempLabel(NULL);
|
15196 |
|
|
+
|
15197 |
|
|
+ fprintf(of, "\n");
|
15198 |
|
|
+ fprintf(of, "__muluchar:\n");
|
15199 |
|
|
+ fprintf(of, "\tLOAD\tsE, %s08\n", pblaze_options.dialect ? "" : "$");
|
15200 |
|
|
+ fprintf(of, "\tLOAD\tsD, sC\n");
|
15201 |
|
|
+ fprintf(of, "\tLOAD\tsC, %s00\n", pblaze_options.dialect ? "" : "$");
|
15202 |
|
|
+
|
15203 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblc));
|
15204 |
|
|
+ fprintf(of, "\tTEST\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15205 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbladd));
|
15206 |
|
|
+ fprintf(of, "\tADD\tsC, sD\n");
|
15207 |
|
|
+
|
15208 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbladd));
|
15209 |
|
|
+ fprintf(of, "\tSR0\tsC\n");
|
15210 |
|
|
+ fprintf(of, "\tSRA\tsB\n");
|
15211 |
|
|
+ fprintf(of, "\tSUB\tsE, %s01\n", pblaze_options.dialect ? "" : "$");
|
15212 |
|
|
+ fprintf(of, "\tJUMP\tNZ, _LM%04d\n", LBL_KEY(lblc));
|
15213 |
|
|
+ if (pblaze_options.dialect)
|
15214 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15215 |
|
|
+ else
|
15216 |
|
|
+ fprintf(of, "\tRET\n");
|
15217 |
|
|
+}
|
15218 |
|
|
+
|
15219 |
|
|
+
|
15220 |
|
|
+/*-----------------------------------------------------------------*/
|
15221 |
|
|
+/* genMultInt - signed & unsigned 2B x 2B -> 2B */
|
15222 |
|
|
+/*-----------------------------------------------------------------*/
|
15223 |
|
|
+void genMultInt(FILE * of)
|
15224 |
|
|
+{
|
15225 |
|
|
+
|
15226 |
|
|
+ symbol *lbladd = newiTempLabel(NULL);
|
15227 |
|
|
+ symbol *lblc = newiTempLabel(NULL);
|
15228 |
|
|
+
|
15229 |
|
|
+ fprintf(of, "\n");
|
15230 |
|
|
+ fprintf(of, "__mulint:\n");
|
15231 |
|
|
+ fprintf(of, "\tLOAD\ts7, %s10\n", pblaze_options.dialect ? "" : "$");
|
15232 |
|
|
+ fprintf(of, "\tLOAD\ts8, sD\n");
|
15233 |
|
|
+ fprintf(of, "\tLOAD\ts9, sE\n");
|
15234 |
|
|
+ fprintf(of, "\tLOAD\tsD, %s00\n", pblaze_options.dialect ? "" : "$");
|
15235 |
|
|
+ fprintf(of, "\tLOAD\tsE, %s00\n", pblaze_options.dialect ? "" : "$");
|
15236 |
|
|
+
|
15237 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblc));
|
15238 |
|
|
+ fprintf(of, "\tTEST\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15239 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbladd));
|
15240 |
|
|
+ fprintf(of, "\tADD\tsD, s8\n");
|
15241 |
|
|
+ fprintf(of, "\tADDC%s\tsE, s9\n", pblaze_options.dialect ? "Y" : "");
|
15242 |
|
|
+
|
15243 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbladd));
|
15244 |
|
|
+ fprintf(of, "\tSR0\tsE\n");
|
15245 |
|
|
+ fprintf(of, "\tSRA\tsD\n");
|
15246 |
|
|
+ fprintf(of, "\tSRA\tsC\n");
|
15247 |
|
|
+ fprintf(of, "\tSRA\tsB\n");
|
15248 |
|
|
+
|
15249 |
|
|
+ fprintf(of, "\tSUB\ts7, %s01\n", pblaze_options.dialect ? "" : "$");
|
15250 |
|
|
+ fprintf(of, "\tJUMP\tNZ, _LM%04d\n", LBL_KEY(lblc));
|
15251 |
|
|
+ if (pblaze_options.dialect)
|
15252 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15253 |
|
|
+ else
|
15254 |
|
|
+ fprintf(of, "\tRET\n");
|
15255 |
|
|
+}
|
15256 |
|
|
+
|
15257 |
|
|
+
|
15258 |
|
|
+
|
15259 |
|
|
+/*-----------------------------------------------------------------*/
|
15260 |
|
|
+/* genMultLong - signed & unsigned 4B x 4B -> 4B */
|
15261 |
|
|
+/*-----------------------------------------------------------------*/
|
15262 |
|
|
+void genMultLong(FILE * of)
|
15263 |
|
|
+{
|
15264 |
|
|
+ symbol *lbladd = newiTempLabel(NULL);
|
15265 |
|
|
+ symbol *lblc = newiTempLabel(NULL);
|
15266 |
|
|
+
|
15267 |
|
|
+ fprintf(of, "\n");
|
15268 |
|
|
+ fprintf(of, "__mullong:\n");
|
15269 |
|
|
+
|
15270 |
|
|
+ // load multiplicand, multiplier is stored in registers sE..sB
|
15271 |
|
|
+ fprintf(of, "\tADD\tsF, %s01\n", pblaze_options.dialect ? "" : "$");
|
15272 |
|
|
+ fprintf(of, "\tFETCH\ts6, (sF)\n");
|
15273 |
|
|
+ fprintf(of, "\tADD\tsF, %s01\n", pblaze_options.dialect ? "" : "$");
|
15274 |
|
|
+ fprintf(of, "\tFETCH\ts5, (sF)\n");
|
15275 |
|
|
+ fprintf(of, "\tADD\tsF, %s01\n", pblaze_options.dialect ? "" : "$");
|
15276 |
|
|
+ fprintf(of, "\tFETCH\ts4, (sF)\n");
|
15277 |
|
|
+ fprintf(of, "\tADD\tsF, %s01\n", pblaze_options.dialect ? "" : "$");
|
15278 |
|
|
+ fprintf(of, "\tFETCH\ts3, (sF)\n");
|
15279 |
|
|
+
|
15280 |
|
|
+ // 32 cycles
|
15281 |
|
|
+ fprintf(of, "\tLOAD\ts2, %s20\n", pblaze_options.dialect ? "" : "$");
|
15282 |
|
|
+
|
15283 |
|
|
+ // clear upper 4B of the result (but only lower 4B are used as the result)
|
15284 |
|
|
+ fprintf(of, "\tLOAD\tsA, %s00\n", pblaze_options.dialect ? "" : "$");
|
15285 |
|
|
+ fprintf(of, "\tLOAD\ts9, %s00\n", pblaze_options.dialect ? "" : "$");
|
15286 |
|
|
+ fprintf(of, "\tLOAD\ts8, %s00\n", pblaze_options.dialect ? "" : "$");
|
15287 |
|
|
+ fprintf(of, "\tLOAD\ts7, %s00\n", pblaze_options.dialect ? "" : "$");
|
15288 |
|
|
+
|
15289 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblc));
|
15290 |
|
|
+ // add multiplicand to the result if the lowest bit of the multiplier is 1
|
15291 |
|
|
+ fprintf(of, "\tTEST\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15292 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbladd));
|
15293 |
|
|
+ fprintf(of, "\tADD\ts7, s3\n");
|
15294 |
|
|
+ fprintf(of, "\tADDC%s\ts8, s4\n", pblaze_options.dialect ? "Y" : "");
|
15295 |
|
|
+ fprintf(of, "\tADDC%s\ts9, s5\n", pblaze_options.dialect ? "Y" : "");
|
15296 |
|
|
+ fprintf(of, "\tADDC%s\tsA, s6\n", pblaze_options.dialect ? "Y" : "");
|
15297 |
|
|
+
|
15298 |
|
|
+ // result is shifted right
|
15299 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbladd));
|
15300 |
|
|
+ fprintf(of, "\tSR0\tsA\n");
|
15301 |
|
|
+ fprintf(of, "\tSRA\ts9\n");
|
15302 |
|
|
+ fprintf(of, "\tSRA\ts8\n");
|
15303 |
|
|
+ fprintf(of, "\tSRA\ts7\n");
|
15304 |
|
|
+ fprintf(of, "\tSRA\tsE\n");
|
15305 |
|
|
+ fprintf(of, "\tSRA\tsD\n");
|
15306 |
|
|
+ fprintf(of, "\tSRA\tsC\n");
|
15307 |
|
|
+ fprintf(of, "\tSRA\tsB\n");
|
15308 |
|
|
+
|
15309 |
|
|
+ fprintf(of, "\tSUB\ts2, %s01\n", pblaze_options.dialect ? "" : "$");
|
15310 |
|
|
+ fprintf(of, "\tJUMP\tNZ, _LM%04d\n", LBL_KEY(lblc));
|
15311 |
|
|
+ if (pblaze_options.dialect)
|
15312 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15313 |
|
|
+ else
|
15314 |
|
|
+ fprintf(of, "\tRET\n");
|
15315 |
|
|
+}
|
15316 |
|
|
+
|
15317 |
|
|
+/*-----------------------------------------------------------------*/
|
15318 |
|
|
+/* genModChar - function 1B mod 1B -> 1B */
|
15319 |
|
|
+/*-----------------------------------------------------------------*/
|
15320 |
|
|
+void genModChar(FILE * of)
|
15321 |
|
|
+{
|
15322 |
|
|
+
|
15323 |
|
|
+ symbol *lblend = newiTempLabel(NULL);
|
15324 |
|
|
+
|
15325 |
|
|
+ fprintf(of, "\n");
|
15326 |
|
|
+ fprintf(of, "__modschar:\n");
|
15327 |
|
|
+ fprintf(of, "\tCALL\t__divschar\n");
|
15328 |
|
|
+ fprintf(of, "\tTEST\tsA, %s01\n", pblaze_options.dialect ? "" : "$");
|
15329 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lblend));
|
15330 |
|
|
+ fprintf(of, "\tXOR\tsC, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15331 |
|
|
+ fprintf(of, "\tADD\tsC, %s01\n", pblaze_options.dialect ? "" : "$");
|
15332 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblend));
|
15333 |
|
|
+ fprintf(of, "\tXOR\tsB, sC\n");
|
15334 |
|
|
+ fprintf(of, "\tXOR\tsC, sB\n");
|
15335 |
|
|
+ fprintf(of, "\tXOR\tsB, sC\n");
|
15336 |
|
|
+ if (pblaze_options.dialect)
|
15337 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15338 |
|
|
+ else
|
15339 |
|
|
+ fprintf(of, "\tRET\n");
|
15340 |
|
|
+}
|
15341 |
|
|
+
|
15342 |
|
|
+/*-----------------------------------------------------------------*/
|
15343 |
|
|
+/* genModUnsignedChar - mod function 1B / 1B -> 1B */
|
15344 |
|
|
+/*-----------------------------------------------------------------*/
|
15345 |
|
|
+void genModUnsignedChar(FILE * of)
|
15346 |
|
|
+{
|
15347 |
|
|
+
|
15348 |
|
|
+ fprintf(of, "\n");
|
15349 |
|
|
+ fprintf(of, "__moduchar:\n");
|
15350 |
|
|
+ fprintf(of, "__moduschar:\n");
|
15351 |
|
|
+ fprintf(of, "\tCALL\t__divuschar\n");
|
15352 |
|
|
+
|
15353 |
|
|
+ fprintf(of, "\tXOR\tsB, sC\n");
|
15354 |
|
|
+ fprintf(of, "\tXOR\tsC, sB\n");
|
15355 |
|
|
+ fprintf(of, "\tXOR\tsB, sC\n");
|
15356 |
|
|
+ if (pblaze_options.dialect)
|
15357 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15358 |
|
|
+ else
|
15359 |
|
|
+ fprintf(of, "\tRET\n");
|
15360 |
|
|
+}
|
15361 |
|
|
+
|
15362 |
|
|
+/*-----------------------------------------------------------------*/
|
15363 |
|
|
+/* genDivChar - Div function 1B / 1B -> 1B */
|
15364 |
|
|
+/*-----------------------------------------------------------------*/
|
15365 |
|
|
+void genDivChar(FILE * of)
|
15366 |
|
|
+{
|
15367 |
|
|
+
|
15368 |
|
|
+ symbol *lblend = newiTempLabel(NULL);
|
15369 |
|
|
+ symbol *lbls1 = newiTempLabel(NULL);
|
15370 |
|
|
+ symbol *lbls2 = newiTempLabel(NULL);
|
15371 |
|
|
+
|
15372 |
|
|
+ fprintf(of, "\n");
|
15373 |
|
|
+ fprintf(of, "__divschar:\n");
|
15374 |
|
|
+ fprintf(of, "\tLOAD\tsA, %s00\n", pblaze_options.dialect ? "" : "$");
|
15375 |
|
|
+ fprintf(of, "\tTEST\tsB, %s80\n", pblaze_options.dialect ? "" : "$");
|
15376 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbls1));
|
15377 |
|
|
+ fprintf(of, "\tXOR\tsB, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15378 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15379 |
|
|
+ fprintf(of, "\tOR\tsA, %s01\n", pblaze_options.dialect ? "" : "$");
|
15380 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbls1));
|
15381 |
|
|
+ fprintf(of, "\tTEST\tsC, %s80\n", pblaze_options.dialect ? "" : "$");
|
15382 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbls2));
|
15383 |
|
|
+ fprintf(of, "\tXOR\tsC, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15384 |
|
|
+ fprintf(of, "\tADD\tsC, %s01\n", pblaze_options.dialect ? "" : "$");
|
15385 |
|
|
+ fprintf(of, "\tOR\tsA, %s02\n", pblaze_options.dialect ? "" : "$");
|
15386 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbls2));
|
15387 |
|
|
+ fprintf(of, "\tCALL\t__divuchar\n");
|
15388 |
|
|
+ fprintf(of, "\tTEST\tsA, %s03\n", pblaze_options.dialect ? "" : "$");
|
15389 |
|
|
+ fprintf(of, "\tJUMP\tNC, _LM%04d\n", LBL_KEY(lblend));
|
15390 |
|
|
+ fprintf(of, "\tXOR\tsB, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15391 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15392 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblend));
|
15393 |
|
|
+ if (pblaze_options.dialect)
|
15394 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15395 |
|
|
+ else
|
15396 |
|
|
+ fprintf(of, "\tRET\n");
|
15397 |
|
|
+}
|
15398 |
|
|
+
|
15399 |
|
|
+/*-----------------------------------------------------------------*/
|
15400 |
|
|
+/* genDivUnsignedChar - mDiv function 1B / 1B -> 1B */
|
15401 |
|
|
+/*-----------------------------------------------------------------*/
|
15402 |
|
|
+void genDivUnsignedChar(FILE * of)
|
15403 |
|
|
+{
|
15404 |
|
|
+ symbol *lblc = newiTempLabel(NULL);
|
15405 |
|
|
+ symbol *lbladd = newiTempLabel(NULL);
|
15406 |
|
|
+
|
15407 |
|
|
+ fprintf(of, "\n");
|
15408 |
|
|
+ fprintf(of, "__divuchar:\n");
|
15409 |
|
|
+ fprintf(of, "\tLOAD\tsE, %s08\n", pblaze_options.dialect ? "" : "$");
|
15410 |
|
|
+ fprintf(of, "\tLOAD\tsD, sC\n");
|
15411 |
|
|
+ fprintf(of, "\tLOAD\tsC, %s00\n", pblaze_options.dialect ? "" : "$");
|
15412 |
|
|
+
|
15413 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblc));
|
15414 |
|
|
+ fprintf(of, "\tSL0\tsB\n");
|
15415 |
|
|
+ fprintf(of, "\tSLA\tsC\n");
|
15416 |
|
|
+ fprintf(of, "\tCOMP%s\tsC, sD\n", pblaze_options.dialect ? "ARE" : "");
|
15417 |
|
|
+ fprintf(of, "\tJUMP\tC, _LM%04d\n", LBL_KEY(lbladd));
|
15418 |
|
|
+ fprintf(of, "\tSUB\tsC, sD\n");
|
15419 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15420 |
|
|
+
|
15421 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbladd));
|
15422 |
|
|
+
|
15423 |
|
|
+ fprintf(of, "\tSUB\tsE, %s01\n", pblaze_options.dialect ? "" : "$");
|
15424 |
|
|
+ fprintf(of, "\tJUMP\tNZ, _LM%04d\n", LBL_KEY(lblc));
|
15425 |
|
|
+ if (pblaze_options.dialect)
|
15426 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15427 |
|
|
+ else
|
15428 |
|
|
+ fprintf(of, "\tRET\n");
|
15429 |
|
|
+}
|
15430 |
|
|
+
|
15431 |
|
|
+
|
15432 |
|
|
+/*-----------------------------------------------------------------*/
|
15433 |
|
|
+/* genModInt */
|
15434 |
|
|
+/*-----------------------------------------------------------------*/
|
15435 |
|
|
+void genModInt(FILE * of)
|
15436 |
|
|
+{
|
15437 |
|
|
+
|
15438 |
|
|
+ symbol *lblend = newiTempLabel(NULL);
|
15439 |
|
|
+
|
15440 |
|
|
+ fprintf(of, "\n");
|
15441 |
|
|
+ fprintf(of, "__modsint:\n");
|
15442 |
|
|
+ fprintf(of, "\tCALL\t__divsint\n");
|
15443 |
|
|
+ fprintf(of, "\tTEST\tsA, %s01\n", pblaze_options.dialect ? "" : "$");
|
15444 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lblend));
|
15445 |
|
|
+ fprintf(of, "\tXOR\tsD, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15446 |
|
|
+ fprintf(of, "\tXOR\tsE, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15447 |
|
|
+ fprintf(of, "\tADD\tsD, %s01\n", pblaze_options.dialect ? "" : "$");
|
15448 |
|
|
+ fprintf(of, "\tADDC%s\tsE, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15449 |
|
|
+
|
15450 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblend));
|
15451 |
|
|
+ fprintf(of, "\tXOR\tsB, sD\n");
|
15452 |
|
|
+ fprintf(of, "\tXOR\tsD, sB\n");
|
15453 |
|
|
+ fprintf(of, "\tXOR\tsB, sD\n");
|
15454 |
|
|
+
|
15455 |
|
|
+ fprintf(of, "\tXOR\tsE, sC\n");
|
15456 |
|
|
+ fprintf(of, "\tXOR\tsC, sE\n");
|
15457 |
|
|
+ fprintf(of, "\tXOR\tsE, sC\n");
|
15458 |
|
|
+ if (pblaze_options.dialect)
|
15459 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15460 |
|
|
+ else
|
15461 |
|
|
+ fprintf(of, "\tRET\n");
|
15462 |
|
|
+}
|
15463 |
|
|
+
|
15464 |
|
|
+/*-----------------------------------------------------------------*/
|
15465 |
|
|
+/* genModUnsignedInt */
|
15466 |
|
|
+/*-----------------------------------------------------------------*/
|
15467 |
|
|
+void genModUnsignedInt(FILE * of)
|
15468 |
|
|
+{
|
15469 |
|
|
+
|
15470 |
|
|
+ fprintf(of, "\n");
|
15471 |
|
|
+ fprintf(of, "__moduint:\n");
|
15472 |
|
|
+ fprintf(of, "\tCALL\t__divuint\n");
|
15473 |
|
|
+
|
15474 |
|
|
+ fprintf(of, "\tXOR\tsB, sD\n");
|
15475 |
|
|
+ fprintf(of, "\tXOR\tsD, sB\n");
|
15476 |
|
|
+ fprintf(of, "\tXOR\tsB, sD\n");
|
15477 |
|
|
+
|
15478 |
|
|
+ fprintf(of, "\tXOR\tsE, sC\n");
|
15479 |
|
|
+ fprintf(of, "\tXOR\tsC, sE\n");
|
15480 |
|
|
+ fprintf(of, "\tXOR\tsE, sC\n");
|
15481 |
|
|
+
|
15482 |
|
|
+ if (pblaze_options.dialect)
|
15483 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15484 |
|
|
+ else
|
15485 |
|
|
+ fprintf(of, "\tRET\n");
|
15486 |
|
|
+}
|
15487 |
|
|
+
|
15488 |
|
|
+/*-----------------------------------------------------------------*/
|
15489 |
|
|
+/* genDivInt */
|
15490 |
|
|
+/*-----------------------------------------------------------------*/
|
15491 |
|
|
+void genDivInt(FILE * of)
|
15492 |
|
|
+{
|
15493 |
|
|
+
|
15494 |
|
|
+ symbol *lblend = newiTempLabel(NULL);
|
15495 |
|
|
+ symbol *lbls1 = newiTempLabel(NULL);
|
15496 |
|
|
+ symbol *lbls2 = newiTempLabel(NULL);
|
15497 |
|
|
+
|
15498 |
|
|
+ fprintf(of, "\n");
|
15499 |
|
|
+ fprintf(of, "__divsint:\n");
|
15500 |
|
|
+ fprintf(of, "\tLOAD\tsA, %s00\n", pblaze_options.dialect ? "" : "$");
|
15501 |
|
|
+ fprintf(of, "\tTEST\tsC, %s80\n", pblaze_options.dialect ? "" : "$");
|
15502 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbls1));
|
15503 |
|
|
+ fprintf(of, "\tXOR\tsB, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15504 |
|
|
+ fprintf(of, "\tXOR\tsC, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15505 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15506 |
|
|
+ fprintf(of, "\tADDC%s\tsC, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15507 |
|
|
+ fprintf(of, "\tOR\tsA, %s01\n", pblaze_options.dialect ? "" : "$");
|
15508 |
|
|
+
|
15509 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbls1));
|
15510 |
|
|
+ fprintf(of, "\tTEST\tsE, %s80\n", pblaze_options.dialect ? "" : "$");
|
15511 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbls2));
|
15512 |
|
|
+ fprintf(of, "\tXOR\tsD, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15513 |
|
|
+ fprintf(of, "\tXOR\tsE, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15514 |
|
|
+ fprintf(of, "\tADD\tsD, %s01\n", pblaze_options.dialect ? "" : "$");
|
15515 |
|
|
+ fprintf(of, "\tADDC%s\tsE, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15516 |
|
|
+ fprintf(of, "\tOR\tsA, %s02\n", pblaze_options.dialect ? "" : "$");
|
15517 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbls2));
|
15518 |
|
|
+ fprintf(of, "\tCALL\t__divuint\n");
|
15519 |
|
|
+ fprintf(of, "\tTEST\tsA, %s03\n", pblaze_options.dialect ? "" : "$");
|
15520 |
|
|
+ fprintf(of, "\tJUMP\tNC, _LM%04d\n", LBL_KEY(lblend));
|
15521 |
|
|
+ fprintf(of, "\tXOR\tsB, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15522 |
|
|
+ fprintf(of, "\tXOR\tsC, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15523 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15524 |
|
|
+ fprintf(of, "\tADDC%s\tsC, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15525 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblend));
|
15526 |
|
|
+ if (pblaze_options.dialect)
|
15527 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15528 |
|
|
+ else
|
15529 |
|
|
+ fprintf(of, "\tRET\n");
|
15530 |
|
|
+}
|
15531 |
|
|
+
|
15532 |
|
|
+/*-----------------------------------------------------------------*/
|
15533 |
|
|
+/* genDivUnsignedInt */
|
15534 |
|
|
+/*-----------------------------------------------------------------*/
|
15535 |
|
|
+void genDivUnsignedInt(FILE * of)
|
15536 |
|
|
+{
|
15537 |
|
|
+ symbol *lblc = newiTempLabel(NULL);
|
15538 |
|
|
+ symbol *lbladd = newiTempLabel(NULL);
|
15539 |
|
|
+
|
15540 |
|
|
+ fprintf(of, "\n");
|
15541 |
|
|
+ fprintf(of, "__divuint:\n");
|
15542 |
|
|
+ fprintf(of, "\tLOAD\ts7, %s10\n", pblaze_options.dialect ? "" : "$");
|
15543 |
|
|
+ fprintf(of, "\tLOAD\ts8, sD\n");
|
15544 |
|
|
+ fprintf(of, "\tLOAD\ts9, sE\n");
|
15545 |
|
|
+ fprintf(of, "\tLOAD\tsD, %s00\n", pblaze_options.dialect ? "" : "$");
|
15546 |
|
|
+ fprintf(of, "\tLOAD\tsE, %s00\n", pblaze_options.dialect ? "" : "$");
|
15547 |
|
|
+
|
15548 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblc));
|
15549 |
|
|
+ fprintf(of, "\tSL0\tsB\n");
|
15550 |
|
|
+ fprintf(of, "\tSLA\tsC\n");
|
15551 |
|
|
+ fprintf(of, "\tSLA\tsD\n");
|
15552 |
|
|
+ fprintf(of, "\tSLA\tsE\n");
|
15553 |
|
|
+
|
15554 |
|
|
+ fprintf(of, "\tCOMP%s\tsE, s9\n", pblaze_options.dialect ? "ARE" : "");
|
15555 |
|
|
+ fprintf(of, "\tJUMP\tC, _LM%04d\n", LBL_KEY(lbladd));
|
15556 |
|
|
+ fprintf(of, "\tCOMP%s\tsD, s8\n", pblaze_options.dialect ? "ARE" : "");
|
15557 |
|
|
+ fprintf(of, "\tJUMP\tC, _LM%04d\n", LBL_KEY(lbladd));
|
15558 |
|
|
+
|
15559 |
|
|
+ fprintf(of, "\tSUB\tsD, s8\n");
|
15560 |
|
|
+ fprintf(of, "\tSUBC%s\tsE, s9\n", pblaze_options.dialect ? "Y" : "");
|
15561 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15562 |
|
|
+
|
15563 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbladd));
|
15564 |
|
|
+
|
15565 |
|
|
+ fprintf(of, "\tSUB\ts7, %s01\n", pblaze_options.dialect ? "" : "$");
|
15566 |
|
|
+ fprintf(of, "\tJUMP\tNZ, _LM%04d\n", LBL_KEY(lblc));
|
15567 |
|
|
+ if (pblaze_options.dialect)
|
15568 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15569 |
|
|
+ else
|
15570 |
|
|
+ fprintf(of, "\tRET\n");
|
15571 |
|
|
+}
|
15572 |
|
|
+
|
15573 |
|
|
+/*-----------------------------------------------------------------*/
|
15574 |
|
|
+/* genDivUnsignedLong - signed & unsigned 4B x 4B -> 4B */
|
15575 |
|
|
+/*-----------------------------------------------------------------*/
|
15576 |
|
|
+void genDivUnsignedLong(FILE * of)
|
15577 |
|
|
+{
|
15578 |
|
|
+ symbol *lbladd = newiTempLabel(NULL);
|
15579 |
|
|
+ symbol *lbldo = newiTempLabel(NULL);
|
15580 |
|
|
+ symbol *lblc = newiTempLabel(NULL);
|
15581 |
|
|
+
|
15582 |
|
|
+ fprintf(of, "\n");
|
15583 |
|
|
+ fprintf(of, "__divulong:\n");
|
15584 |
|
|
+
|
15585 |
|
|
+ fprintf(of, "\tCALL\t__divuslongload\n");
|
15586 |
|
|
+ fprintf(of, "\tCALL\t__divuslongdiv\n");
|
15587 |
|
|
+ if (pblaze_options.dialect)
|
15588 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15589 |
|
|
+ else
|
15590 |
|
|
+ fprintf(of, "\tRET\n");
|
15591 |
|
|
+
|
15592 |
|
|
+ fprintf(of, "__divuslongdiv:\n");
|
15593 |
|
|
+ // 32 cycles
|
15594 |
|
|
+ fprintf(of, "\tLOAD\ts2, %s20\n", pblaze_options.dialect ? "" : "$");
|
15595 |
|
|
+
|
15596 |
|
|
+ // clear upper 4B of the result (but only lower 4B are used as the result)
|
15597 |
|
|
+ fprintf(of, "\tLOAD\tsA, %s00\n", pblaze_options.dialect ? "" : "$");
|
15598 |
|
|
+ fprintf(of, "\tLOAD\ts9, %s00\n", pblaze_options.dialect ? "" : "$");
|
15599 |
|
|
+ fprintf(of, "\tLOAD\ts8, %s00\n", pblaze_options.dialect ? "" : "$");
|
15600 |
|
|
+ fprintf(of, "\tLOAD\ts7, %s00\n", pblaze_options.dialect ? "" : "$");
|
15601 |
|
|
+
|
15602 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblc));
|
15603 |
|
|
+ // result is shifted left
|
15604 |
|
|
+ fprintf(of, "\tSL0\tsB\n");
|
15605 |
|
|
+ fprintf(of, "\tSLA\tsC\n");
|
15606 |
|
|
+ fprintf(of, "\tSLA\tsD\n");
|
15607 |
|
|
+ fprintf(of, "\tSLA\tsE\n");
|
15608 |
|
|
+ fprintf(of, "\tSLA\ts7\n");
|
15609 |
|
|
+ fprintf(of, "\tSLA\ts8\n");
|
15610 |
|
|
+ fprintf(of, "\tSLA\ts9\n");
|
15611 |
|
|
+ fprintf(of, "\tSLA\tsA\n");
|
15612 |
|
|
+
|
15613 |
|
|
+ fprintf(of, "\tCOMP%s\tsA, s6\n", pblaze_options.dialect ? "ARE" : "");
|
15614 |
|
|
+ fprintf(of, "\tJUMP\tC, _LM%04d\n", LBL_KEY(lbladd));
|
15615 |
|
|
+ fprintf(of, "\tJUMP\tNZ, _LM%04d\n", LBL_KEY(lbldo));
|
15616 |
|
|
+ fprintf(of, "\tCOMP%s\ts9, s5\n", pblaze_options.dialect ? "ARE" : "");
|
15617 |
|
|
+ fprintf(of, "\tJUMP\tC, _LM%04d\n", LBL_KEY(lbladd));
|
15618 |
|
|
+ fprintf(of, "\tJUMP\tNZ, _LM%04d\n", LBL_KEY(lbldo));
|
15619 |
|
|
+ fprintf(of, "\tCOMP%s\ts8, s4\n", pblaze_options.dialect ? "ARE" : "");
|
15620 |
|
|
+ fprintf(of, "\tJUMP\tC, _LM%04d\n", LBL_KEY(lbladd));
|
15621 |
|
|
+ fprintf(of, "\tJUMP\tNZ, _LM%04d\n", LBL_KEY(lbldo));
|
15622 |
|
|
+ fprintf(of, "\tCOMP%s\ts7, s3\n", pblaze_options.dialect ? "ARE" : "");
|
15623 |
|
|
+ fprintf(of, "\tJUMP\tC, _LM%04d\n", LBL_KEY(lbladd));
|
15624 |
|
|
+
|
15625 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbldo));
|
15626 |
|
|
+ fprintf(of, "\tSUB\ts7, s3\n");
|
15627 |
|
|
+ fprintf(of, "\tSUBC%s\ts8, s4\n", pblaze_options.dialect ? "Y" : "");
|
15628 |
|
|
+ fprintf(of, "\tSUBC%s\ts9, s5\n", pblaze_options.dialect ? "Y" : "");
|
15629 |
|
|
+ fprintf(of, "\tSUBC%s\tsA, s6\n", pblaze_options.dialect ? "Y" : "");
|
15630 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15631 |
|
|
+
|
15632 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbladd));
|
15633 |
|
|
+
|
15634 |
|
|
+ fprintf(of, "\tSUB\ts2, %s01\n", pblaze_options.dialect ? "" : "$");
|
15635 |
|
|
+ fprintf(of, "\tJUMP\tNZ, _LM%04d\n", LBL_KEY(lblc));
|
15636 |
|
|
+ if (pblaze_options.dialect)
|
15637 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15638 |
|
|
+ else
|
15639 |
|
|
+ fprintf(of, "\tRET\n");
|
15640 |
|
|
+
|
15641 |
|
|
+ fprintf(of, "__divuslongload:\n");
|
15642 |
|
|
+ // load divisor, divident is stored in registers sE..sB
|
15643 |
|
|
+ fprintf(of, "\tADD\tsF, %s01\n", pblaze_options.dialect ? "" : "$");
|
15644 |
|
|
+ fprintf(of, "\tFETCH\ts6, (sF)\n");
|
15645 |
|
|
+ fprintf(of, "\tADD\tsF, %s01\n", pblaze_options.dialect ? "" : "$");
|
15646 |
|
|
+ fprintf(of, "\tFETCH\ts5, (sF)\n");
|
15647 |
|
|
+ fprintf(of, "\tADD\tsF, %s01\n", pblaze_options.dialect ? "" : "$");
|
15648 |
|
|
+ fprintf(of, "\tFETCH\ts4, (sF)\n");
|
15649 |
|
|
+ fprintf(of, "\tADD\tsF, %s01\n", pblaze_options.dialect ? "" : "$");
|
15650 |
|
|
+ fprintf(of, "\tFETCH\ts3, (sF)\n");
|
15651 |
|
|
+ if (pblaze_options.dialect)
|
15652 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15653 |
|
|
+ else
|
15654 |
|
|
+ fprintf(of, "\tRET\n");
|
15655 |
|
|
+}
|
15656 |
|
|
+
|
15657 |
|
|
+/*-----------------------------------------------------------------*/
|
15658 |
|
|
+/* genDivLong - */
|
15659 |
|
|
+/*-----------------------------------------------------------------*/
|
15660 |
|
|
+void genDivLong(FILE * of)
|
15661 |
|
|
+{
|
15662 |
|
|
+
|
15663 |
|
|
+ symbol *lblend = newiTempLabel(NULL);
|
15664 |
|
|
+ symbol *lbls1 = newiTempLabel(NULL);
|
15665 |
|
|
+ symbol *lbls2 = newiTempLabel(NULL);
|
15666 |
|
|
+
|
15667 |
|
|
+ fprintf(of, "\n");
|
15668 |
|
|
+ fprintf(of, "__divslong:\n");
|
15669 |
|
|
+ fprintf(of, "\tCALL\t__divuslongload\n");
|
15670 |
|
|
+ fprintf(of, "\tLOAD\tsA, %s00\n", pblaze_options.dialect ? "" : "$");
|
15671 |
|
|
+ fprintf(of, "\tTEST\tsC, %s80\n", pblaze_options.dialect ? "" : "$");
|
15672 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbls1));
|
15673 |
|
|
+ fprintf(of, "\tXOR\tsB, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15674 |
|
|
+ fprintf(of, "\tXOR\tsC, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15675 |
|
|
+ fprintf(of, "\tXOR\tsD, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15676 |
|
|
+ fprintf(of, "\tXOR\tsE, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15677 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15678 |
|
|
+ fprintf(of, "\tADDC%s\tsC, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15679 |
|
|
+ fprintf(of, "\tADDC%s\tsD, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15680 |
|
|
+ fprintf(of, "\tADDC%s\tsE, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15681 |
|
|
+ fprintf(of, "\tOR\tsA, %s01\n", pblaze_options.dialect ? "" : "$");
|
15682 |
|
|
+
|
15683 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbls1));
|
15684 |
|
|
+ fprintf(of, "\tTEST\tsE, %s80\n", pblaze_options.dialect ? "" : "$");
|
15685 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lbls2));
|
15686 |
|
|
+ fprintf(of, "\tXOR\ts3, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15687 |
|
|
+ fprintf(of, "\tXOR\ts4, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15688 |
|
|
+ fprintf(of, "\tXOR\ts5, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15689 |
|
|
+ fprintf(of, "\tXOR\ts6, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15690 |
|
|
+ fprintf(of, "\tADD\ts3, %s01\n", pblaze_options.dialect ? "" : "$");
|
15691 |
|
|
+ fprintf(of, "\tADDC%s\ts4, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15692 |
|
|
+ fprintf(of, "\tADDC%s\ts5, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15693 |
|
|
+ fprintf(of, "\tADDC%s\ts6, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15694 |
|
|
+ fprintf(of, "\tOR\tsA, %s02\n", pblaze_options.dialect ? "" : "$");
|
15695 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lbls2));
|
15696 |
|
|
+ fprintf(of, "\tCALL\t__divuslongdiv\n");
|
15697 |
|
|
+ fprintf(of, "\tTEST\tsA, %s03\n", pblaze_options.dialect ? "" : "$");
|
15698 |
|
|
+ fprintf(of, "\tJUMP\tNC, _LM%04d\n", LBL_KEY(lblend));
|
15699 |
|
|
+ fprintf(of, "\tXOR\tsB, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15700 |
|
|
+ fprintf(of, "\tXOR\tsC, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15701 |
|
|
+ fprintf(of, "\tXOR\tsD, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15702 |
|
|
+ fprintf(of, "\tXOR\tsE, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15703 |
|
|
+ fprintf(of, "\tADD\tsB, %s01\n", pblaze_options.dialect ? "" : "$");
|
15704 |
|
|
+ fprintf(of, "\tADDC%s\tsC, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15705 |
|
|
+ fprintf(of, "\tADDC%s\tsD, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15706 |
|
|
+ fprintf(of, "\tADDC%s\tsE, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15707 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblend));
|
15708 |
|
|
+ if (pblaze_options.dialect)
|
15709 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15710 |
|
|
+ else
|
15711 |
|
|
+ fprintf(of, "\tRET\n");
|
15712 |
|
|
+}
|
15713 |
|
|
+
|
15714 |
|
|
+/*-----------------------------------------------------------------*/
|
15715 |
|
|
+/* genModLong - mod function 4B / 4B -> 4B */
|
15716 |
|
|
+/*-----------------------------------------------------------------*/
|
15717 |
|
|
+void genModLong(FILE * of)
|
15718 |
|
|
+{
|
15719 |
|
|
+
|
15720 |
|
|
+ symbol *lblend = newiTempLabel(NULL);
|
15721 |
|
|
+
|
15722 |
|
|
+ fprintf(of, "\n");
|
15723 |
|
|
+ fprintf(of, "__modslong:\n");
|
15724 |
|
|
+ fprintf(of, "\tCALL\t__divslong\n");
|
15725 |
|
|
+ fprintf(of, "\tTEST\tsA, %s01\n", pblaze_options.dialect ? "" : "$");
|
15726 |
|
|
+ fprintf(of, "\tJUMP\tZ, _LM%04d\n", LBL_KEY(lblend));
|
15727 |
|
|
+ fprintf(of, "\tXOR\ts7, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15728 |
|
|
+ fprintf(of, "\tXOR\ts8, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15729 |
|
|
+ fprintf(of, "\tXOR\ts9, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15730 |
|
|
+ fprintf(of, "\tXOR\tsA, %sFF\n", pblaze_options.dialect ? "" : "$");
|
15731 |
|
|
+ fprintf(of, "\tADD\ts7, %s01\n", pblaze_options.dialect ? "" : "$");
|
15732 |
|
|
+ fprintf(of, "\tADDC%s\ts8, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15733 |
|
|
+ fprintf(of, "\tADDC%s\ts9, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15734 |
|
|
+ fprintf(of, "\tADDC%s\tsA, %s00\n", pblaze_options.dialect ? "Y" : "", pblaze_options.dialect ? "" : "$");
|
15735 |
|
|
+
|
15736 |
|
|
+ fprintf(of, "_LM%04d:\n", LBL_KEY(lblend));
|
15737 |
|
|
+ fprintf(of, "\tXOR\tsB, s7\n");
|
15738 |
|
|
+ fprintf(of, "\tXOR\ts7, sB\n");
|
15739 |
|
|
+ fprintf(of, "\tXOR\tsB, s7\n");
|
15740 |
|
|
+
|
15741 |
|
|
+ fprintf(of, "\tXOR\ts8, sC\n");
|
15742 |
|
|
+ fprintf(of, "\tXOR\tsC, s8\n");
|
15743 |
|
|
+ fprintf(of, "\tXOR\ts8, sC\n");
|
15744 |
|
|
+
|
15745 |
|
|
+ fprintf(of, "\tXOR\tsD, s9\n");
|
15746 |
|
|
+ fprintf(of, "\tXOR\ts9, sD\n");
|
15747 |
|
|
+ fprintf(of, "\tXOR\tsD, s9\n");
|
15748 |
|
|
+
|
15749 |
|
|
+ fprintf(of, "\tXOR\tsE, sA\n");
|
15750 |
|
|
+ fprintf(of, "\tXOR\tsA, sE\n");
|
15751 |
|
|
+ fprintf(of, "\tXOR\tsE, sA\n");
|
15752 |
|
|
+ if (pblaze_options.dialect)
|
15753 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15754 |
|
|
+ else
|
15755 |
|
|
+ fprintf(of, "\tRET\n");
|
15756 |
|
|
+}
|
15757 |
|
|
+
|
15758 |
|
|
+/*-----------------------------------------------------------------*/
|
15759 |
|
|
+/* genModUnsignedLong - mod function 4B / 4B -> 4B */
|
15760 |
|
|
+/*-----------------------------------------------------------------*/
|
15761 |
|
|
+void genModUnsignedLong(FILE * of)
|
15762 |
|
|
+{
|
15763 |
|
|
+
|
15764 |
|
|
+ fprintf(of, "\n");
|
15765 |
|
|
+ fprintf(of, "__modulong:\n");
|
15766 |
|
|
+ fprintf(of, "\tCALL\t__divulong\n");
|
15767 |
|
|
+
|
15768 |
|
|
+ fprintf(of, "\tXOR\tsB, s7\n");
|
15769 |
|
|
+ fprintf(of, "\tXOR\ts7, sB\n");
|
15770 |
|
|
+ fprintf(of, "\tXOR\tsB, s7\n");
|
15771 |
|
|
+
|
15772 |
|
|
+ fprintf(of, "\tXOR\ts8, sC\n");
|
15773 |
|
|
+ fprintf(of, "\tXOR\tsC, s8\n");
|
15774 |
|
|
+ fprintf(of, "\tXOR\ts8, sC\n");
|
15775 |
|
|
+
|
15776 |
|
|
+ fprintf(of, "\tXOR\tsD, s9\n");
|
15777 |
|
|
+ fprintf(of, "\tXOR\ts9, sD\n");
|
15778 |
|
|
+ fprintf(of, "\tXOR\tsD, s9\n");
|
15779 |
|
|
+
|
15780 |
|
|
+ fprintf(of, "\tXOR\tsE, sA\n");
|
15781 |
|
|
+ fprintf(of, "\tXOR\tsA, sE\n");
|
15782 |
|
|
+ fprintf(of, "\tXOR\tsE, sA\n");
|
15783 |
|
|
+
|
15784 |
|
|
+ if (pblaze_options.dialect)
|
15785 |
|
|
+ fprintf(of, "\tRETURN\n");
|
15786 |
|
|
+ else
|
15787 |
|
|
+ fprintf(of, "\tRET\n");
|
15788 |
|
|
+}
|
15789 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/main.c sdcc-src-3.1.0-pblaze/src/pblaze/main.c
|
15790 |
|
|
--- sdcc-src-3.1.0/src/pblaze/main.c 1970-01-01 01:00:00.000000000 +0100
|
15791 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/main.c 2011-12-06 01:42:51.714771500 +0100
|
15792 |
|
|
@@ -0,0 +1,355 @@
|
15793 |
|
|
+/** @file main.c
|
15794 |
|
|
+ pblaze specific general functions.
|
15795 |
|
|
+
|
15796 |
|
|
+ Author:
|
15797 |
|
|
+ Jakub Hornik, xhorni00<at>stud.fit.vutbr.cz
|
15798 |
|
|
+ Master Thesis Project:
|
15799 |
|
|
+ Compiler Back-End of Subset of Language C for 8-Bit Processor
|
15800 |
|
|
+ Date:
|
15801 |
|
|
+ 2011
|
15802 |
|
|
+
|
15803 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
15804 |
|
|
+ under the terms of the GNU General Public License as published by the
|
15805 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
15806 |
|
|
+ later version.
|
15807 |
|
|
+
|
15808 |
|
|
+ This program is distributed in the hope that it will be useful,
|
15809 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15810 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15811 |
|
|
+ GNU General Public License for more details.
|
15812 |
|
|
+
|
15813 |
|
|
+ You should have received a copy of the GNU General Public License
|
15814 |
|
|
+ along with this program; if not, write to the Free Software
|
15815 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15816 |
|
|
+
|
15817 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
15818 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
15819 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
15820 |
|
|
+-------------------------------------------------------------------------*/
|
15821 |
|
|
+
|
15822 |
|
|
+#include "common.h"
|
15823 |
|
|
+#include "main.h"
|
15824 |
|
|
+#include "ralloc.h"
|
15825 |
|
|
+#include "gen.h"
|
15826 |
|
|
+#include "ralloc.h"
|
15827 |
|
|
+#include "pbglue.h"
|
15828 |
|
|
+#include "dbuf_string.h"
|
15829 |
|
|
+
|
15830 |
|
|
+static char _defaultRules[] = {
|
15831 |
|
|
+#include "peeph.rul"
|
15832 |
|
|
+};
|
15833 |
|
|
+
|
15834 |
|
|
+#define DIALECT_OPT "--dialect="
|
15835 |
|
|
+#define PORTKW_OPT "--portkw="
|
15836 |
|
|
+#define ACKNOWLEDGEMENT_OPT "--acknowledgement"
|
15837 |
|
|
+
|
15838 |
|
|
+pblaze_options_t pblaze_options;
|
15839 |
|
|
+
|
15840 |
|
|
+OPTION pblaze_optionsTable[] = {
|
15841 |
|
|
+ {0, DIALECT_OPT, &pblaze_options.dialect,
|
15842 |
|
|
+ "(kcpsm3 or pblazeide) selects the assembler dialect for the chosen target platform (see argument --target) as there are some minor differences between the PicoBlaze-3 Assembler for HDL/HEX production (KCPSM3) and for the simulation (pBlazeIDE). (Default: pblazeide)"},
|
15843 |
|
|
+ {0, PORTKW_OPT, &pblaze_options.portKw,
|
15844 |
|
|
+ "set proper keyword used for INPUT/OUTPUT operations (default: PBLAZEPORT)"},
|
15845 |
|
|
+ {0, ACKNOWLEDGEMENT_OPT, NULL,
|
15846 |
|
|
+ "The development of this pblaze-port was supported by the Czech Ministry of Education, Youth and Sports grant 2C06008 Virtual Laboratory of Microprocessor Technology Application (visit the website http://www.vlam.cz)."},
|
15847 |
|
|
+ {0, NULL, NULL, NULL}
|
15848 |
|
|
+};
|
15849 |
|
|
+
|
15850 |
|
|
+/* list of key words used by msc51 */
|
15851 |
|
|
+static char *_pblaze_keywords[] = {
|
15852 |
|
|
+ "at",
|
15853 |
|
|
+ "code",
|
15854 |
|
|
+ "critical",
|
15855 |
|
|
+ "interrupt",
|
15856 |
|
|
+ "xdata",
|
15857 |
|
|
+ "_code",
|
15858 |
|
|
+ "_generic",
|
15859 |
|
|
+ "_xdata",
|
15860 |
|
|
+ "_NECO",
|
15861 |
|
|
+ NULL
|
15862 |
|
|
+};
|
15863 |
|
|
+
|
15864 |
|
|
+static int regParmFlg = 0; /* determine if we can register a parameter */
|
15865 |
|
|
+
|
15866 |
|
|
+static void _pblaze_init(void)
|
15867 |
|
|
+{
|
15868 |
|
|
+ asm_addTree(&asm_asxxxx_mapping);
|
15869 |
|
|
+}
|
15870 |
|
|
+
|
15871 |
|
|
+static void _pblaze_reset_regparm(void)
|
15872 |
|
|
+{
|
15873 |
|
|
+ regParmFlg = 0;
|
15874 |
|
|
+}
|
15875 |
|
|
+
|
15876 |
|
|
+
|
15877 |
|
|
+void _pblaze_genInitStartup(FILE * of)
|
15878 |
|
|
+{
|
15879 |
|
|
+ printConstants(of);
|
15880 |
|
|
+}
|
15881 |
|
|
+
|
15882 |
|
|
+
|
15883 |
|
|
+static int _pblaze_regparm(sym_link * l, bool reentrant)
|
15884 |
|
|
+{
|
15885 |
|
|
+ /* we won't split variables
|
15886 |
|
|
+ i.e. if not enough registers left to hold
|
15887 |
|
|
+ the parameter then the whole parameter along
|
15888 |
|
|
+ with rest of the parameters go onto the stack */
|
15889 |
|
|
+ if (regParmFlg < SEND_REG_COUNT) {
|
15890 |
|
|
+ int size;
|
15891 |
|
|
+ if ((size = getSize(l)) > (SEND_REG_COUNT - regParmFlg)) {
|
15892 |
|
|
+ /* all remaining go on stack */
|
15893 |
|
|
+ regParmFlg = SEND_REG_COUNT;
|
15894 |
|
|
+ return 0;
|
15895 |
|
|
+ }
|
15896 |
|
|
+ regParmFlg += size;
|
15897 |
|
|
+ return 1;
|
15898 |
|
|
+ }
|
15899 |
|
|
+
|
15900 |
|
|
+ return 0;
|
15901 |
|
|
+}
|
15902 |
|
|
+
|
15903 |
|
|
+void pblaze_assignRegisters(ebbIndex *);
|
15904 |
|
|
+
|
15905 |
|
|
+#define ISOPT(str) !strncmp(argv[ *i ], str, strlen(str) )
|
15906 |
|
|
+
|
15907 |
|
|
+static bool _pblaze_parseOptions(int *pargc, char **argv, int *i)
|
15908 |
|
|
+{
|
15909 |
|
|
+ char *dialecttype;
|
15910 |
|
|
+
|
15911 |
|
|
+ if (ISOPT(DIALECT_OPT)) {
|
15912 |
|
|
+ dialecttype = getStringArg(DIALECT_OPT, argv, i, *pargc);
|
15913 |
|
|
+ if (!STRCASECMP(dialecttype, "pblazeide"))
|
15914 |
|
|
+ pblaze_options.dialect = 0;
|
15915 |
|
|
+ else if (!STRCASECMP(dialecttype, "kcpsm3"))
|
15916 |
|
|
+ pblaze_options.dialect = 1;
|
15917 |
|
|
+ else {
|
15918 |
|
|
+ fprintf(stderr, "Unknown dialect type: %s\nAvaiable options: pblazeide or kcpsm3\n", dialecttype);
|
15919 |
|
|
+ exit(EXIT_FAILURE);
|
15920 |
|
|
+ }
|
15921 |
|
|
+ return TRUE;
|
15922 |
|
|
+ }
|
15923 |
|
|
+
|
15924 |
|
|
+ if (ISOPT(PORTKW_OPT)) {
|
15925 |
|
|
+ pblaze_options.portKw = Safe_strdup(getStringArg(PORTKW_OPT, argv, i, *pargc));
|
15926 |
|
|
+ return TRUE;
|
15927 |
|
|
+ }
|
15928 |
|
|
+
|
15929 |
|
|
+ if (ISOPT(ACKNOWLEDGEMENT_OPT)) {
|
15930 |
|
|
+ fprintf(stderr, "The development of this pblaze-port was supported by the Czech Ministry of Education, Youth and Sports grant 2C06008 Virtual Laboratory of Microprocessor Technology Application (visit the website http://www.vlam.cz).");
|
15931 |
|
|
+ exit(EXIT_FAILURE);
|
15932 |
|
|
+ return TRUE;
|
15933 |
|
|
+ }
|
15934 |
|
|
+
|
15935 |
|
|
+ return FALSE;
|
15936 |
|
|
+}
|
15937 |
|
|
+
|
15938 |
|
|
+
|
15939 |
|
|
+static void _pblaze_finaliseOptions(void)
|
15940 |
|
|
+{
|
15941 |
|
|
+ port->mem.default_local_map = port->mem.default_globl_map = data;
|
15942 |
|
|
+ /* change stack to be in far space */
|
15943 |
|
|
+ /* internal stack segment ;
|
15944 |
|
|
+ SFRSPACE - NO
|
15945 |
|
|
+ FAR-SPACE - YES
|
15946 |
|
|
+ PAGED - NO
|
15947 |
|
|
+ DIRECT-ACCESS - NO
|
15948 |
|
|
+ BIT-ACCESS - NO
|
15949 |
|
|
+ CODE-ACESS - NO
|
15950 |
|
|
+ DEBUG-NAME - 'B'
|
15951 |
|
|
+ POINTER-TYPE - FPOINTER
|
15952 |
|
|
+ */
|
15953 |
|
|
+ istack = allocMap(0, 1, 0, 0, 0, 0, options.stack_loc, ISTACK_NAME, 'B', FPOINTER);
|
15954 |
|
|
+
|
15955 |
|
|
+ /* also change xdata to be direct space since we can use lds/sts */
|
15956 |
|
|
+ xdata->direct = 1;
|
15957 |
|
|
+
|
15958 |
|
|
+}
|
15959 |
|
|
+
|
15960 |
|
|
+static void _pblaze_setDefaultOptions(void)
|
15961 |
|
|
+{
|
15962 |
|
|
+ pblaze_options.dialect = 1;
|
15963 |
|
|
+ pblaze_options.portKw = "PBLAZEPORT";
|
15964 |
|
|
+ options.stackAuto = 1;
|
15965 |
|
|
+}
|
15966 |
|
|
+
|
15967 |
|
|
+static const char *_pblaze_getRegName(struct reg_info *reg)
|
15968 |
|
|
+{
|
15969 |
|
|
+ if (reg)
|
15970 |
|
|
+ return reg->name;
|
15971 |
|
|
+ return "err";
|
15972 |
|
|
+}
|
15973 |
|
|
+
|
15974 |
|
|
+static void _pblaze_genAssemblerPreamble(FILE * of)
|
15975 |
|
|
+{
|
15976 |
|
|
+
|
15977 |
|
|
+}
|
15978 |
|
|
+
|
15979 |
|
|
+static void _pblaze_genAssemblerEnd(FILE * of)
|
15980 |
|
|
+{
|
15981 |
|
|
+ genMulDivFunc(of);
|
15982 |
|
|
+}
|
15983 |
|
|
+
|
15984 |
|
|
+/* Generate interrupt vector table. */
|
15985 |
|
|
+static int _pblaze_genIVT(struct dbuf_s *oBuf, symbol ** interrupts, int maxInterrupts)
|
15986 |
|
|
+{
|
15987 |
|
|
+ if (pblaze_interrupt) {
|
15988 |
|
|
+ if (pblaze_options.dialect) {
|
15989 |
|
|
+ dbuf_printf(oBuf, "\tADDRESS\t3ff\n");
|
15990 |
|
|
+ } else {
|
15991 |
|
|
+ dbuf_printf(oBuf, "\tORG\t$3ff\n");
|
15992 |
|
|
+ }
|
15993 |
|
|
+ dbuf_printf(oBuf, "\tJUMP\t_%s\n", pblaze_interrupt->name);
|
15994 |
|
|
+ }
|
15995 |
|
|
+
|
15996 |
|
|
+ return TRUE;
|
15997 |
|
|
+}
|
15998 |
|
|
+
|
15999 |
|
|
+/* Indicate which extended bit operations this port supports */
|
16000 |
|
|
+static bool hasExtBitOp(int op, int size)
|
16001 |
|
|
+{
|
16002 |
|
|
+ if (op == RRC || op == RLC || op == GETHBIT)
|
16003 |
|
|
+ return TRUE;
|
16004 |
|
|
+ else
|
16005 |
|
|
+ return FALSE;
|
16006 |
|
|
+}
|
16007 |
|
|
+
|
16008 |
|
|
+/* Indicate the expense of an access to an output storage class */
|
16009 |
|
|
+static int oclsExpense(struct memmap *oclass)
|
16010 |
|
|
+{
|
16011 |
|
|
+ if (IN_FARSPACE(oclass))
|
16012 |
|
|
+ return 1;
|
16013 |
|
|
+
|
16014 |
|
|
+ return 0;
|
16015 |
|
|
+}
|
16016 |
|
|
+
|
16017 |
|
|
+/** $1 is always the basename.
|
16018 |
|
|
+ $2 is always the output file.
|
16019 |
|
|
+ $3 varies
|
16020 |
|
|
+ $l is the list of extra options that should be there somewhere...
|
16021 |
|
|
+ MUST be terminated with a NULL.
|
16022 |
|
|
+*/
|
16023 |
|
|
+static const char *_linkCmd[] = {
|
16024 |
|
|
+ "linkpblaze", "", "\"$1\"", NULL
|
16025 |
|
|
+};
|
16026 |
|
|
+
|
16027 |
|
|
+/* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
|
16028 |
|
|
+static const char *_asmCmd[] = {
|
16029 |
|
|
+ "aspblaze", "$l", "$3", "\"$1.s\"", NULL
|
16030 |
|
|
+};
|
16031 |
|
|
+
|
16032 |
|
|
+/* Globals */
|
16033 |
|
|
+PORT pblaze_port = {
|
16034 |
|
|
+ TARGET_ID_PBLAZE,
|
16035 |
|
|
+ "pblaze",
|
16036 |
|
|
+ "XILINX PicoBlaze", /* Target name */
|
16037 |
|
|
+ NULL, /* processor */
|
16038 |
|
|
+ {
|
16039 |
|
|
+ pblaze_glue,
|
16040 |
|
|
+ TRUE, /* Emit glue around main */
|
16041 |
|
|
+ MODEL_SMALL,
|
16042 |
|
|
+ MODEL_SMALL,
|
16043 |
|
|
+ NULL, /* model == target */
|
16044 |
|
|
+ },
|
16045 |
|
|
+ {
|
16046 |
|
|
+ _asmCmd,
|
16047 |
|
|
+ NULL,
|
16048 |
|
|
+ "-plosgff", /* Options with debug */
|
16049 |
|
|
+ "-plosgff", /* Options without debug */
|
16050 |
|
|
+ 0,
|
16051 |
|
|
+ ".psm",
|
16052 |
|
|
+ NULL, /* no do_assemble */
|
16053 |
|
|
+ },
|
16054 |
|
|
+ {
|
16055 |
|
|
+ _linkCmd,
|
16056 |
|
|
+ NULL,
|
16057 |
|
|
+ NULL,
|
16058 |
|
|
+ ".rel",
|
16059 |
|
|
+ 1},
|
16060 |
|
|
+ {
|
16061 |
|
|
+ _defaultRules},
|
16062 |
|
|
+ {
|
16063 |
|
|
+ /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
|
16064 |
|
|
+ 1, 2, 2, 4, 1, 1, 1, 1, 0, 4},
|
16065 |
|
|
+
|
16066 |
|
|
+ /* tags for generic pointers */
|
16067 |
|
|
+ {0x00, 0x40, 0x60, 0x80}, /* far, near, xstack, code */
|
16068 |
|
|
+
|
16069 |
|
|
+ {
|
16070 |
|
|
+ "XSEG",
|
16071 |
|
|
+ "STACK",
|
16072 |
|
|
+ "CSEG",
|
16073 |
|
|
+ "DSEG",
|
16074 |
|
|
+ "ISEG",
|
16075 |
|
|
+ NULL, //PSEG
|
16076 |
|
|
+ "XSEG",
|
16077 |
|
|
+ "BSEG",
|
16078 |
|
|
+ "RSEG",
|
16079 |
|
|
+ "GSINIT",
|
16080 |
|
|
+ "OSEG",
|
16081 |
|
|
+ "GSFINAL",
|
16082 |
|
|
+ "HOME",
|
16083 |
|
|
+ NULL, // initialized xdata
|
16084 |
|
|
+ NULL, // a code copy of xiseg
|
16085 |
|
|
+ "CONST (CODE)", // const_name - const data (code or not)
|
16086 |
|
|
+ "CABS (ABS,CODE)", // cabs_name - const absolute data (code or not)
|
16087 |
|
|
+ "XABS (ABS,XDATA)", // xabs_name - absolute xdata/pdata
|
16088 |
|
|
+ "IABS (ABS,DATA)", // iabs_name - absolute idata/data
|
16089 |
|
|
+ NULL,
|
16090 |
|
|
+ NULL,
|
16091 |
|
|
+ 0,
|
16092 |
|
|
+ },
|
16093 |
|
|
+ {NULL, NULL},
|
16094 |
|
|
+ {
|
16095 |
|
|
+ -1, 1, 4, 1, 1, 0},
|
16096 |
|
|
+ /* pblaze hasn't any mul */
|
16097 |
|
|
+ {
|
16098 |
|
|
+ 0, -1},
|
16099 |
|
|
+ {
|
16100 |
|
|
+ pblaze_emitDebuggerSymbol},
|
16101 |
|
|
+ {
|
16102 |
|
|
+ 32, /* maxCount */
|
16103 |
|
|
+ 2, /* sizeofElement */
|
16104 |
|
|
+ /* the behavior of src/SDCCicode.c 1.207 and earlier. */
|
16105 |
|
|
+ {2, 2, 2}, /* sizeofMatchJump[] */
|
16106 |
|
|
+ {0, 0, 0}, /* sizeofRangeCompare[] */
|
16107 |
|
|
+ 0, /* sizeofSubtract */
|
16108 |
|
|
+ 2, /* sizeofDispatch */
|
16109 |
|
|
+ },
|
16110 |
|
|
+ "_",
|
16111 |
|
|
+ _pblaze_init,
|
16112 |
|
|
+ _pblaze_parseOptions,
|
16113 |
|
|
+ pblaze_optionsTable,
|
16114 |
|
|
+ NULL,
|
16115 |
|
|
+ _pblaze_finaliseOptions,
|
16116 |
|
|
+ _pblaze_setDefaultOptions,
|
16117 |
|
|
+ pblaze_assignRegisters,
|
16118 |
|
|
+ _pblaze_getRegName,
|
16119 |
|
|
+ _pblaze_keywords,
|
16120 |
|
|
+ _pblaze_genAssemblerPreamble,
|
16121 |
|
|
+ _pblaze_genAssemblerEnd, /* no genAssemblerEnd */
|
16122 |
|
|
+ _pblaze_genIVT,
|
16123 |
|
|
+ NULL, // _pblaze_genXINIT
|
16124 |
|
|
+ _pblaze_genInitStartup, /* genInitStartup */
|
16125 |
|
|
+ _pblaze_reset_regparm,
|
16126 |
|
|
+ _pblaze_regparm,
|
16127 |
|
|
+ NULL,
|
16128 |
|
|
+ NULL,
|
16129 |
|
|
+ NULL,
|
16130 |
|
|
+ hasExtBitOp, /* hasExtBitOp */
|
16131 |
|
|
+ oclsExpense, /* oclsExpense */
|
16132 |
|
|
+ FALSE,
|
16133 |
|
|
+ TRUE, /* little endian */
|
16134 |
|
|
+ 0, /* leave lt */
|
16135 |
|
|
+ 0, /* leave gt */
|
16136 |
|
|
+ 1, /* transform <= to ! > */
|
16137 |
|
|
+ 1, /* transform >= to ! < */
|
16138 |
|
|
+ 1, /* transform != to !(a == b) */
|
16139 |
|
|
+ 0, /* leave == */
|
16140 |
|
|
+ FALSE, /* No array initializer support. */
|
16141 |
|
|
+ 0, /* no CSE cost estimation yet */
|
16142 |
|
|
+ NULL, /* no builtin functions */
|
16143 |
|
|
+ GPOINTER, /* treat unqualified pointers as "generic" pointers */
|
16144 |
|
|
+ 0, /* reset labelKey to 1 */
|
16145 |
|
|
+ 1, /* globals & local static allowed */
|
16146 |
|
|
+ PORT_MAGIC
|
16147 |
|
|
+};
|
16148 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/main.h sdcc-src-3.1.0-pblaze/src/pblaze/main.h
|
16149 |
|
|
--- sdcc-src-3.1.0/src/pblaze/main.h 1970-01-01 01:00:00.000000000 +0100
|
16150 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/main.h 2011-08-23 15:56:30.000000000 +0200
|
16151 |
|
|
@@ -0,0 +1,45 @@
|
16152 |
|
|
+/*-------------------------------------------------------------------------
|
16153 |
|
|
+main.h - header file for XILINX PICOBLAZE
|
16154 |
|
|
+
|
16155 |
|
|
+Author:
|
16156 |
|
|
+ Jakub Hornik, xhorni00<at>stud.fit.vutbr.cz
|
16157 |
|
|
+Master Thesis Project:
|
16158 |
|
|
+ Compiler Back-End of Subset of Language C for 8-Bit Processor
|
16159 |
|
|
+Date:
|
16160 |
|
|
+ 2011
|
16161 |
|
|
+
|
16162 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
16163 |
|
|
+ under the terms of the GNU General Public License as published by the
|
16164 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
16165 |
|
|
+ later version.
|
16166 |
|
|
+
|
16167 |
|
|
+ This program is distributed in the hope that it will be useful,
|
16168 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16169 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16170 |
|
|
+ GNU General Public License for more details.
|
16171 |
|
|
+
|
16172 |
|
|
+ You should have received a copy of the GNU General Public License
|
16173 |
|
|
+ along with this program; if not, write to the Free Software
|
16174 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16175 |
|
|
+
|
16176 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
16177 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
16178 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
16179 |
|
|
+-------------------------------------------------------------------------*/
|
16180 |
|
|
+
|
16181 |
|
|
+#ifndef MAIN_INCLUDE
|
16182 |
|
|
+#define MAIN_INCLUDE
|
16183 |
|
|
+
|
16184 |
|
|
+bool x_parseOptions(char **argv, int *pargc);
|
16185 |
|
|
+void x_setDefaultOptions(void);
|
16186 |
|
|
+void x_finaliseOptions(void);
|
16187 |
|
|
+
|
16188 |
|
|
+typedef struct {
|
16189 |
|
|
+ int dialect;
|
16190 |
|
|
+ char *portKw;
|
16191 |
|
|
+} pblaze_options_t;
|
16192 |
|
|
+
|
16193 |
|
|
+symbol *pblaze_interrupt;
|
16194 |
|
|
+extern pblaze_options_t pblaze_options;
|
16195 |
|
|
+
|
16196 |
|
|
+#endif
|
16197 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/pbglue.c sdcc-src-3.1.0-pblaze/src/pblaze/pbglue.c
|
16198 |
|
|
--- sdcc-src-3.1.0/src/pblaze/pbglue.c 1970-01-01 01:00:00.000000000 +0100
|
16199 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/pbglue.c 2011-08-23 15:56:30.000000000 +0200
|
16200 |
|
|
@@ -0,0 +1,677 @@
|
16201 |
|
|
+/*-------------------------------------------------------------------------
|
16202 |
|
|
+ pbglue.c - glues everything we have done together into one file.
|
16203 |
|
|
+ Written By:
|
16204 |
|
|
+ Sandeep Dutta . sandeep.dutta@usa.net (1998)
|
16205 |
|
|
+ &&
|
16206 |
|
|
+ Jakub Hornik, xhorni00<at>stud.fit.vutbr.cz
|
16207 |
|
|
+ Master Thesis Project:
|
16208 |
|
|
+ Compiler Back-End of Subset of Language C for 8-Bit Processor
|
16209 |
|
|
+ Date:
|
16210 |
|
|
+ 2011
|
16211 |
|
|
+
|
16212 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
16213 |
|
|
+ under the terms of the GNU General Public License as published by the
|
16214 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
16215 |
|
|
+ later version.
|
16216 |
|
|
+
|
16217 |
|
|
+ This program is distributed in the hope that it will be useful,
|
16218 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16219 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16220 |
|
|
+ GNU General Public License for more details.
|
16221 |
|
|
+
|
16222 |
|
|
+ You should have received a copy of the GNU General Public License
|
16223 |
|
|
+ along with this program; if not, write to the Free Software
|
16224 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16225 |
|
|
+
|
16226 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
16227 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
16228 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
16229 |
|
|
+-------------------------------------------------------------------------*/
|
16230 |
|
|
+
|
16231 |
|
|
+#include "pbglue.h"
|
16232 |
|
|
+#include "main.h"
|
16233 |
|
|
+#include "ralloc.h"
|
16234 |
|
|
+
|
16235 |
|
|
+#include <time.h>
|
16236 |
|
|
+//#include "newalloc.h"
|
16237 |
|
|
+#include <fcntl.h>
|
16238 |
|
|
+#include <sys/stat.h>
|
16239 |
|
|
+#include "dbuf_string.h"
|
16240 |
|
|
+
|
16241 |
|
|
+#ifdef _WIN32
|
16242 |
|
|
+#include <io.h>
|
16243 |
|
|
+#else
|
16244 |
|
|
+#include <unistd.h>
|
16245 |
|
|
+#endif
|
16246 |
|
|
+
|
16247 |
|
|
+symbol *interrupts[INTNO_MAX + 1];
|
16248 |
|
|
+
|
16249 |
|
|
+void printIval(symbol *, sym_link *, initList *, struct dbuf_s *, bool check);
|
16250 |
|
|
+set *pblaze_publics = NULL; /* public variables */
|
16251 |
|
|
+set *pblaze_externs = NULL; /* Variables that are declared as extern */
|
16252 |
|
|
+
|
16253 |
|
|
+//unsigned maxInterrupts = 0;
|
16254 |
|
|
+int pblaze_allocInfo = 1;
|
16255 |
|
|
+symbol *pblaze_mainf;
|
16256 |
|
|
+int pblaze_noInit = 0; /* no initialization */
|
16257 |
|
|
+
|
16258 |
|
|
+
|
16259 |
|
|
+/*-----------------------------------------------------------------*/
|
16260 |
|
|
+/* pblaze_emitDebugSym - emit label for debug symbol */
|
16261 |
|
|
+/*-----------------------------------------------------------------*/
|
16262 |
|
|
+static void pblaze_emitDebugSym(struct dbuf_s *oBuf, symbol * sym)
|
16263 |
|
|
+{
|
16264 |
|
|
+ if (!sym->level) { /* global */
|
16265 |
|
|
+ if (IS_STATIC(sym->etype))
|
16266 |
|
|
+ dbuf_printf(oBuf, "F%s$", moduleName); /* scope is file */
|
16267 |
|
|
+ else
|
16268 |
|
|
+ dbuf_printf(oBuf, "G$"); /* scope is global */
|
16269 |
|
|
+ } else {
|
16270 |
|
|
+ /* symbol is local */
|
16271 |
|
|
+ dbuf_printf(oBuf, "L%s$", (sym->localof ? sym->localof->name : "-null-"));
|
16272 |
|
|
+ }
|
16273 |
|
|
+ dbuf_printf(oBuf, "%s$%d$%d", sym->name, sym->level, sym->block);
|
16274 |
|
|
+}
|
16275 |
|
|
+
|
16276 |
|
|
+
|
16277 |
|
|
+/*-----------------------------------------------------------------*/
|
16278 |
|
|
+/* pblaze_printChar - formats and prints a characater string with DB */
|
16279 |
|
|
+/*-----------------------------------------------------------------*/
|
16280 |
|
|
+void pblaze_printChar(struct dbuf_s *oBuf, char *s, int plen)
|
16281 |
|
|
+{
|
16282 |
|
|
+ int i;
|
16283 |
|
|
+ int len = plen;
|
16284 |
|
|
+ int pplen = 0;
|
16285 |
|
|
+ char buf[100];
|
16286 |
|
|
+ char *p = buf;
|
16287 |
|
|
+
|
16288 |
|
|
+ while (len && pplen < plen) {
|
16289 |
|
|
+ i = 60;
|
16290 |
|
|
+ while (i && pplen < plen) {
|
16291 |
|
|
+ if (*s < ' ' || *s == '\"' || *s == '\\') {
|
16292 |
|
|
+ *p = '\0';
|
16293 |
|
|
+ if (p != buf)
|
16294 |
|
|
+ dbuf_tprintf(oBuf, "\t!ascii\n", buf);
|
16295 |
|
|
+ dbuf_tprintf(oBuf, "\t!db !constbyte\n", (unsigned char) *s);
|
16296 |
|
|
+ p = buf;
|
16297 |
|
|
+ } else {
|
16298 |
|
|
+ *p = *s;
|
16299 |
|
|
+ p++;
|
16300 |
|
|
+ }
|
16301 |
|
|
+ s++;
|
16302 |
|
|
+ pplen++;
|
16303 |
|
|
+ i--;
|
16304 |
|
|
+ }
|
16305 |
|
|
+ if (p != buf) {
|
16306 |
|
|
+ *p = '\0';
|
16307 |
|
|
+ dbuf_tprintf(oBuf, "\t!ascii\n", buf);
|
16308 |
|
|
+ p = buf;
|
16309 |
|
|
+ }
|
16310 |
|
|
+
|
16311 |
|
|
+ if (len > 60)
|
16312 |
|
|
+ len -= 60;
|
16313 |
|
|
+ else
|
16314 |
|
|
+ len = 0;
|
16315 |
|
|
+ }
|
16316 |
|
|
+ while (pplen < plen) {
|
16317 |
|
|
+ dbuf_tprintf(oBuf, "\t!db !constbyte\n", 0);
|
16318 |
|
|
+ pplen++;
|
16319 |
|
|
+ }
|
16320 |
|
|
+}
|
16321 |
|
|
+
|
16322 |
|
|
+/*-----------------------------------------------------------------*/
|
16323 |
|
|
+/* pblaze_emitRegularMap - emit code for maps with no special cases */
|
16324 |
|
|
+/*-----------------------------------------------------------------*/
|
16325 |
|
|
+static void pblaze_emitRegularMap(memmap * map, bool addPublics, bool arFlag)
|
16326 |
|
|
+{
|
16327 |
|
|
+ symbol *sym;
|
16328 |
|
|
+ ast *ival = NULL;
|
16329 |
|
|
+
|
16330 |
|
|
+ if (!map)
|
16331 |
|
|
+ return;
|
16332 |
|
|
+
|
16333 |
|
|
+ if (addPublics) {
|
16334 |
|
|
+
|
16335 |
|
|
+ if (map->regsp)
|
16336 |
|
|
+ dbuf_tprintf(&map->oBuf, "\t!org\n", 0);
|
16337 |
|
|
+ }
|
16338 |
|
|
+
|
16339 |
|
|
+ for (sym = setFirstItem(map->syms); sym; sym = setNextItem(map->syms)) {
|
16340 |
|
|
+ symbol *newSym = NULL;
|
16341 |
|
|
+
|
16342 |
|
|
+ /* if extern then add it into the extern list */
|
16343 |
|
|
+ if (IS_EXTERN(sym->etype)) {
|
16344 |
|
|
+ addSetHead(&pblaze_externs, sym);
|
16345 |
|
|
+ continue;
|
16346 |
|
|
+ }
|
16347 |
|
|
+
|
16348 |
|
|
+ /* if allocation required check is needed
|
16349 |
|
|
+ then check if the symbol really requires
|
16350 |
|
|
+ allocation only for local variables */
|
16351 |
|
|
+
|
16352 |
|
|
+ if (arFlag && !IS_AGGREGATE(sym->type) && !(sym->_isparm && !IS_REGPARM(sym->etype)) && !sym->allocreq && sym->level)
|
16353 |
|
|
+ continue;
|
16354 |
|
|
+
|
16355 |
|
|
+ /* for bitvar locals and parameters */
|
16356 |
|
|
+ if (!arFlag && !sym->allocreq && sym->level && !SPEC_ABSA(sym->etype)) {
|
16357 |
|
|
+ continue;
|
16358 |
|
|
+ }
|
16359 |
|
|
+
|
16360 |
|
|
+ /* if global variable & not static or extern
|
16361 |
|
|
+ and addPublics allowed then add it to the public set */
|
16362 |
|
|
+ if ((sym->level == 0 ||
|
16363 |
|
|
+ (sym->_isparm && !IS_REGPARM(sym->etype))) &&
|
16364 |
|
|
+ addPublics && !IS_STATIC(sym->etype) && (IS_FUNC(sym->type) ? (sym->used || IFFUNC_HASBODY(sym->type)) : 1)) {
|
16365 |
|
|
+ addSetHead(&pblaze_publics, sym);
|
16366 |
|
|
+ }
|
16367 |
|
|
+
|
16368 |
|
|
+ /* if extern then do nothing or is a function
|
16369 |
|
|
+ then do nothing */
|
16370 |
|
|
+ if (IS_FUNC(sym->type) && !(sym->isitmp))
|
16371 |
|
|
+ continue;
|
16372 |
|
|
+
|
16373 |
|
|
+ /* if it has an initial value then do it only if
|
16374 |
|
|
+ it is a global variable */
|
16375 |
|
|
+ if (sym->ival && sym->level == 0) {
|
16376 |
|
|
+ if ((SPEC_OCLS(sym->etype) == xidata) && !SPEC_ABSA(sym->etype)) {
|
16377 |
|
|
+ sym_link *t;
|
16378 |
|
|
+ /* create a new "XINIT (CODE)" symbol, that will be emited later
|
16379 |
|
|
+ in the static seg */
|
16380 |
|
|
+ newSym = copySymbol(sym);
|
16381 |
|
|
+ SPEC_OCLS(newSym->etype) = xinit;
|
16382 |
|
|
+ SNPRINTF(newSym->name, sizeof(newSym->name), "__xinit_%s", sym->name);
|
16383 |
|
|
+ SNPRINTF(newSym->rname, sizeof(newSym->rname), "__xinit_%s", sym->rname);
|
16384 |
|
|
+ /* find the first non-array link */
|
16385 |
|
|
+ t = newSym->type;
|
16386 |
|
|
+ while (IS_ARRAY(t))
|
16387 |
|
|
+ t = t->next;
|
16388 |
|
|
+ if (IS_SPEC(t))
|
16389 |
|
|
+ SPEC_CONST(t) = 1;
|
16390 |
|
|
+ else
|
16391 |
|
|
+ DCL_PTR_CONST(t) = 1;
|
16392 |
|
|
+ SPEC_STAT(newSym->etype) = 1;
|
16393 |
|
|
+ resolveIvalSym(newSym->ival, newSym->type);
|
16394 |
|
|
+
|
16395 |
|
|
+ // add it to the "XINIT (CODE)" segment
|
16396 |
|
|
+ addSet(&xinit->syms, newSym);
|
16397 |
|
|
+
|
16398 |
|
|
+ if (!SPEC_ABSA(sym->etype)) {
|
16399 |
|
|
+ struct dbuf_s tmpBuf;
|
16400 |
|
|
+
|
16401 |
|
|
+ dbuf_init(&tmpBuf, 4096);
|
16402 |
|
|
+ // before allocation we must parse the sym->ival tree
|
16403 |
|
|
+ // but without actually generating initialization code
|
16404 |
|
|
+ ++noAlloc;
|
16405 |
|
|
+ resolveIvalSym(sym->ival, sym->type);
|
16406 |
|
|
+ ++pblaze_noInit;
|
16407 |
|
|
+ printIval(sym, sym->type, sym->ival, &tmpBuf, TRUE);
|
16408 |
|
|
+ --pblaze_noInit;
|
16409 |
|
|
+ --noAlloc;
|
16410 |
|
|
+ dbuf_destroy(&tmpBuf);
|
16411 |
|
|
+ }
|
16412 |
|
|
+ } else {
|
16413 |
|
|
+ if (IS_AGGREGATE(sym->type)) {
|
16414 |
|
|
+ ival = initAggregates(sym, sym->ival, NULL);
|
16415 |
|
|
+ } else {
|
16416 |
|
|
+ if (getNelements(sym->type, sym->ival) > 1) {
|
16417 |
|
|
+ werrorfl(sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", sym->name);
|
16418 |
|
|
+ }
|
16419 |
|
|
+ ival = newNode('=', newAst_VALUE(symbolVal(sym)), decorateType(resolveSymbols(list2expr(sym->ival)), RESULT_TYPE_NONE));
|
16420 |
|
|
+ }
|
16421 |
|
|
+ codeOutBuf = &statsg->oBuf;
|
16422 |
|
|
+
|
16423 |
|
|
+ if (ival) {
|
16424 |
|
|
+ // set ival's lineno to where the symbol was defined
|
16425 |
|
|
+ setAstFileLine(ival, filename = sym->fileDef, lineno = sym->lineDef);
|
16426 |
|
|
+ // check if this is not a constant expression
|
16427 |
|
|
+ if (!constExprTree(ival)) {
|
16428 |
|
|
+ werror(E_CONST_EXPECTED, "found expression");
|
16429 |
|
|
+ // but try to do it anyway
|
16430 |
|
|
+ }
|
16431 |
|
|
+ pblaze_allocInfo = 0;
|
16432 |
|
|
+ if (!astErrors(ival))
|
16433 |
|
|
+ eBBlockFromiCode(iCodeFromAst(ival));
|
16434 |
|
|
+ pblaze_allocInfo = 1;
|
16435 |
|
|
+ }
|
16436 |
|
|
+ }
|
16437 |
|
|
+ }
|
16438 |
|
|
+
|
16439 |
|
|
+ /* if it has an absolute address then generate
|
16440 |
|
|
+ an equate for this no need to allocate space */
|
16441 |
|
|
+ if (SPEC_ABSA(sym->etype) && !sym->ival) {
|
16442 |
|
|
+ char *equ = "=";
|
16443 |
|
|
+
|
16444 |
|
|
+ /* print extra debug info if required */
|
16445 |
|
|
+ if (options.debug) {
|
16446 |
|
|
+ pblaze_emitDebugSym(&map->oBuf, sym);
|
16447 |
|
|
+ dbuf_printf(&map->oBuf, " == 0x%04x\n", SPEC_ADDR(sym->etype));
|
16448 |
|
|
+ }
|
16449 |
|
|
+ if (TARGET_IS_XA51) {
|
16450 |
|
|
+ if (map == sfr) {
|
16451 |
|
|
+ equ = "sfr";
|
16452 |
|
|
+ } else if (map == bit || map == sfrbit) {
|
16453 |
|
|
+ equ = "bit";
|
16454 |
|
|
+ }
|
16455 |
|
|
+ }
|
16456 |
|
|
+ dbuf_printf(&map->oBuf, "%s\t%s\t0x%04x\n", sym->rname, equ, SPEC_ADDR(sym->etype));
|
16457 |
|
|
+ } else {
|
16458 |
|
|
+ int size = getSize(sym->type) + sym->flexArrayLength;
|
16459 |
|
|
+ if (size == 0) {
|
16460 |
|
|
+ werrorfl(sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name);
|
16461 |
|
|
+ }
|
16462 |
|
|
+ /* allocate space */
|
16463 |
|
|
+ if (SPEC_ABSA(sym->etype)) {
|
16464 |
|
|
+ dbuf_tprintf(&map->oBuf, "\t!org\n", SPEC_ADDR(sym->etype));
|
16465 |
|
|
+ }
|
16466 |
|
|
+ /* print extra debug info if required */
|
16467 |
|
|
+ if (options.debug) {
|
16468 |
|
|
+ pblaze_emitDebugSym(&map->oBuf, sym);
|
16469 |
|
|
+ dbuf_printf(&map->oBuf, "==.\n");
|
16470 |
|
|
+ }
|
16471 |
|
|
+ if (IS_STATIC(sym->etype) || sym->level)
|
16472 |
|
|
+ dbuf_tprintf(&map->oBuf, "!slabeldef\n", sym->rname);
|
16473 |
|
|
+ else
|
16474 |
|
|
+ dbuf_tprintf(&map->oBuf, "!labeldef\n", sym->rname);
|
16475 |
|
|
+ dbuf_tprintf(&map->oBuf, "\t!ds\n", (unsigned int) size & 0xffff);
|
16476 |
|
|
+ }
|
16477 |
|
|
+ sym->ival = NULL;
|
16478 |
|
|
+ }
|
16479 |
|
|
+}
|
16480 |
|
|
+
|
16481 |
|
|
+
|
16482 |
|
|
+/*-----------------------------------------------------------------*/
|
16483 |
|
|
+/* pblaze_emitStaticSeg - emitcode for the static segment */
|
16484 |
|
|
+/*-----------------------------------------------------------------*/
|
16485 |
|
|
+void pblaze_emitStaticSeg(memmap * map, struct dbuf_s *oBuf)
|
16486 |
|
|
+{
|
16487 |
|
|
+ symbol *sym;
|
16488 |
|
|
+
|
16489 |
|
|
+ /* fprintf(out, "\t.area\t%s\n", map->sname); */
|
16490 |
|
|
+
|
16491 |
|
|
+ /* for all variables in this segment do */
|
16492 |
|
|
+ for (sym = setFirstItem(map->syms); sym; sym = setNextItem(map->syms)) {
|
16493 |
|
|
+ /* if it is "extern" then do nothing */
|
16494 |
|
|
+ if (IS_EXTERN(sym->etype))
|
16495 |
|
|
+ continue;
|
16496 |
|
|
+
|
16497 |
|
|
+ /* if it is not static add it to the public table */
|
16498 |
|
|
+ if (!IS_STATIC(sym->etype)) {
|
16499 |
|
|
+ addSetHead(&pblaze_publics, sym);
|
16500 |
|
|
+ }
|
16501 |
|
|
+
|
16502 |
|
|
+ /* if it has an absolute address and no initializer */
|
16503 |
|
|
+ if (SPEC_ABSA(sym->etype) && !sym->ival) {
|
16504 |
|
|
+ if (options.debug) {
|
16505 |
|
|
+ pblaze_emitDebugSym(oBuf, sym);
|
16506 |
|
|
+ dbuf_printf(oBuf, " == 0x%04x\n", SPEC_ADDR(sym->etype));
|
16507 |
|
|
+ }
|
16508 |
|
|
+ dbuf_printf(oBuf, "%s\t=\t0x%04x\n", sym->rname, SPEC_ADDR(sym->etype));
|
16509 |
|
|
+ } else {
|
16510 |
|
|
+ int size = getSize(sym->type);
|
16511 |
|
|
+
|
16512 |
|
|
+ if (size == 0) {
|
16513 |
|
|
+ werrorfl(sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name);
|
16514 |
|
|
+ }
|
16515 |
|
|
+ /* if it has an initial value */
|
16516 |
|
|
+ if (sym->ival) {
|
16517 |
|
|
+ if (SPEC_ABSA(sym->etype)) {
|
16518 |
|
|
+ dbuf_tprintf(oBuf, "\t!org\n", SPEC_ADDR(sym->etype));
|
16519 |
|
|
+ }
|
16520 |
|
|
+ if (options.debug) {
|
16521 |
|
|
+ pblaze_emitDebugSym(oBuf, sym);
|
16522 |
|
|
+ dbuf_printf(oBuf, " == .\n");
|
16523 |
|
|
+ }
|
16524 |
|
|
+ dbuf_printf(oBuf, "%s:\n", sym->rname);
|
16525 |
|
|
+ ++noAlloc;
|
16526 |
|
|
+ resolveIvalSym(sym->ival, sym->type);
|
16527 |
|
|
+ printIval(sym, sym->type, sym->ival, oBuf, map != xinit);
|
16528 |
|
|
+ --noAlloc;
|
16529 |
|
|
+ /* if sym is a simple string and sym->ival is a string,
|
16530 |
|
|
+ WE don't need it anymore */
|
16531 |
|
|
+ if (IS_ARRAY(sym->type) && IS_CHAR(sym->type->next) &&
|
16532 |
|
|
+ IS_AST_SYM_VALUE(list2expr(sym->ival)) && list2val(sym->ival)->sym->isstrlit) {
|
16533 |
|
|
+ freeStringSymbol(list2val(sym->ival)->sym);
|
16534 |
|
|
+ }
|
16535 |
|
|
+ } else {
|
16536 |
|
|
+ /* allocate space */
|
16537 |
|
|
+ if (options.debug) {
|
16538 |
|
|
+ pblaze_emitDebugSym(oBuf, sym);
|
16539 |
|
|
+ dbuf_printf(oBuf, " == .\n");
|
16540 |
|
|
+ }
|
16541 |
|
|
+ dbuf_printf(oBuf, "%s:\n", sym->rname);
|
16542 |
|
|
+ /* special case for character strings */
|
16543 |
|
|
+ if (IS_ARRAY(sym->type) && IS_CHAR(sym->type->next) && SPEC_CVAL(sym->etype).v_char) {
|
16544 |
|
|
+ pblaze_printChar(oBuf, SPEC_CVAL(sym->etype).v_char, size);
|
16545 |
|
|
+ } else {
|
16546 |
|
|
+ dbuf_tprintf(oBuf, "\t!ds\n", (unsigned int) size & 0xffff);
|
16547 |
|
|
+ }
|
16548 |
|
|
+ }
|
16549 |
|
|
+ }
|
16550 |
|
|
+ }
|
16551 |
|
|
+}
|
16552 |
|
|
+
|
16553 |
|
|
+/*-----------------------------------------------------------------*/
|
16554 |
|
|
+/* pblaze_emitMaps - emits the code for the data portion the code */
|
16555 |
|
|
+/*-----------------------------------------------------------------*/
|
16556 |
|
|
+void pblaze_emitMaps(void)
|
16557 |
|
|
+{
|
16558 |
|
|
+ int publicsfr = TARGET_IS_MCS51; /* Ideally, this should be true for all */
|
16559 |
|
|
+ /* ports but let's be conservative - EEP */
|
16560 |
|
|
+
|
16561 |
|
|
+ inInitMode++;
|
16562 |
|
|
+ /* no special considerations for the following
|
16563 |
|
|
+ data, idata & bit & xdata */
|
16564 |
|
|
+ pblaze_emitRegularMap(data, TRUE, TRUE);
|
16565 |
|
|
+ pblaze_emitRegularMap(idata, TRUE, TRUE);
|
16566 |
|
|
+ pblaze_emitRegularMap(d_abs, TRUE, TRUE);
|
16567 |
|
|
+ pblaze_emitRegularMap(i_abs, TRUE, TRUE);
|
16568 |
|
|
+ pblaze_emitRegularMap(bit, TRUE, TRUE);
|
16569 |
|
|
+ pblaze_emitRegularMap(pdata, TRUE, TRUE);
|
16570 |
|
|
+ pblaze_emitRegularMap(xdata, TRUE, TRUE);
|
16571 |
|
|
+ pblaze_emitRegularMap(x_abs, TRUE, TRUE);
|
16572 |
|
|
+ if (port->genXINIT) {
|
16573 |
|
|
+ pblaze_emitRegularMap(xidata, TRUE, TRUE);
|
16574 |
|
|
+ }
|
16575 |
|
|
+ pblaze_emitRegularMap(sfr, publicsfr, FALSE);
|
16576 |
|
|
+ pblaze_emitRegularMap(sfrbit, publicsfr, FALSE);
|
16577 |
|
|
+ pblaze_emitRegularMap(home, TRUE, FALSE);
|
16578 |
|
|
+ pblaze_emitRegularMap(code, TRUE, FALSE);
|
16579 |
|
|
+
|
16580 |
|
|
+
|
16581 |
|
|
+ pblaze_emitStaticSeg(c_abs, &code->oBuf);
|
16582 |
|
|
+ inInitMode--;
|
16583 |
|
|
+}
|
16584 |
|
|
+
|
16585 |
|
|
+/*-----------------------------------------------------------------*/
|
16586 |
|
|
+/* pblaze_createInterruptVect - creates the interrupt vector */
|
16587 |
|
|
+/*-----------------------------------------------------------------*/
|
16588 |
|
|
+void pblaze_createInterruptVect(struct dbuf_s *vBuf)
|
16589 |
|
|
+{
|
16590 |
|
|
+ pblaze_mainf = newSymbol("main", 0);
|
16591 |
|
|
+ pblaze_mainf->block = 0;
|
16592 |
|
|
+
|
16593 |
|
|
+ /* only if the main function exists */
|
16594 |
|
|
+ if (!(pblaze_mainf = findSymWithLevel(SymbolTab, pblaze_mainf))) {
|
16595 |
|
|
+ if (!options.cc_only && !noAssemble && !options.c1mode)
|
16596 |
|
|
+ werror(E_NO_MAIN);
|
16597 |
|
|
+ return;
|
16598 |
|
|
+ }
|
16599 |
|
|
+
|
16600 |
|
|
+ /* if the main is only a prototype ie. no body then do nothing */
|
16601 |
|
|
+ if (!IFFUNC_HASBODY(pblaze_mainf->type)) {
|
16602 |
|
|
+ /* if ! compile only then main function should be present */
|
16603 |
|
|
+ if (!options.cc_only && !noAssemble)
|
16604 |
|
|
+ werror(E_NO_MAIN);
|
16605 |
|
|
+ return;
|
16606 |
|
|
+ }
|
16607 |
|
|
+ //dbuf_printf (vBuf, "__interrupt_vect:\n");
|
16608 |
|
|
+
|
16609 |
|
|
+ if (!port->genIVT || !(port->genIVT(vBuf, interrupts, maxInterrupts))) {
|
16610 |
|
|
+ /* There's no such thing as a "generic" interrupt table header. */
|
16611 |
|
|
+ wassert(0);
|
16612 |
|
|
+ }
|
16613 |
|
|
+}
|
16614 |
|
|
+
|
16615 |
|
|
+char *pblaze_iComments1 = {
|
16616 |
|
|
+ ";--------------------------------------------------------\n" "; File Created by SDCC : free open source ANSI-C Compiler\n"
|
16617 |
|
|
+};
|
16618 |
|
|
+
|
16619 |
|
|
+char *pblaze_iComments2 = {
|
16620 |
|
|
+ ";--------------------------------------------------------\n"
|
16621 |
|
|
+};
|
16622 |
|
|
+
|
16623 |
|
|
+
|
16624 |
|
|
+/*-----------------------------------------------------------------*/
|
16625 |
|
|
+/* pbInitialComments - puts in some initial comments */
|
16626 |
|
|
+/*-----------------------------------------------------------------*/
|
16627 |
|
|
+void pbInitialComments(FILE * afile)
|
16628 |
|
|
+{
|
16629 |
|
|
+ time_t t;
|
16630 |
|
|
+ time(&t);
|
16631 |
|
|
+ fprintf(afile, "%s", pblaze_iComments1);
|
16632 |
|
|
+ fprintf(afile, "; Version " SDCC_VERSION_STR " #%s (%s) (%s)\n", getBuildNumber(), getBuildDate(), getBuildEnvironment());
|
16633 |
|
|
+ fprintf(afile, "; This file was generated %s", asctime(localtime(&t)));
|
16634 |
|
|
+ fprintf(afile, "%s", pblaze_iComments2);
|
16635 |
|
|
+}
|
16636 |
|
|
+
|
16637 |
|
|
+
|
16638 |
|
|
+/*-----------------------------------------------------------------*/
|
16639 |
|
|
+/* pblaze_printPublics - generates .global for publics */
|
16640 |
|
|
+/*-----------------------------------------------------------------*/
|
16641 |
|
|
+void pblaze_printPublics(FILE * afile)
|
16642 |
|
|
+{
|
16643 |
|
|
+ symbol *sym;
|
16644 |
|
|
+
|
16645 |
|
|
+ fprintf(afile, "%s", pblaze_iComments2);
|
16646 |
|
|
+ fprintf(afile, "; Public variables in this module\n");
|
16647 |
|
|
+ fprintf(afile, "%s", pblaze_iComments2);
|
16648 |
|
|
+
|
16649 |
|
|
+ for (sym = setFirstItem(pblaze_publics); sym; sym = setNextItem(pblaze_publics))
|
16650 |
|
|
+ tfprintf(afile, "\t!global\n", sym->rname);
|
16651 |
|
|
+}
|
16652 |
|
|
+
|
16653 |
|
|
+
|
16654 |
|
|
+/*-----------------------------------------------------------------*/
|
16655 |
|
|
+/* pblaze_printExterns - generates .global for Externs */
|
16656 |
|
|
+/*-----------------------------------------------------------------*/
|
16657 |
|
|
+void pblaze_printExterns(FILE * afile)
|
16658 |
|
|
+{
|
16659 |
|
|
+ fprintf(afile, "%s", pblaze_iComments2);
|
16660 |
|
|
+ fprintf(afile, "; Externals used\n");
|
16661 |
|
|
+ fprintf(afile, "%s", pblaze_iComments2);
|
16662 |
|
|
+
|
16663 |
|
|
+}
|
16664 |
|
|
+
|
16665 |
|
|
+/*-----------------------------------------------------------------*/
|
16666 |
|
|
+/* pblaze_emitOverlay - will emit code for the overlay stuff */
|
16667 |
|
|
+/*-----------------------------------------------------------------*/
|
16668 |
|
|
+static void pblaze_emitOverlay(struct dbuf_s *aBuf)
|
16669 |
|
|
+{
|
16670 |
|
|
+ set *ovrset;
|
16671 |
|
|
+
|
16672 |
|
|
+
|
16673 |
|
|
+ /* for each of the sets in the overlay segment do */
|
16674 |
|
|
+ for (ovrset = setFirstItem(ovrSetSets); ovrset; ovrset = setNextItem(ovrSetSets)) {
|
16675 |
|
|
+ symbol *sym;
|
16676 |
|
|
+
|
16677 |
|
|
+ for (sym = setFirstItem(ovrset); sym; sym = setNextItem(ovrset)) {
|
16678 |
|
|
+ /* if extern then it is in the pblaze_publics table: do nothing */
|
16679 |
|
|
+ if (IS_EXTERN(sym->etype))
|
16680 |
|
|
+ continue;
|
16681 |
|
|
+
|
16682 |
|
|
+ /* if allocation required check is needed
|
16683 |
|
|
+ then check if the symbol really requires
|
16684 |
|
|
+ allocation only for local variables */
|
16685 |
|
|
+ if (!IS_AGGREGATE(sym->type) && !(sym->_isparm && !IS_REGPARM(sym->etype))
|
16686 |
|
|
+ && !sym->allocreq && sym->level)
|
16687 |
|
|
+ continue;
|
16688 |
|
|
+
|
16689 |
|
|
+ /* if global variable & not static or extern
|
16690 |
|
|
+ and addPublics allowed then add it to the public set */
|
16691 |
|
|
+ if ((sym->_isparm && !IS_REGPARM(sym->etype))
|
16692 |
|
|
+ && !IS_STATIC(sym->etype)) {
|
16693 |
|
|
+ addSetHead(&pblaze_publics, sym);
|
16694 |
|
|
+ }
|
16695 |
|
|
+
|
16696 |
|
|
+ /* if extern then do nothing or is a function
|
16697 |
|
|
+ then do nothing */
|
16698 |
|
|
+ if (IS_FUNC(sym->type))
|
16699 |
|
|
+ continue;
|
16700 |
|
|
+
|
16701 |
|
|
+ /* print extra debug info if required */
|
16702 |
|
|
+ if (options.debug) {
|
16703 |
|
|
+ if (!sym->level) { /* global */
|
16704 |
|
|
+ if (IS_STATIC(sym->etype))
|
16705 |
|
|
+ dbuf_printf(aBuf, "F%s$", moduleName); /* scope is file */
|
16706 |
|
|
+ else
|
16707 |
|
|
+ dbuf_printf(aBuf, "G$"); /* scope is global */
|
16708 |
|
|
+ } else
|
16709 |
|
|
+ /* symbol is local */
|
16710 |
|
|
+ dbuf_printf(aBuf, "L%s$", (sym->localof ? sym->localof->name : "-null-"));
|
16711 |
|
|
+ dbuf_printf(aBuf, "%s$%d$%d", sym->name, sym->level, sym->block);
|
16712 |
|
|
+ }
|
16713 |
|
|
+
|
16714 |
|
|
+ /* if is has an absolute address then generate
|
16715 |
|
|
+ an equate for this no need to allocate space */
|
16716 |
|
|
+ if (SPEC_ABSA(sym->etype)) {
|
16717 |
|
|
+ if (options.debug)
|
16718 |
|
|
+ dbuf_printf(aBuf, " == 0x%04x\n", SPEC_ADDR(sym->etype));
|
16719 |
|
|
+
|
16720 |
|
|
+ dbuf_printf(aBuf, "%s\t=\t0x%04x\n", sym->rname, SPEC_ADDR(sym->etype));
|
16721 |
|
|
+ } else {
|
16722 |
|
|
+ int size = getSize(sym->type);
|
16723 |
|
|
+
|
16724 |
|
|
+ if (size == 0) {
|
16725 |
|
|
+ werrorfl(sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE);
|
16726 |
|
|
+ }
|
16727 |
|
|
+ if (options.debug)
|
16728 |
|
|
+ dbuf_printf(aBuf, "==.\n");
|
16729 |
|
|
+
|
16730 |
|
|
+ /* allocate space */
|
16731 |
|
|
+ dbuf_tprintf(aBuf, "!labeldef\n", sym->rname);
|
16732 |
|
|
+ dbuf_tprintf(aBuf, "\t!ds\n", (unsigned int) getSize(sym->type) & 0xffff);
|
16733 |
|
|
+ }
|
16734 |
|
|
+ }
|
16735 |
|
|
+ }
|
16736 |
|
|
+}
|
16737 |
|
|
+
|
16738 |
|
|
+/*-----------------------------------------------------------------*/
|
16739 |
|
|
+/* glue - the final glue that hold the whole thing together */
|
16740 |
|
|
+/*-----------------------------------------------------------------*/
|
16741 |
|
|
+void pblaze_glue(void)
|
16742 |
|
|
+{
|
16743 |
|
|
+ struct dbuf_s vBuf;
|
16744 |
|
|
+ struct dbuf_s ovrBuf;
|
16745 |
|
|
+ struct dbuf_s asmFileName;
|
16746 |
|
|
+ FILE *asmFile;
|
16747 |
|
|
+
|
16748 |
|
|
+
|
16749 |
|
|
+ pblaze_genCodeLoop();
|
16750 |
|
|
+
|
16751 |
|
|
+ dbuf_init(&vBuf, 4096);
|
16752 |
|
|
+ dbuf_init(&ovrBuf, 4096);
|
16753 |
|
|
+
|
16754 |
|
|
+ /* print the global struct definitions */
|
16755 |
|
|
+ if (options.debug)
|
16756 |
|
|
+ cdbStructBlock(0);
|
16757 |
|
|
+
|
16758 |
|
|
+ /* PENDING: this isn't the best place but it will do */
|
16759 |
|
|
+ if (port->general.glue_up_main) {
|
16760 |
|
|
+ /* create the interrupt vector table */
|
16761 |
|
|
+ pblaze_createInterruptVect(&vBuf);
|
16762 |
|
|
+ }
|
16763 |
|
|
+
|
16764 |
|
|
+ /* emit code for the all the variables declared */
|
16765 |
|
|
+ pblaze_emitMaps();
|
16766 |
|
|
+ /* do the overlay segments */
|
16767 |
|
|
+ pblaze_emitOverlay(&ovrBuf);
|
16768 |
|
|
+
|
16769 |
|
|
+ outputDebugSymbols();
|
16770 |
|
|
+
|
16771 |
|
|
+ /* now put it all together into the assembler file */
|
16772 |
|
|
+ /* create the assembler file name */
|
16773 |
|
|
+
|
16774 |
|
|
+ /* -o option overrides default name? */
|
16775 |
|
|
+ dbuf_init(&asmFileName, PATH_MAX);
|
16776 |
|
|
+ if ((noAssemble || options.c1mode) && fullDstFileName) {
|
16777 |
|
|
+ dbuf_append_str(&asmFileName, fullDstFileName);
|
16778 |
|
|
+ } else {
|
16779 |
|
|
+ dbuf_append_str(&asmFileName, dstFileName);
|
16780 |
|
|
+ dbuf_append_str(&asmFileName, port->assembler.file_ext);
|
16781 |
|
|
+ }
|
16782 |
|
|
+
|
16783 |
|
|
+ if (!(asmFile = fopen(dbuf_c_str(&asmFileName), "w"))) {
|
16784 |
|
|
+ werror(E_FILE_OPEN_ERR, dbuf_c_str(&asmFileName));
|
16785 |
|
|
+ dbuf_destroy(&asmFileName);
|
16786 |
|
|
+ exit(EXIT_FAILURE);
|
16787 |
|
|
+ }
|
16788 |
|
|
+ dbuf_destroy(&asmFileName);
|
16789 |
|
|
+
|
16790 |
|
|
+ /* initial comments */
|
16791 |
|
|
+ pbInitialComments(asmFile);
|
16792 |
|
|
+
|
16793 |
|
|
+
|
16794 |
|
|
+ /* Let the port generate any global directives, etc. */
|
16795 |
|
|
+ if (port->genAssemblerPreamble) {
|
16796 |
|
|
+ port->genAssemblerPreamble(asmFile);
|
16797 |
|
|
+ }
|
16798 |
|
|
+
|
16799 |
|
|
+ /* print the global variables in this module */
|
16800 |
|
|
+ //pblaze_printPublics (asmFile);
|
16801 |
|
|
+ if (port->assembler.externGlobal)
|
16802 |
|
|
+ pblaze_printExterns(asmFile);
|
16803 |
|
|
+
|
16804 |
|
|
+
|
16805 |
|
|
+ /* If the port wants to generate any extra areas, let it do so. */
|
16806 |
|
|
+ if (port->extraAreas.genExtraAreaDeclaration) {
|
16807 |
|
|
+ port->extraAreas.genExtraAreaDeclaration(asmFile, pblaze_mainf && IFFUNC_HASBODY(pblaze_mainf->type));
|
16808 |
|
|
+ }
|
16809 |
|
|
+
|
16810 |
|
|
+ /* copy global & static initialisations */
|
16811 |
|
|
+ fprintf(asmFile, "%s", pblaze_iComments2);
|
16812 |
|
|
+ fprintf(asmFile, "; global & static initialisations\n");
|
16813 |
|
|
+ fprintf(asmFile, "%s", pblaze_iComments2);
|
16814 |
|
|
+
|
16815 |
|
|
+ if (pblaze_mainf && IFFUNC_HASBODY(pblaze_mainf->type)) {
|
16816 |
|
|
+ if (port->genInitStartup) {
|
16817 |
|
|
+ port->genInitStartup(asmFile);
|
16818 |
|
|
+ } else {
|
16819 |
|
|
+
|
16820 |
|
|
+ // if the port can copy the XINIT segment to XISEG
|
16821 |
|
|
+ if (port->genXINIT) {
|
16822 |
|
|
+ port->genXINIT(asmFile);
|
16823 |
|
|
+ }
|
16824 |
|
|
+ }
|
16825 |
|
|
+ }
|
16826 |
|
|
+ dbuf_write_and_destroy(&statsg->oBuf, asmFile);
|
16827 |
|
|
+
|
16828 |
|
|
+ if (port->general.glue_up_main && pblaze_mainf && IFFUNC_HASBODY(pblaze_mainf->type)) {
|
16829 |
|
|
+ /* This code is generated in the post-static area.
|
16830 |
|
|
+ * This area is guaranteed to follow the static area
|
16831 |
|
|
+ * by the ugly shucking and jiving about 20 lines ago.
|
16832 |
|
|
+ */
|
16833 |
|
|
+
|
16834 |
|
|
+ fprintf(asmFile, "\tLOAD\tsF, %s%02x\n", pblaze_options.dialect ? "" : "$", MEMSIZE - 1);
|
16835 |
|
|
+ fprintf(asmFile, "\tJUMP\t__sdcc_program_startup\n");
|
16836 |
|
|
+ }
|
16837 |
|
|
+
|
16838 |
|
|
+ fprintf(asmFile, "%s" "; Home\n" "%s", pblaze_iComments2, pblaze_iComments2);
|
16839 |
|
|
+ dbuf_write_and_destroy(&home->oBuf, asmFile);
|
16840 |
|
|
+
|
16841 |
|
|
+ if (pblaze_mainf && IFFUNC_HASBODY(pblaze_mainf->type)) {
|
16842 |
|
|
+ /* entry point @ start of HOME */
|
16843 |
|
|
+ fprintf(asmFile, "__sdcc_program_startup:\n");
|
16844 |
|
|
+
|
16845 |
|
|
+ /* put in jump or call to main */
|
16846 |
|
|
+ if (options.mainreturn) {
|
16847 |
|
|
+ fprintf(asmFile, "\tJUMP\t_main\n"); /* needed? */
|
16848 |
|
|
+ if (!options.noCcodeInAsm)
|
16849 |
|
|
+ fprintf(asmFile, ";\treturn from main will return to caller\n");
|
16850 |
|
|
+ } else {
|
16851 |
|
|
+ fprintf(asmFile, "\tCALL\t_main\n");
|
16852 |
|
|
+ if (!options.noCcodeInAsm)
|
16853 |
|
|
+ fprintf(asmFile, ";\treturn from main will lock up\n");
|
16854 |
|
|
+ fprintf(asmFile, "__sdcc_loop:\n");
|
16855 |
|
|
+ fprintf(asmFile, "\tJUMP\t__sdcc_loop\n");
|
16856 |
|
|
+ }
|
16857 |
|
|
+ }
|
16858 |
|
|
+ /* copy over code */
|
16859 |
|
|
+ fprintf(asmFile, "%s", pblaze_iComments2);
|
16860 |
|
|
+ fprintf(asmFile, "; code\n");
|
16861 |
|
|
+ fprintf(asmFile, "%s", pblaze_iComments2);
|
16862 |
|
|
+ dbuf_write_and_destroy(&code->oBuf, asmFile);
|
16863 |
|
|
+
|
16864 |
|
|
+ if (port->genAssemblerEnd) {
|
16865 |
|
|
+ port->genAssemblerEnd(asmFile);
|
16866 |
|
|
+ }
|
16867 |
|
|
+
|
16868 |
|
|
+ /* copy the interrupt vector table */
|
16869 |
|
|
+ if (pblaze_mainf && IFFUNC_HASBODY(pblaze_mainf->type)) {
|
16870 |
|
|
+ fprintf(asmFile, "%s", pblaze_iComments2);
|
16871 |
|
|
+ fprintf(asmFile, "; interrupt vector \n");
|
16872 |
|
|
+ fprintf(asmFile, "%s", pblaze_iComments2);
|
16873 |
|
|
+ dbuf_write_and_destroy(&vBuf, asmFile);
|
16874 |
|
|
+ }
|
16875 |
|
|
+
|
16876 |
|
|
+ fclose(asmFile);
|
16877 |
|
|
+}
|
16878 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/pbglue.h sdcc-src-3.1.0-pblaze/src/pblaze/pbglue.h
|
16879 |
|
|
--- sdcc-src-3.1.0/src/pblaze/pbglue.h 1970-01-01 01:00:00.000000000 +0100
|
16880 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/pbglue.h 2011-08-23 15:56:30.000000000 +0200
|
16881 |
|
|
@@ -0,0 +1,43 @@
|
16882 |
|
|
+/*-------------------------------------------------------------------------
|
16883 |
|
|
+ pbglue.h - glues everything we have done together into one file.
|
16884 |
|
|
+
|
16885 |
|
|
+ Written By:
|
16886 |
|
|
+ Sandeep Dutta . sandeep.dutta@usa.net (1998)
|
16887 |
|
|
+ &&
|
16888 |
|
|
+ Jakub Hornik, xhorni00<at>stud.fit.vutbr.cz
|
16889 |
|
|
+ Master Thesis Project:
|
16890 |
|
|
+ Compiler Back-End of Subset of Language C for 8-Bit Processor
|
16891 |
|
|
+ Date:
|
16892 |
|
|
+ 2011
|
16893 |
|
|
+
|
16894 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
16895 |
|
|
+ under the terms of the GNU General Public License as published by the
|
16896 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
16897 |
|
|
+ later version.
|
16898 |
|
|
+
|
16899 |
|
|
+ This program is distributed in the hope that it will be useful,
|
16900 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16901 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16902 |
|
|
+ GNU General Public License for more details.
|
16903 |
|
|
+
|
16904 |
|
|
+ You should have received a copy of the GNU General Public License
|
16905 |
|
|
+ along with this program; if not, write to the Free Software
|
16906 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16907 |
|
|
+
|
16908 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
16909 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
16910 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
16911 |
|
|
+-------------------------------------------------------------------------*/
|
16912 |
|
|
+#include "common.h"
|
16913 |
|
|
+
|
16914 |
|
|
+#ifndef PBGLUE_H
|
16915 |
|
|
+#define PBGLUE_H 1
|
16916 |
|
|
+
|
16917 |
|
|
+void pblaze_glue(void);
|
16918 |
|
|
+
|
16919 |
|
|
+extern symbol *interrupts[];
|
16920 |
|
|
+extern set *pblaze_publics;
|
16921 |
|
|
+
|
16922 |
|
|
+
|
16923 |
|
|
+
|
16924 |
|
|
+#endif
|
16925 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/peeph.def sdcc-src-3.1.0-pblaze/src/pblaze/peeph.def
|
16926 |
|
|
--- sdcc-src-3.1.0/src/pblaze/peeph.def 1970-01-01 01:00:00.000000000 +0100
|
16927 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/peeph.def 2011-08-23 15:56:30.000000000 +0200
|
16928 |
|
|
@@ -0,0 +1,17 @@
|
16929 |
|
|
+
|
16930 |
|
|
+replace {
|
16931 |
|
|
+ FETCH %1, %2
|
16932 |
|
|
+ LOAD %1, %3
|
16933 |
|
|
+} by {
|
16934 |
|
|
+ ; Peephole 1 unnecessary fetch %1, %2
|
16935 |
|
|
+ LOAD %1, %3
|
16936 |
|
|
+}
|
16937 |
|
|
+
|
16938 |
|
|
+// should be one of the last peepholes
|
16939 |
|
|
+replace{
|
16940 |
|
|
+%1:
|
16941 |
|
|
+} by {
|
16942 |
|
|
+ ; Peephole 500 removed redundant label %1
|
16943 |
|
|
+} if labelRefCount(%1 0)
|
16944 |
|
|
+
|
16945 |
|
|
+
|
16946 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/ralloc.c sdcc-src-3.1.0-pblaze/src/pblaze/ralloc.c
|
16947 |
|
|
--- sdcc-src-3.1.0/src/pblaze/ralloc.c 1970-01-01 01:00:00.000000000 +0100
|
16948 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/ralloc.c 2011-12-05 23:46:59.162175900 +0100
|
16949 |
|
|
@@ -0,0 +1,1827 @@
|
16950 |
|
|
+/*------------------------------------------------------------------------
|
16951 |
|
|
+ralloc.c - source file for register allocation. (XILINX PICOBLAZE) specific
|
16952 |
|
|
+
|
16953 |
|
|
+Author:
|
16954 |
|
|
+ Jakub Hornik, xhorni00<at>stud.fit.vutbr.cz
|
16955 |
|
|
+Master Thesis Project:
|
16956 |
|
|
+ Compiler Back-End of Subset of Language C for 8-Bit Processor
|
16957 |
|
|
+Date:
|
16958 |
|
|
+ 2011
|
16959 |
|
|
+
|
16960 |
|
|
+This program is free software; you can redistribute it and/or modify it
|
16961 |
|
|
+under the terms of the GNU General Public License as published by the
|
16962 |
|
|
+Free Software Foundation; either version 2, or (at your option) any
|
16963 |
|
|
+later version.
|
16964 |
|
|
+
|
16965 |
|
|
+This program is distributed in the hope that it will be useful,
|
16966 |
|
|
+but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16967 |
|
|
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16968 |
|
|
+GNU General Public License for more details.
|
16969 |
|
|
+
|
16970 |
|
|
+You should have received a copy of the GNU General Public License
|
16971 |
|
|
+along with this program; if not, write to the Free Software
|
16972 |
|
|
+Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16973 |
|
|
+
|
16974 |
|
|
+In other words, you are welcome to use, share and improve this program.
|
16975 |
|
|
+You are forbidden to forbid anyone else to use, share and improve
|
16976 |
|
|
+what you give them. Help stamp out software-hoarding!
|
16977 |
|
|
+-------------------------------------------------------------------------*/
|
16978 |
|
|
+
|
16979 |
|
|
+#include "common.h"
|
16980 |
|
|
+#include "ralloc.h"
|
16981 |
|
|
+#include "gen.h"
|
16982 |
|
|
+
|
16983 |
|
|
+//#define SYMBOL_IN_REG(reg) validateOpType(reg->currOper, "OP_SYMBOL", #op, SYMBOL, __FILE__, __LINE__)->operand.symOperand
|
16984 |
|
|
+#define SYMBOL_IN_REG(reg) OP_SYMBOL(reg.currOper)
|
16985 |
|
|
+#define RCV ic->op == RECEIVE
|
16986 |
|
|
+#define GLOBORVOLATIL(x) (IS_OP_GLOBAL(x) || IS_OP_VOLATILE(x))
|
16987 |
|
|
+#define IS_ENDLABEL(x) x->op == LABEL && strstr( IC_LABEL(x)->name, "_ifend_")
|
16988 |
|
|
+
|
16989 |
|
|
+#define SKIP_IC5(x) (x->op == CALL || \
|
16990 |
|
|
+ x->op == RETURN || \
|
16991 |
|
|
+ x->op == ENDFUNCTION || \
|
16992 |
|
|
+ x->op == FUNCTION || \
|
16993 |
|
|
+ x->op == SEND || \
|
16994 |
|
|
+ x->op == RECEIVE )
|
16995 |
|
|
+
|
16996 |
|
|
+
|
16997 |
|
|
+#define SKIP_NO_OP(x) (x->op == GOTO || \
|
16998 |
|
|
+ x->op == LABEL || \
|
16999 |
|
|
+ x->op == FUNCTION || \
|
17000 |
|
|
+ x->op == INLINEASM || \
|
17001 |
|
|
+ x->op == JUMPTABLE || \
|
17002 |
|
|
+ x->op == IFX || \
|
17003 |
|
|
+ x->op == CALL || \
|
17004 |
|
|
+ x->op == PCALL || \
|
17005 |
|
|
+ x->op == ARRAYINIT || \
|
17006 |
|
|
+ x->op == CRITICAL || \
|
17007 |
|
|
+ x->op == ENDCRITICAL || \
|
17008 |
|
|
+ x->op == ENDFUNCTION )
|
17009 |
|
|
+
|
17010 |
|
|
+extern void genPBLAZECode(iCode *);
|
17011 |
|
|
+extern unsigned fPBLAZEReturnSize;
|
17012 |
|
|
+extern void emitStore(char *r, int mem);
|
17013 |
|
|
+extern void emitFetch(char *r, int mem);
|
17014 |
|
|
+
|
17015 |
|
|
+/* Global data */
|
17016 |
|
|
+static struct {
|
17017 |
|
|
+ bitVect *regAssigned;
|
17018 |
|
|
+ bitVect *funcrUsed; /* registers used in a function */
|
17019 |
|
|
+ int stackExtend;
|
17020 |
|
|
+ int dataExtend;
|
17021 |
|
|
+} _G;
|
17022 |
|
|
+
|
17023 |
|
|
+/* Shared with gen.c */
|
17024 |
|
|
+int pblaze_ptrRegReq; /* pointer register required */
|
17025 |
|
|
+
|
17026 |
|
|
+int gInit = 0;
|
17027 |
|
|
+
|
17028 |
|
|
+/* PBLAZE registers */
|
17029 |
|
|
+reg_info regsPBLAZE[] = {
|
17030 |
|
|
+ {REG_GPR, S0_IDX, "s0", NULL, 0, 0, SAME_VAL, 1, 0},
|
17031 |
|
|
+ {REG_GPR, S1_IDX, "s1", NULL, 0, 0, SAME_VAL, 1, 0},
|
17032 |
|
|
+ {REG_GPR, S2_IDX, "s2", NULL, 0, 0, SAME_VAL, 1, 0},
|
17033 |
|
|
+ {REG_GPR, S3_IDX, "s3", NULL, 0, 0, SAME_VAL, 1, 0},
|
17034 |
|
|
+ {REG_GPR, S4_IDX, "s4", NULL, 0, 0, SAME_VAL, 1, 0},
|
17035 |
|
|
+ {REG_GPR, S5_IDX, "s5", NULL, 0, 0, SAME_VAL, 1, 0},
|
17036 |
|
|
+ {REG_GPR, S6_IDX, "s6", NULL, 0, 0, SAME_VAL, 1, 0},
|
17037 |
|
|
+ {REG_GPR, S7_IDX, "s7", NULL, 0, 0, SAME_VAL, 1, 0},
|
17038 |
|
|
+ {REG_GPR, S8_IDX, "s8", NULL, 0, 0, SAME_VAL, 1, 0},
|
17039 |
|
|
+ {REG_GPR, S9_IDX, "s9", NULL, 0, 0, SAME_VAL, 1, 0},
|
17040 |
|
|
+ {REG_GPR, SA_IDX, "sA", NULL, 0, 0, SAME_VAL, 1, 0},
|
17041 |
|
|
+ {REG_GPR, SB_IDX, "sB", NULL, 0, 0, SAME_VAL, 1, 1},
|
17042 |
|
|
+ {REG_GPR, SC_IDX, "sC", NULL, 0, 0, SAME_VAL, 1, 1},
|
17043 |
|
|
+ {REG_GPR, SD_IDX, "sD", NULL, 0, 0, SAME_VAL, 1, 1},
|
17044 |
|
|
+ {REG_GPR, SE_IDX, "sE", NULL, 0, 0, SAME_VAL, 1, 1},
|
17045 |
|
|
+ {REG_GPR, SF_IDX, "sF", NULL, 0, 0, SAME_VAL, 0, 1},
|
17046 |
|
|
+};
|
17047 |
|
|
+
|
17048 |
|
|
+
|
17049 |
|
|
+
|
17050 |
|
|
+int pblaze_nRegs = PBLAZENREGS - SEND_REG_COUNT - 1; // avaiable regs
|
17051 |
|
|
+int pblaze_totalRegs = PBLAZENREGS; // total regs
|
17052 |
|
|
+int pblaze_fReg = 0; /* first allocatable register */
|
17053 |
|
|
+
|
17054 |
|
|
+// temp regs counter
|
17055 |
|
|
+int ctr = 0;
|
17056 |
|
|
+
|
17057 |
|
|
+memMap memPBLAZE[MEMSIZE];
|
17058 |
|
|
+
|
17059 |
|
|
+
|
17060 |
|
|
+void printRegs(void)
|
17061 |
|
|
+{
|
17062 |
|
|
+
|
17063 |
|
|
+ int i;
|
17064 |
|
|
+
|
17065 |
|
|
+ printf("==============PicoBlaze=Registers=============\n");
|
17066 |
|
|
+
|
17067 |
|
|
+ for (i = 0; i < pblaze_nRegs; i++) {
|
17068 |
|
|
+ if (regsPBLAZE[i].isFree == 0 && regsPBLAZE[i].currOper) {
|
17069 |
|
|
+ printf("%s ->\t %s:%d\n", regsPBLAZE[i].name, SYMBOL_IN_REG(regsPBLAZE[i])->name, regsPBLAZE[i].offset);
|
17070 |
|
|
+
|
17071 |
|
|
+ } else if (regsPBLAZE[i].isReserved == 1 && regsPBLAZE[i].currOper)
|
17072 |
|
|
+ //printf("%s ->\t %s\n", regsPBLAZE[i].name, "reserved");
|
17073 |
|
|
+ printf("%sR ->\t %s:%d\n", regsPBLAZE[i].name, SYMBOL_IN_REG(regsPBLAZE[i])->name, regsPBLAZE[i].offset);
|
17074 |
|
|
+ }
|
17075 |
|
|
+ printf("==============================================\n\n");
|
17076 |
|
|
+}
|
17077 |
|
|
+
|
17078 |
|
|
+
|
17079 |
|
|
+void printMemory(void)
|
17080 |
|
|
+{
|
17081 |
|
|
+
|
17082 |
|
|
+ int i;
|
17083 |
|
|
+
|
17084 |
|
|
+ printf("==============PicoBlaze=Memory================\n");
|
17085 |
|
|
+
|
17086 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17087 |
|
|
+ if (memPBLAZE[i].isFree == 0 && memPBLAZE[i].currOper) {
|
17088 |
|
|
+ printf("%d ->\t %s:%d\n", memPBLAZE[i].addr, SYMBOL_IN_REG(memPBLAZE[i])->name, memPBLAZE[i].offset);
|
17089 |
|
|
+
|
17090 |
|
|
+ }
|
17091 |
|
|
+ }
|
17092 |
|
|
+ printf("==============================================\n\n");
|
17093 |
|
|
+}
|
17094 |
|
|
+
|
17095 |
|
|
+/*-----------------------------------------------------------------*/
|
17096 |
|
|
+/* Prints constants name depending on the selected dialect */
|
17097 |
|
|
+/*-----------------------------------------------------------------*/
|
17098 |
|
|
+void printConstants(FILE * of)
|
17099 |
|
|
+{
|
17100 |
|
|
+ int i;
|
17101 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17102 |
|
|
+ if (memPBLAZE[i].isFree == 0 && memPBLAZE[i].currOper && IS_OP_GLOBAL(memPBLAZE[i].currOper)) {
|
17103 |
|
|
+ if (pblaze_options.dialect && getSize(operandType(memPBLAZE[i].currOper)) == 1)
|
17104 |
|
|
+ fprintf(of, "\tCONSTANT\t%s, %02x\n", SYMBOL_IN_REG(memPBLAZE[i])->rname, i);
|
17105 |
|
|
+ else if (pblaze_options.dialect)
|
17106 |
|
|
+ fprintf(of, "\tCONSTANT\t%s_%d, %02x\n", SYMBOL_IN_REG(memPBLAZE[i])->rname, memPBLAZE[i].offset, i);
|
17107 |
|
|
+ else if (getSize(operandType(memPBLAZE[i].currOper)) == 1)
|
17108 |
|
|
+ fprintf(of, "\t%s\tEQU $%02x\n", SYMBOL_IN_REG(memPBLAZE[i])->rname, i);
|
17109 |
|
|
+ else
|
17110 |
|
|
+ fprintf(of, "\t%s_%d\tEQU $%02x\n", SYMBOL_IN_REG(memPBLAZE[i])->rname, memPBLAZE[i].offset, i);
|
17111 |
|
|
+ }
|
17112 |
|
|
+ }
|
17113 |
|
|
+ fprintf(of, "\n");
|
17114 |
|
|
+}
|
17115 |
|
|
+
|
17116 |
|
|
+/*-----------------------------------------------------------------*/
|
17117 |
|
|
+/* operName - returns a memory name or a memory adress */
|
17118 |
|
|
+/*-----------------------------------------------------------------*/
|
17119 |
|
|
+char *operName(int addr)
|
17120 |
|
|
+{
|
17121 |
|
|
+ char *s = buffer;
|
17122 |
|
|
+ if (memPBLAZE[addr].isFree || !IS_OP_GLOBAL(memPBLAZE[addr].currOper))
|
17123 |
|
|
+ sprintf(s, "%s%02x", pblaze_options.dialect ? "" : "$", addr);
|
17124 |
|
|
+ else if (getSize(operandType(memPBLAZE[addr].currOper)) == 1)
|
17125 |
|
|
+ sprintf(s, "%s", SYMBOL_IN_REG(memPBLAZE[addr])->rname);
|
17126 |
|
|
+ else
|
17127 |
|
|
+ sprintf(s, "%s_%d", SYMBOL_IN_REG(memPBLAZE[addr])->rname, memPBLAZE[addr].offset);
|
17128 |
|
|
+ return Safe_strdup(s);
|
17129 |
|
|
+}
|
17130 |
|
|
+
|
17131 |
|
|
+/*-----------------------------------------------------------------*/
|
17132 |
|
|
+/* pblaze_regWithIdx - returns pointer to register with index number*/
|
17133 |
|
|
+/*-----------------------------------------------------------------*/
|
17134 |
|
|
+reg_info *pblaze_regWithIdx(int idx)
|
17135 |
|
|
+{
|
17136 |
|
|
+ int i;
|
17137 |
|
|
+
|
17138 |
|
|
+ for (i = 0; i < pblaze_totalRegs; i++)
|
17139 |
|
|
+ if (regsPBLAZE[i].rIdx == idx)
|
17140 |
|
|
+ return ®sPBLAZE[i];
|
17141 |
|
|
+
|
17142 |
|
|
+ werror(E_INTERNAL_ERROR, __FILE__, __LINE__, "regWithIdx not found");
|
17143 |
|
|
+ exit(1);
|
17144 |
|
|
+}
|
17145 |
|
|
+
|
17146 |
|
|
+/*-----------------------------------------------------------------*/
|
17147 |
|
|
+/* check for memory collisions (between data part and the stack */
|
17148 |
|
|
+/*-----------------------------------------------------------------*/
|
17149 |
|
|
+void staticMemoryCheck(int t)
|
17150 |
|
|
+{
|
17151 |
|
|
+ static int top = MEMSIZE - 1;
|
17152 |
|
|
+ if (t >= 0 && t < MEMSIZE)
|
17153 |
|
|
+ top = t;
|
17154 |
|
|
+
|
17155 |
|
|
+ if (!memPBLAZE[top].isFree || memPBLAZE[top].currOper) {
|
17156 |
|
|
+ fprintf(stderr, "pblaze port error: not enough memory\n");
|
17157 |
|
|
+ exit(0);
|
17158 |
|
|
+ }
|
17159 |
|
|
+
|
17160 |
|
|
+}
|
17161 |
|
|
+
|
17162 |
|
|
+/*-----------------------------------------------------------------*/
|
17163 |
|
|
+/* Init stack */
|
17164 |
|
|
+/*-----------------------------------------------------------------*/
|
17165 |
|
|
+void initPBLAZEStack(void)
|
17166 |
|
|
+{
|
17167 |
|
|
+ // top of the stack pointer
|
17168 |
|
|
+ reg_info *rStack;
|
17169 |
|
|
+ //pblaze_nRegs = 15;
|
17170 |
|
|
+ rStack = pblaze_regWithIdx(SF_IDX);
|
17171 |
|
|
+ rStack->currOper = NULL;
|
17172 |
|
|
+ rStack->isFree = 0;
|
17173 |
|
|
+ rStack->isReserved = 1;
|
17174 |
|
|
+
|
17175 |
|
|
+}
|
17176 |
|
|
+
|
17177 |
|
|
+/*-----------------------------------------------------------------*/
|
17178 |
|
|
+/* firstFreeReg - returns first free register */
|
17179 |
|
|
+/*-----------------------------------------------------------------*/
|
17180 |
|
|
+static reg_info *firstFreeReg(void)
|
17181 |
|
|
+{
|
17182 |
|
|
+ int i;
|
17183 |
|
|
+
|
17184 |
|
|
+ for (i = 0; i < pblaze_nRegs; i++) {
|
17185 |
|
|
+ if (regsPBLAZE[i].isFree == 1 && regsPBLAZE[i].isReserved == 0)
|
17186 |
|
|
+ return ®sPBLAZE[i];
|
17187 |
|
|
+ }
|
17188 |
|
|
+
|
17189 |
|
|
+ return NULL;
|
17190 |
|
|
+}
|
17191 |
|
|
+
|
17192 |
|
|
+/*-----------------------------------------------------------------*/
|
17193 |
|
|
+/* firstFreeMem - returns first free register */
|
17194 |
|
|
+/*-----------------------------------------------------------------*/
|
17195 |
|
|
+memMap *firstFreeMem(void)
|
17196 |
|
|
+{
|
17197 |
|
|
+ int i;
|
17198 |
|
|
+
|
17199 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17200 |
|
|
+ if (memPBLAZE[i].isFree == 1)
|
17201 |
|
|
+ return &memPBLAZE[i];
|
17202 |
|
|
+ }
|
17203 |
|
|
+
|
17204 |
|
|
+ return NULL;
|
17205 |
|
|
+}
|
17206 |
|
|
+
|
17207 |
|
|
+/*-----------------------------------------------------------------*/
|
17208 |
|
|
+/* isOpInReg - test if operand is in registers */
|
17209 |
|
|
+/*-----------------------------------------------------------------*/
|
17210 |
|
|
+int isOpInReg(operand * op)
|
17211 |
|
|
+{
|
17212 |
|
|
+ int i, found = 0;
|
17213 |
|
|
+
|
17214 |
|
|
+ if (!op)
|
17215 |
|
|
+ return 0;
|
17216 |
|
|
+
|
17217 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
17218 |
|
|
+ if (regsPBLAZE[i].currOper && pblaze_operandsEqu(op, regsPBLAZE[i].currOper)) {
|
17219 |
|
|
+ found++;
|
17220 |
|
|
+ }
|
17221 |
|
|
+ }
|
17222 |
|
|
+
|
17223 |
|
|
+ return found;
|
17224 |
|
|
+}
|
17225 |
|
|
+
|
17226 |
|
|
+
|
17227 |
|
|
+/*-----------------------------------------------------------------*/
|
17228 |
|
|
+/* isOffsetInReg - test if operand's offset is in registers */
|
17229 |
|
|
+/*-----------------------------------------------------------------*/
|
17230 |
|
|
+reg_info *isOffsetInReg(operand * op, int offset)
|
17231 |
|
|
+{
|
17232 |
|
|
+ int i;
|
17233 |
|
|
+
|
17234 |
|
|
+ if (!op)
|
17235 |
|
|
+ return NULL;
|
17236 |
|
|
+
|
17237 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
17238 |
|
|
+ if (regsPBLAZE[i].currOper && pblaze_operandsEqu(op, regsPBLAZE[i].currOper) && regsPBLAZE[i].offset == offset) {
|
17239 |
|
|
+ return ®sPBLAZE[i];
|
17240 |
|
|
+ }
|
17241 |
|
|
+ }
|
17242 |
|
|
+
|
17243 |
|
|
+ return NULL;
|
17244 |
|
|
+}
|
17245 |
|
|
+
|
17246 |
|
|
+/*-----------------------------------------------------------------*/
|
17247 |
|
|
+/* isOffsetInMem - test if operand's offset is in the memory */
|
17248 |
|
|
+/* returns pointer into memory */
|
17249 |
|
|
+/*-----------------------------------------------------------------*/
|
17250 |
|
|
+memMap *isOffsetInMem(operand * op, int offset)
|
17251 |
|
|
+{
|
17252 |
|
|
+ int i;
|
17253 |
|
|
+ if (op == NULL || op->type != SYMBOL)
|
17254 |
|
|
+ return NULL;
|
17255 |
|
|
+
|
17256 |
|
|
+ if (!op)
|
17257 |
|
|
+ return NULL;
|
17258 |
|
|
+
|
17259 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17260 |
|
|
+ if (memPBLAZE[i].currOper && pblaze_operandsEqu(op, memPBLAZE[i].currOper)) {
|
17261 |
|
|
+ if (memPBLAZE[i].offset == offset)
|
17262 |
|
|
+ return &memPBLAZE[i];
|
17263 |
|
|
+ }
|
17264 |
|
|
+ }
|
17265 |
|
|
+
|
17266 |
|
|
+ return NULL;
|
17267 |
|
|
+}
|
17268 |
|
|
+
|
17269 |
|
|
+/*-----------------------------------------------------------------*/
|
17270 |
|
|
+/* isOpInMem - test if symbol is in the memory */
|
17271 |
|
|
+/* returns pointer into memory */
|
17272 |
|
|
+/*-----------------------------------------------------------------*/
|
17273 |
|
|
+memMap *isOpInMem(operand * op)
|
17274 |
|
|
+{
|
17275 |
|
|
+ int i, size, found = 0;
|
17276 |
|
|
+ memMap *m = NULL;
|
17277 |
|
|
+ if (op == NULL || op->type != SYMBOL)
|
17278 |
|
|
+ return NULL;
|
17279 |
|
|
+
|
17280 |
|
|
+ symbol *s = OP_SYMBOL(op);
|
17281 |
|
|
+
|
17282 |
|
|
+ if (!op)
|
17283 |
|
|
+ return NULL;
|
17284 |
|
|
+
|
17285 |
|
|
+ size = getSize(s->type);
|
17286 |
|
|
+
|
17287 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17288 |
|
|
+ if (memPBLAZE[i].currOper && pblaze_operandsEqu(op, memPBLAZE[i].currOper)) {
|
17289 |
|
|
+ found++;
|
17290 |
|
|
+ if (m == NULL)
|
17291 |
|
|
+ m = &memPBLAZE[i];
|
17292 |
|
|
+ }
|
17293 |
|
|
+ }
|
17294 |
|
|
+
|
17295 |
|
|
+ if (found == size)
|
17296 |
|
|
+ return m;
|
17297 |
|
|
+ return NULL;
|
17298 |
|
|
+
|
17299 |
|
|
+}
|
17300 |
|
|
+
|
17301 |
|
|
+/*-----------------------------------------------------------------*/
|
17302 |
|
|
+/* lockReg - set a register as reserved */
|
17303 |
|
|
+/*-----------------------------------------------------------------*/
|
17304 |
|
|
+void lockReg(reg_info * r)
|
17305 |
|
|
+{
|
17306 |
|
|
+ r->isReserved = 1;
|
17307 |
|
|
+}
|
17308 |
|
|
+
|
17309 |
|
|
+/*-----------------------------------------------------------------*/
|
17310 |
|
|
+/* unlockReg - unset a register as reserved */
|
17311 |
|
|
+/*-----------------------------------------------------------------*/
|
17312 |
|
|
+void unlockReg(reg_info * r)
|
17313 |
|
|
+{
|
17314 |
|
|
+ if (r->rIdx < pblaze_nRegs)
|
17315 |
|
|
+ r->isReserved = 0;
|
17316 |
|
|
+}
|
17317 |
|
|
+
|
17318 |
|
|
+/*-----------------------------------------------------------------*/
|
17319 |
|
|
+/* freeReg - frees a register */
|
17320 |
|
|
+/*-----------------------------------------------------------------*/
|
17321 |
|
|
+static void freeReg(reg_info * reg)
|
17322 |
|
|
+{
|
17323 |
|
|
+ if (reg) {
|
17324 |
|
|
+ reg->isFree = 1;
|
17325 |
|
|
+ reg->currOper = NULL;
|
17326 |
|
|
+ reg->offset = 0;
|
17327 |
|
|
+ reg->ptrOffset = 0;
|
17328 |
|
|
+ reg->isReserved = 0;
|
17329 |
|
|
+ reg->changed = SAME_VAL;
|
17330 |
|
|
+ }
|
17331 |
|
|
+}
|
17332 |
|
|
+
|
17333 |
|
|
+/*-----------------------------------------------------------------*/
|
17334 |
|
|
+/* freeMem - frees a memory cell */
|
17335 |
|
|
+/*-----------------------------------------------------------------*/
|
17336 |
|
|
+static void freeMem(memMap * mem)
|
17337 |
|
|
+{
|
17338 |
|
|
+ if (mem) {
|
17339 |
|
|
+ mem->currOper = NULL;
|
17340 |
|
|
+ mem->offset = 0;
|
17341 |
|
|
+ mem->ptrOffset = 0;
|
17342 |
|
|
+ mem->nextPart = -1;
|
17343 |
|
|
+ mem->reserved = 0;
|
17344 |
|
|
+ mem->isGlobal = 0;
|
17345 |
|
|
+ mem->isFree = 1;
|
17346 |
|
|
+ mem->isOnlyInMem = 0;
|
17347 |
|
|
+ }
|
17348 |
|
|
+}
|
17349 |
|
|
+
|
17350 |
|
|
+/*-----------------------------------------------------------------*/
|
17351 |
|
|
+/* initPBLAZEMem - init PicoBlaze memory */
|
17352 |
|
|
+/*-----------------------------------------------------------------*/
|
17353 |
|
|
+void initPBLAZEMem(void)
|
17354 |
|
|
+{
|
17355 |
|
|
+ int i;
|
17356 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17357 |
|
|
+
|
17358 |
|
|
+ memPBLAZE[i].addr = i;
|
17359 |
|
|
+ memPBLAZE[i].currOper = NULL;
|
17360 |
|
|
+ memPBLAZE[i].offset = 0;
|
17361 |
|
|
+ memPBLAZE[i].ptrOffset = 0;
|
17362 |
|
|
+ memPBLAZE[i].nextPart = -1;
|
17363 |
|
|
+ memPBLAZE[i].reserved = 0;
|
17364 |
|
|
+ memPBLAZE[i].isGlobal = 0;
|
17365 |
|
|
+ memPBLAZE[i].isFree = 1;
|
17366 |
|
|
+ memPBLAZE[i].isOnlyInMem = 0;
|
17367 |
|
|
+
|
17368 |
|
|
+ }
|
17369 |
|
|
+}
|
17370 |
|
|
+
|
17371 |
|
|
+/*-----------------------------------------------------------------*/
|
17372 |
|
|
+/* freeOpFromReg - frees an operand from registers */
|
17373 |
|
|
+/*-----------------------------------------------------------------*/
|
17374 |
|
|
+void freeOpFromReg(operand * op)
|
17375 |
|
|
+{
|
17376 |
|
|
+ int i, size;
|
17377 |
|
|
+ symbol *s;
|
17378 |
|
|
+ reg_info *rtmp;
|
17379 |
|
|
+
|
17380 |
|
|
+ if (!op)
|
17381 |
|
|
+ return;
|
17382 |
|
|
+
|
17383 |
|
|
+ s = OP_SYMBOL(op);
|
17384 |
|
|
+ size = getSize(operandType(op));
|
17385 |
|
|
+
|
17386 |
|
|
+ for (i = 0; i < size; i++) {
|
17387 |
|
|
+ if (s->regs[i]) {
|
17388 |
|
|
+ rtmp = s->regs[i];
|
17389 |
|
|
+ s->regs[i] = NULL;
|
17390 |
|
|
+ freeReg(rtmp);
|
17391 |
|
|
+ }
|
17392 |
|
|
+ }
|
17393 |
|
|
+ s->nRegs = 0;
|
17394 |
|
|
+}
|
17395 |
|
|
+
|
17396 |
|
|
+/*-----------------------------------------------------------------*/
|
17397 |
|
|
+/* freeOffsetFromReg - frees an operand offset from registers */
|
17398 |
|
|
+/*-----------------------------------------------------------------*/
|
17399 |
|
|
+void freeOffsetFromReg(operand * op, int offset)
|
17400 |
|
|
+{
|
17401 |
|
|
+ if (!op)
|
17402 |
|
|
+ return;
|
17403 |
|
|
+
|
17404 |
|
|
+ symbol *s = OP_SYMBOL(op);
|
17405 |
|
|
+ reg_info *rtmp;
|
17406 |
|
|
+
|
17407 |
|
|
+ if (s->regs[offset]) {
|
17408 |
|
|
+ rtmp = s->regs[offset];
|
17409 |
|
|
+ s->regs[offset] = NULL;
|
17410 |
|
|
+ freeReg(rtmp);
|
17411 |
|
|
+ }
|
17412 |
|
|
+}
|
17413 |
|
|
+
|
17414 |
|
|
+/*-----------------------------------------------------------------*/
|
17415 |
|
|
+/* freeOpFromMem - frees an operand from the memory */
|
17416 |
|
|
+/*-----------------------------------------------------------------*/
|
17417 |
|
|
+void freeOpFromMem(operand * op)
|
17418 |
|
|
+{
|
17419 |
|
|
+ int i;
|
17420 |
|
|
+
|
17421 |
|
|
+ if (!op)
|
17422 |
|
|
+ return;
|
17423 |
|
|
+
|
17424 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17425 |
|
|
+ if (memPBLAZE[i].currOper == op) {
|
17426 |
|
|
+ freeMem(&memPBLAZE[i]);
|
17427 |
|
|
+ }
|
17428 |
|
|
+ }
|
17429 |
|
|
+}
|
17430 |
|
|
+
|
17431 |
|
|
+/*-----------------------------------------------------------------*/
|
17432 |
|
|
+/* freeOffsetFromMem - frees an operand offset from the memory */
|
17433 |
|
|
+/*-----------------------------------------------------------------*/
|
17434 |
|
|
+void freeOffsetFromMem(operand * op, int offset)
|
17435 |
|
|
+{
|
17436 |
|
|
+ int i;
|
17437 |
|
|
+
|
17438 |
|
|
+ if (!op)
|
17439 |
|
|
+ return;
|
17440 |
|
|
+
|
17441 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17442 |
|
|
+ if (memPBLAZE[i].currOper && pblaze_operandsEqu(op, memPBLAZE[i].currOper) && memPBLAZE[i].offset == offset) {
|
17443 |
|
|
+ freeMem(&memPBLAZE[i]);
|
17444 |
|
|
+ }
|
17445 |
|
|
+ }
|
17446 |
|
|
+}
|
17447 |
|
|
+
|
17448 |
|
|
+
|
17449 |
|
|
+/*-----------------------------------------------------------------*/
|
17450 |
|
|
+/* freeOperand - frees an operand */
|
17451 |
|
|
+/*-----------------------------------------------------------------*/
|
17452 |
|
|
+void freeOperand(operand * op)
|
17453 |
|
|
+{
|
17454 |
|
|
+ freeOpFromReg(op);
|
17455 |
|
|
+ freeOpFromMem(op);
|
17456 |
|
|
+}
|
17457 |
|
|
+
|
17458 |
|
|
+/*-----------------------------------------------------------------*/
|
17459 |
|
|
+/* nFreeRegs - returns number of free registers */
|
17460 |
|
|
+/*-----------------------------------------------------------------*/
|
17461 |
|
|
+static int nFreeRegs(void)
|
17462 |
|
|
+{
|
17463 |
|
|
+ int i;
|
17464 |
|
|
+ int nfr = 0;
|
17465 |
|
|
+
|
17466 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++)
|
17467 |
|
|
+ if (regsPBLAZE[i].isFree && regsPBLAZE[i].isReserved == 0)
|
17468 |
|
|
+ nfr++;
|
17469 |
|
|
+ return nfr;
|
17470 |
|
|
+}
|
17471 |
|
|
+
|
17472 |
|
|
+/*-----------------------------------------------------------------*/
|
17473 |
|
|
+/* resetRegs - clear GP registers */
|
17474 |
|
|
+/*-----------------------------------------------------------------*/
|
17475 |
|
|
+void resetRegs(void)
|
17476 |
|
|
+{
|
17477 |
|
|
+ int i;
|
17478 |
|
|
+
|
17479 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
17480 |
|
|
+ if (!regsPBLAZE[i].isReserved)
|
17481 |
|
|
+ freeReg(®sPBLAZE[i]);
|
17482 |
|
|
+ }
|
17483 |
|
|
+}
|
17484 |
|
|
+
|
17485 |
|
|
+/*-----------------------------------------------------------------*/
|
17486 |
|
|
+/* clearUnusedOpFromReg - remove old operands from the registers */
|
17487 |
|
|
+/*-----------------------------------------------------------------*/
|
17488 |
|
|
+int clearUnusedOpFromReg(iCode * ic)
|
17489 |
|
|
+{
|
17490 |
|
|
+ int position, freed = 0, i = 0;
|
17491 |
|
|
+ if (!ic)
|
17492 |
|
|
+ return 0;
|
17493 |
|
|
+
|
17494 |
|
|
+ position = ic->seq;
|
17495 |
|
|
+
|
17496 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
17497 |
|
|
+ if (regsPBLAZE[i].isFree == 0 && regsPBLAZE[i].isReserved == 0 && regsPBLAZE[i].currOper &&
|
17498 |
|
|
+ !isOpVolatile(regsPBLAZE[i].currOper) && OP_LIVETO(regsPBLAZE[i].currOper) < position) {
|
17499 |
|
|
+ if (!IS_OP_GLOBAL(regsPBLAZE[i].currOper) && OP_LIVEFROM(regsPBLAZE[i].currOper) > 0) {
|
17500 |
|
|
+ freeOpFromReg(regsPBLAZE[i].currOper);
|
17501 |
|
|
+ if (i >= SEND_REG_FIRST)
|
17502 |
|
|
+ regsPBLAZE[i].isReserved = 1;
|
17503 |
|
|
+ freed++;
|
17504 |
|
|
+ }
|
17505 |
|
|
+ }
|
17506 |
|
|
+ }
|
17507 |
|
|
+
|
17508 |
|
|
+ return freed;
|
17509 |
|
|
+}
|
17510 |
|
|
+
|
17511 |
|
|
+/*-----------------------------------------------------------------*/
|
17512 |
|
|
+/* clearUnusedOpFromMem - remove old operands from the memory */
|
17513 |
|
|
+/*-----------------------------------------------------------------*/
|
17514 |
|
|
+int clearUnusedOpFromMem(iCode * ic)
|
17515 |
|
|
+{
|
17516 |
|
|
+ int position, freed = 0, i = 0;
|
17517 |
|
|
+ if (!ic)
|
17518 |
|
|
+ return 0;
|
17519 |
|
|
+
|
17520 |
|
|
+ position = ic->seq;
|
17521 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17522 |
|
|
+
|
17523 |
|
|
+ if (memPBLAZE[i].isFree == 0 && memPBLAZE[i].currOper && !IS_OP_GLOBAL(memPBLAZE[i].currOper) &&
|
17524 |
|
|
+ OP_LIVETO(memPBLAZE[i].currOper) != 0 && OP_LIVETO(memPBLAZE[i].currOper) < position) {
|
17525 |
|
|
+
|
17526 |
|
|
+ freeMem(&memPBLAZE[i]);
|
17527 |
|
|
+ freed++;
|
17528 |
|
|
+ }
|
17529 |
|
|
+ }
|
17530 |
|
|
+
|
17531 |
|
|
+ return freed;
|
17532 |
|
|
+}
|
17533 |
|
|
+
|
17534 |
|
|
+/*-----------------------------------------------------------------*/
|
17535 |
|
|
+/* clearMemEndFunc - clear memory at the end of a current function */
|
17536 |
|
|
+/*-----------------------------------------------------------------*/
|
17537 |
|
|
+void clearMemEndFunc(void)
|
17538 |
|
|
+{
|
17539 |
|
|
+ int i;
|
17540 |
|
|
+
|
17541 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17542 |
|
|
+
|
17543 |
|
|
+ if (memPBLAZE[i].isFree == 0 && memPBLAZE[i].currOper && !IS_OP_GLOBAL(memPBLAZE[i].currOper)) {
|
17544 |
|
|
+ freeMem(&memPBLAZE[i]);
|
17545 |
|
|
+ }
|
17546 |
|
|
+ }
|
17547 |
|
|
+}
|
17548 |
|
|
+
|
17549 |
|
|
+/*-----------------------------------------------------------------*/
|
17550 |
|
|
+/* getMemoryBlock - return last memory cell number with current size */
|
17551 |
|
|
+/*-----------------------------------------------------------------*/
|
17552 |
|
|
+int getMemoryBlock(int size)
|
17553 |
|
|
+{
|
17554 |
|
|
+ int i, count = 0;
|
17555 |
|
|
+
|
17556 |
|
|
+ for (i = 0; i < MEMSIZE; i++) {
|
17557 |
|
|
+ if (memPBLAZE[i].isFree == 1 && memPBLAZE[i].isGlobal == 0) {
|
17558 |
|
|
+ count++;
|
17559 |
|
|
+ if (size <= count)
|
17560 |
|
|
+ return i;
|
17561 |
|
|
+ } else {
|
17562 |
|
|
+ count = 0;
|
17563 |
|
|
+ }
|
17564 |
|
|
+ }
|
17565 |
|
|
+
|
17566 |
|
|
+ //werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "cannot allocate memory for a global variable");
|
17567 |
|
|
+ fprintf(stderr, "%s:%d: pblaze port error: cannot allocate memory for a global variable\n", __FILE__, __LINE__);
|
17568 |
|
|
+ exit(1);
|
17569 |
|
|
+ return -1;
|
17570 |
|
|
+}
|
17571 |
|
|
+
|
17572 |
|
|
+
|
17573 |
|
|
+/*-----------------------------------------------------------------*/
|
17574 |
|
|
+/* set operand in registers as reserved */
|
17575 |
|
|
+/*-----------------------------------------------------------------*/
|
17576 |
|
|
+void setReserved(operand * oper)
|
17577 |
|
|
+{
|
17578 |
|
|
+ int size, i;
|
17579 |
|
|
+
|
17580 |
|
|
+ if (oper->type != SYMBOL)
|
17581 |
|
|
+ return;
|
17582 |
|
|
+
|
17583 |
|
|
+ symbol *s = OP_SYMBOL(oper);
|
17584 |
|
|
+ size = getSize(s->type);
|
17585 |
|
|
+
|
17586 |
|
|
+ if (s->nRegs == 0)
|
17587 |
|
|
+ return;
|
17588 |
|
|
+
|
17589 |
|
|
+ for (i = 0; i < size; i++) {
|
17590 |
|
|
+
|
17591 |
|
|
+ s->regs[i]->isReserved = 1;
|
17592 |
|
|
+
|
17593 |
|
|
+ }
|
17594 |
|
|
+}
|
17595 |
|
|
+
|
17596 |
|
|
+/*-----------------------------------------------------------------*/
|
17597 |
|
|
+/* unset operand in registers as reserved */
|
17598 |
|
|
+/*-----------------------------------------------------------------*/
|
17599 |
|
|
+void unSetReserved(operand * oper)
|
17600 |
|
|
+{
|
17601 |
|
|
+ int size, i;
|
17602 |
|
|
+
|
17603 |
|
|
+ if (oper->type != SYMBOL)
|
17604 |
|
|
+ return;
|
17605 |
|
|
+
|
17606 |
|
|
+ symbol *s = OP_SYMBOL(oper);
|
17607 |
|
|
+ size = getSize(s->type);
|
17608 |
|
|
+
|
17609 |
|
|
+ if (s->nRegs == 0)
|
17610 |
|
|
+ return;
|
17611 |
|
|
+
|
17612 |
|
|
+ for (i = 0; i < size; i++) {
|
17613 |
|
|
+ if (s->regs[i]->rIdx < pblaze_nRegs)
|
17614 |
|
|
+ s->regs[i]->isReserved = 0;
|
17615 |
|
|
+
|
17616 |
|
|
+ }
|
17617 |
|
|
+}
|
17618 |
|
|
+
|
17619 |
|
|
+/*-----------------------------------------------------------------*/
|
17620 |
|
|
+/* allocOpInMem - alloc operand in the memory */
|
17621 |
|
|
+/*-----------------------------------------------------------------*/
|
17622 |
|
|
+void allocOpInMem(operand * op)
|
17623 |
|
|
+{
|
17624 |
|
|
+ int size, i, pos, next = -1;
|
17625 |
|
|
+ memMap *m;
|
17626 |
|
|
+
|
17627 |
|
|
+ if (isOpInMem(op))
|
17628 |
|
|
+ return;
|
17629 |
|
|
+
|
17630 |
|
|
+ size = getSize(operandType(op));
|
17631 |
|
|
+ pos = getMemoryBlock(size);
|
17632 |
|
|
+
|
17633 |
|
|
+ for (i = 0; i < size; i++) {
|
17634 |
|
|
+ m = &memPBLAZE[pos];
|
17635 |
|
|
+ m->currOper = op;
|
17636 |
|
|
+ m->isFree = 0;
|
17637 |
|
|
+ m->isGlobal = IS_OP_GLOBAL(op);
|
17638 |
|
|
+ m->offset = i;
|
17639 |
|
|
+ m->ptrOffset = 0;
|
17640 |
|
|
+ m->nextPart = next;
|
17641 |
|
|
+ next = pos--;
|
17642 |
|
|
+ }
|
17643 |
|
|
+
|
17644 |
|
|
+}
|
17645 |
|
|
+
|
17646 |
|
|
+
|
17647 |
|
|
+
|
17648 |
|
|
+/*-----------------------------------------------------------------*/
|
17649 |
|
|
+/* moveOpToMem - move operand from registers to memory */
|
17650 |
|
|
+/*-----------------------------------------------------------------*/
|
17651 |
|
|
+void moveOpToMem(operand * op)
|
17652 |
|
|
+{
|
17653 |
|
|
+ if (!op) {
|
17654 |
|
|
+ return;
|
17655 |
|
|
+ }
|
17656 |
|
|
+
|
17657 |
|
|
+ int size, i, next = -1;
|
17658 |
|
|
+ memMap *m, *t;
|
17659 |
|
|
+ symbol *s = OP_SYMBOL(op);
|
17660 |
|
|
+
|
17661 |
|
|
+ size = getSize(s->type);
|
17662 |
|
|
+
|
17663 |
|
|
+ for (i = size - 1; i >= 0; i--) {
|
17664 |
|
|
+ /* this offset is in the memory */
|
17665 |
|
|
+ if (s->regs[i] == NULL && (t = isOffsetInMem(op, i)) != NULL) {
|
17666 |
|
|
+ next = t->addr;
|
17667 |
|
|
+ }
|
17668 |
|
|
+ /* offset is in the registers */
|
17669 |
|
|
+ else if (s->regs[i]) {
|
17670 |
|
|
+ // try to get a pointer, if it is a global variable
|
17671 |
|
|
+ if (IS_OP_GLOBAL(op) && (m = isOffsetInMem(op, i)) != NULL) {
|
17672 |
|
|
+ } else
|
17673 |
|
|
+ m = firstFreeMem();
|
17674 |
|
|
+
|
17675 |
|
|
+ if (!m) {
|
17676 |
|
|
+ fprintf(stderr, "%s:%d: pblaze port error: not enough memory\n", __FILE__, __LINE__);
|
17677 |
|
|
+ exit(1);
|
17678 |
|
|
+ }
|
17679 |
|
|
+ //emitcode ("STORE", "%s, %02x", s->regs[i]->name , m->addr );
|
17680 |
|
|
+ emitStore(s->regs[i]->name, m->addr);
|
17681 |
|
|
+
|
17682 |
|
|
+ m->currOper = op;
|
17683 |
|
|
+ m->isFree = 0;
|
17684 |
|
|
+ m->isGlobal = IS_OP_GLOBAL(op);
|
17685 |
|
|
+ m->offset = i;
|
17686 |
|
|
+ m->ptrOffset = s->regs[i]->ptrOffset;
|
17687 |
|
|
+ m->nextPart = next;
|
17688 |
|
|
+ next = m->addr;
|
17689 |
|
|
+ }
|
17690 |
|
|
+ }
|
17691 |
|
|
+
|
17692 |
|
|
+ freeOpFromReg(op);
|
17693 |
|
|
+}
|
17694 |
|
|
+
|
17695 |
|
|
+/*-----------------------------------------------------------------*/
|
17696 |
|
|
+/* moveOffsetToMem - move operand's offset from registers to memory*/
|
17697 |
|
|
+/*-----------------------------------------------------------------*/
|
17698 |
|
|
+void moveOffsetToMem(operand * op, int offset)
|
17699 |
|
|
+{
|
17700 |
|
|
+ if (!op) {
|
17701 |
|
|
+ return;
|
17702 |
|
|
+ }
|
17703 |
|
|
+
|
17704 |
|
|
+ memMap *m, *t;
|
17705 |
|
|
+ symbol *s = OP_SYMBOL(op);
|
17706 |
|
|
+
|
17707 |
|
|
+ // move all registers if it is a global operand
|
17708 |
|
|
+ if (IS_OP_GLOBAL(op))
|
17709 |
|
|
+ moveOpToMem(op);
|
17710 |
|
|
+
|
17711 |
|
|
+ // not a global operand
|
17712 |
|
|
+ else if (offset >= 0 && s->regs[offset] != NULL) {
|
17713 |
|
|
+ m = isOffsetInMem(op, offset);
|
17714 |
|
|
+ if (!m)
|
17715 |
|
|
+ m = firstFreeMem();
|
17716 |
|
|
+
|
17717 |
|
|
+ if (!m) {
|
17718 |
|
|
+ fprintf(stderr, "%s:%d: pblaze port error: not enough memory\n", __FILE__, __LINE__);
|
17719 |
|
|
+ exit(1);
|
17720 |
|
|
+ }
|
17721 |
|
|
+ //emitcode ("STORE", "%s, %02x", s->regs[offset]->name , m->addr );
|
17722 |
|
|
+ emitStore(s->regs[offset]->name, m->addr);
|
17723 |
|
|
+
|
17724 |
|
|
+ m->currOper = op;
|
17725 |
|
|
+ m->isFree = 0;
|
17726 |
|
|
+ m->isGlobal = IS_OP_GLOBAL(op);
|
17727 |
|
|
+ m->offset = offset;
|
17728 |
|
|
+ m->ptrOffset = s->regs[offset]->ptrOffset;
|
17729 |
|
|
+ t = isOffsetInMem(op, offset + 1);
|
17730 |
|
|
+ if (t == NULL)
|
17731 |
|
|
+ m->nextPart = -1;
|
17732 |
|
|
+ else
|
17733 |
|
|
+ m->nextPart = t->addr;
|
17734 |
|
|
+
|
17735 |
|
|
+ // free operand's offset
|
17736 |
|
|
+ freeOffsetFromReg(op, offset);
|
17737 |
|
|
+ }
|
17738 |
|
|
+}
|
17739 |
|
|
+
|
17740 |
|
|
+
|
17741 |
|
|
+/*-----------------------------------------------------------------*/
|
17742 |
|
|
+/* bitVectRemainRegs - returns sum of a bit values */
|
17743 |
|
|
+/*-----------------------------------------------------------------*/
|
17744 |
|
|
+int bitVectRemainRegs(bitVect * bv)
|
17745 |
|
|
+{
|
17746 |
|
|
+ int i, c = 0;
|
17747 |
|
|
+
|
17748 |
|
|
+ if (!bv)
|
17749 |
|
|
+ return 0;
|
17750 |
|
|
+
|
17751 |
|
|
+ for (i = 0; i < bv->size; i++)
|
17752 |
|
|
+ c += bitVectBitValue(bv, i);
|
17753 |
|
|
+ return c;
|
17754 |
|
|
+}
|
17755 |
|
|
+
|
17756 |
|
|
+
|
17757 |
|
|
+/*-----------------------------------------------------------------*/
|
17758 |
|
|
+/* firstIC5 - returns iCode of the first instruction from IC5 instr*/
|
17759 |
|
|
+/*-----------------------------------------------------------------*/
|
17760 |
|
|
+iCode *firstIC5(iCode * ic)
|
17761 |
|
|
+{
|
17762 |
|
|
+ iCode *tic;
|
17763 |
|
|
+ if (!ic)
|
17764 |
|
|
+ return NULL;
|
17765 |
|
|
+
|
17766 |
|
|
+ tic = ic;
|
17767 |
|
|
+ while (tic) {
|
17768 |
|
|
+ if (SKIP_IC5(tic))
|
17769 |
|
|
+ break;
|
17770 |
|
|
+
|
17771 |
|
|
+ tic = tic->next;
|
17772 |
|
|
+ }
|
17773 |
|
|
+ return tic;
|
17774 |
|
|
+}
|
17775 |
|
|
+
|
17776 |
|
|
+/*-----------------------------------------------------------------*/
|
17777 |
|
|
+/* blockStart - returns iCode of the start of a block */
|
17778 |
|
|
+/*-----------------------------------------------------------------*/
|
17779 |
|
|
+iCode *blockStart(iCode * ic)
|
17780 |
|
|
+{
|
17781 |
|
|
+ iCode *tic;
|
17782 |
|
|
+ if (!ic)
|
17783 |
|
|
+ return NULL;
|
17784 |
|
|
+
|
17785 |
|
|
+ tic = ic;
|
17786 |
|
|
+ while (tic->prev) {
|
17787 |
|
|
+ if (SKIP_IC2(tic->prev) || tic->prev->op == IFX)
|
17788 |
|
|
+ break;
|
17789 |
|
|
+
|
17790 |
|
|
+ tic = tic->prev;
|
17791 |
|
|
+ }
|
17792 |
|
|
+ return tic;
|
17793 |
|
|
+}
|
17794 |
|
|
+
|
17795 |
|
|
+/*-----------------------------------------------------------------*/
|
17796 |
|
|
+/* blockEnd - returns iCode of the end of a block */
|
17797 |
|
|
+/*-----------------------------------------------------------------*/
|
17798 |
|
|
+iCode *blockEnd(iCode * ic)
|
17799 |
|
|
+{
|
17800 |
|
|
+ iCode *tic;
|
17801 |
|
|
+ if (!ic)
|
17802 |
|
|
+ return NULL;
|
17803 |
|
|
+
|
17804 |
|
|
+ tic = ic;
|
17805 |
|
|
+ while (tic->next) {
|
17806 |
|
|
+ if (SKIP_IC2(tic->next) || tic->next->op == IFX)
|
17807 |
|
|
+ break;
|
17808 |
|
|
+
|
17809 |
|
|
+ tic = tic->next;
|
17810 |
|
|
+ }
|
17811 |
|
|
+ return tic;
|
17812 |
|
|
+}
|
17813 |
|
|
+
|
17814 |
|
|
+/*-----------------------------------------------------------------*/
|
17815 |
|
|
+/* assignOptTest - checking whether the assignment can be optimized*/
|
17816 |
|
|
+/* there can be some conflict in IFX */
|
17817 |
|
|
+/*-----------------------------------------------------------------*/
|
17818 |
|
|
+int testIFXConflict(iCode * lic, operand * to)
|
17819 |
|
|
+{
|
17820 |
|
|
+ iCode *ic, *ifxs, *ifxe;
|
17821 |
|
|
+ short isIFX = 0;
|
17822 |
|
|
+ short isIFEND = 0;
|
17823 |
|
|
+ short isAssign = 0;
|
17824 |
|
|
+ short isGoto = 0;
|
17825 |
|
|
+
|
17826 |
|
|
+ if (!lic)
|
17827 |
|
|
+ return 1;
|
17828 |
|
|
+
|
17829 |
|
|
+ /* check whether we are nested in ifx */
|
17830 |
|
|
+ for (ic = lic; ic; ic = ic->prev) {
|
17831 |
|
|
+
|
17832 |
|
|
+ if (ic->op == IFX) {
|
17833 |
|
|
+ isIFX = 1;
|
17834 |
|
|
+ ifxs = ic;
|
17835 |
|
|
+ break;
|
17836 |
|
|
+ } else if (IS_ENDLABEL(ic))
|
17837 |
|
|
+ break;
|
17838 |
|
|
+ }
|
17839 |
|
|
+
|
17840 |
|
|
+ if (!isIFX)
|
17841 |
|
|
+ return 1;
|
17842 |
|
|
+
|
17843 |
|
|
+ /* find end of the current IFX */
|
17844 |
|
|
+ for (ic = lic->next; ic; ic = ic->next) {
|
17845 |
|
|
+ if (IS_ENDLABEL(ic)) {
|
17846 |
|
|
+ isIFEND = 1;
|
17847 |
|
|
+ ifxe = ic;
|
17848 |
|
|
+ break;
|
17849 |
|
|
+ }
|
17850 |
|
|
+ }
|
17851 |
|
|
+
|
17852 |
|
|
+ if (!isIFEND)
|
17853 |
|
|
+ return 0;
|
17854 |
|
|
+
|
17855 |
|
|
+ /* find assing conflicts (forward) */
|
17856 |
|
|
+ for (ic = lic->next; ic && ic != ifxe; ic = ic->next) {
|
17857 |
|
|
+ if (ic->op == GOTO)
|
17858 |
|
|
+ isGoto = 1;
|
17859 |
|
|
+ else if (!SKIP_NO_OP(ic) && isGoto) {
|
17860 |
|
|
+ if (IC_RESULT(ic) && pblaze_operandsEqu(to, IC_RESULT(ic)))
|
17861 |
|
|
+ return 0;
|
17862 |
|
|
+ else if (IC_RIGHT(ic) && pblaze_operandsEqu(to, IC_RIGHT(ic)))
|
17863 |
|
|
+ return 0;
|
17864 |
|
|
+ else if (IC_LEFT(ic) && pblaze_operandsEqu(to, IC_LEFT(ic)))
|
17865 |
|
|
+ return 0;
|
17866 |
|
|
+ }
|
17867 |
|
|
+ }
|
17868 |
|
|
+
|
17869 |
|
|
+ isGoto = 0;
|
17870 |
|
|
+
|
17871 |
|
|
+ /* find assing conflicts (backward) */
|
17872 |
|
|
+ for (ic = lic; ic && ic != ifxs; ic = ic->prev) {
|
17873 |
|
|
+ if (ic->op == GOTO)
|
17874 |
|
|
+ isGoto = 1;
|
17875 |
|
|
+ else if (IS_ENDLABEL(ic))
|
17876 |
|
|
+ break;
|
17877 |
|
|
+ else if (!SKIP_NO_OP(ic) && isGoto) {
|
17878 |
|
|
+ if (IC_RESULT(ic) && pblaze_operandsEqu(to, IC_RESULT(ic)))
|
17879 |
|
|
+ return 0;
|
17880 |
|
|
+ else if (IC_RIGHT(ic) && pblaze_operandsEqu(to, IC_RIGHT(ic)))
|
17881 |
|
|
+ return 0;
|
17882 |
|
|
+ else if (IC_LEFT(ic) && pblaze_operandsEqu(to, IC_LEFT(ic)))
|
17883 |
|
|
+ return 0;
|
17884 |
|
|
+ }
|
17885 |
|
|
+ }
|
17886 |
|
|
+
|
17887 |
|
|
+ return 1;
|
17888 |
|
|
+}
|
17889 |
|
|
+
|
17890 |
|
|
+
|
17891 |
|
|
+/*-----------------------------------------------------------------*/
|
17892 |
|
|
+/* testOperand - LRU operands testing */
|
17893 |
|
|
+/*-----------------------------------------------------------------*/
|
17894 |
|
|
+void testOperand(operand * op, int free, bitVect * rUse)
|
17895 |
|
|
+{
|
17896 |
|
|
+ int sizeInReg, remainOp, size, j;
|
17897 |
|
|
+ reg_info *r;
|
17898 |
|
|
+
|
17899 |
|
|
+ if (!op)
|
17900 |
|
|
+ return;
|
17901 |
|
|
+
|
17902 |
|
|
+ sizeInReg = isOpInReg(op);
|
17903 |
|
|
+ remainOp = bitVectRemainRegs(rUse);
|
17904 |
|
|
+
|
17905 |
|
|
+ if (sizeInReg > 0 && remainOp - sizeInReg >= free) {
|
17906 |
|
|
+ size = getSize(operandType(op));
|
17907 |
|
|
+
|
17908 |
|
|
+ for (j = 0; j < size; j++) {
|
17909 |
|
|
+ r = isOffsetInReg(op, j);
|
17910 |
|
|
+ if (r) {
|
17911 |
|
|
+ bitVectUnSetBit(rUse, r->rIdx);
|
17912 |
|
|
+ }
|
17913 |
|
|
+ }
|
17914 |
|
|
+
|
17915 |
|
|
+ }
|
17916 |
|
|
+}
|
17917 |
|
|
+
|
17918 |
|
|
+int isUsedInCurrentInstr(iCode * ic, operand * op)
|
17919 |
|
|
+{
|
17920 |
|
|
+ int res = 0;
|
17921 |
|
|
+
|
17922 |
|
|
+ if (IC_LEFT(ic) != NULL && pblaze_operandsEqu(IC_LEFT(ic), op)) {
|
17923 |
|
|
+ res = 1;
|
17924 |
|
|
+ }
|
17925 |
|
|
+
|
17926 |
|
|
+ else if (IC_RIGHT(ic) != NULL && pblaze_operandsEqu(IC_RIGHT(ic), op)) {
|
17927 |
|
|
+ res = 1;
|
17928 |
|
|
+ }
|
17929 |
|
|
+
|
17930 |
|
|
+ else if (IC_RESULT(ic) != NULL && pblaze_operandsEqu(IC_RESULT(ic), op)) {
|
17931 |
|
|
+ res = 1;
|
17932 |
|
|
+ }
|
17933 |
|
|
+
|
17934 |
|
|
+ return res;
|
17935 |
|
|
+}
|
17936 |
|
|
+
|
17937 |
|
|
+/*-----------------------------------------------------------------*/
|
17938 |
|
|
+/* spillRegsIntoMem - move LRU operand into memory */
|
17939 |
|
|
+/*-----------------------------------------------------------------*/
|
17940 |
|
|
+int spillRegsIntoMem(iCode * lic, operand * op, int offset, int free)
|
17941 |
|
|
+{
|
17942 |
|
|
+ iCode *ic, *tic;
|
17943 |
|
|
+ bitVect *rUse;
|
17944 |
|
|
+ int remainOp, i, bStart;
|
17945 |
|
|
+
|
17946 |
|
|
+ if (!lic)
|
17947 |
|
|
+ return -1;
|
17948 |
|
|
+ if (free <= 0)
|
17949 |
|
|
+ return 0;
|
17950 |
|
|
+
|
17951 |
|
|
+ // bit vector of used registers
|
17952 |
|
|
+ rUse = newBitVect(pblaze_nRegs);
|
17953 |
|
|
+
|
17954 |
|
|
+ tic = blockStart(lic);
|
17955 |
|
|
+ if (tic)
|
17956 |
|
|
+ bStart = tic->seq;
|
17957 |
|
|
+ else
|
17958 |
|
|
+ bStart = lic->seq;
|
17959 |
|
|
+
|
17960 |
|
|
+ // set vector bits corresponding to used / free registers
|
17961 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
17962 |
|
|
+ if (regsPBLAZE[i].isReserved == 1 || regsPBLAZE[i].isFree == 1 || (bStart > OP_LIVEFROM(regsPBLAZE[i].currOper))
|
17963 |
|
|
+ || (isUsedInCurrentInstr(lic, regsPBLAZE[i].currOper) && regsPBLAZE[i].offset == offset)) {
|
17964 |
|
|
+ bitVectUnSetBit(rUse, i);
|
17965 |
|
|
+ } else {
|
17966 |
|
|
+ bitVectSetBit(rUse, i);
|
17967 |
|
|
+ }
|
17968 |
|
|
+ }
|
17969 |
|
|
+
|
17970 |
|
|
+ if (bitVectRemainRegs(rUse) == 0) {
|
17971 |
|
|
+ return 1;
|
17972 |
|
|
+ }
|
17973 |
|
|
+ // get LRU operand
|
17974 |
|
|
+ for (ic = lic; ic; ic = ic->next) {
|
17975 |
|
|
+
|
17976 |
|
|
+ if (!SKIP_NO_OP(ic)) {
|
17977 |
|
|
+
|
17978 |
|
|
+ if (IC_LEFT(ic) != NULL) {
|
17979 |
|
|
+ testOperand(IC_LEFT(ic), free, rUse);
|
17980 |
|
|
+ }
|
17981 |
|
|
+
|
17982 |
|
|
+ if (IC_RIGHT(ic) != NULL) {
|
17983 |
|
|
+ testOperand(IC_RIGHT(ic), free, rUse);
|
17984 |
|
|
+ }
|
17985 |
|
|
+
|
17986 |
|
|
+ if (IC_RESULT(ic) != NULL) {
|
17987 |
|
|
+ testOperand(IC_RESULT(ic), free, rUse);
|
17988 |
|
|
+ }
|
17989 |
|
|
+
|
17990 |
|
|
+ }
|
17991 |
|
|
+
|
17992 |
|
|
+ remainOp = bitVectRemainRegs(rUse);
|
17993 |
|
|
+
|
17994 |
|
|
+ if (remainOp == free)
|
17995 |
|
|
+ break;
|
17996 |
|
|
+ }
|
17997 |
|
|
+
|
17998 |
|
|
+ // try to move global variable first
|
17999 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
18000 |
|
|
+ if (bitVectBitValue(rUse, i) && IS_OP_GLOBAL(regsPBLAZE[i].currOper) && free > nFreeRegs()) {
|
18001 |
|
|
+ moveOpToMem(regsPBLAZE[i].currOper);
|
18002 |
|
|
+ }
|
18003 |
|
|
+ }
|
18004 |
|
|
+
|
18005 |
|
|
+ // move LRU temp variable into memory
|
18006 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
18007 |
|
|
+ if (bitVectBitValue(rUse, i) && free > nFreeRegs()) {
|
18008 |
|
|
+ moveOffsetToMem(regsPBLAZE[i].currOper, regsPBLAZE[i].offset);
|
18009 |
|
|
+ }
|
18010 |
|
|
+ }
|
18011 |
|
|
+
|
18012 |
|
|
+ //////////////////////////////////////////////////////////////////////////////////////////
|
18013 |
|
|
+ // second selection phase - operand with no assignment conflict (inside IF-ELSE condition)
|
18014 |
|
|
+ if (remainOp == free)
|
18015 |
|
|
+ return 0;
|
18016 |
|
|
+
|
18017 |
|
|
+ /*
|
18018 |
|
|
+
|
18019 |
|
|
+ // set vector bits corresponding to used / free registers
|
18020 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
18021 |
|
|
+ if( regsPBLAZE[i].isReserved == 1 || regsPBLAZE[i].isFree == 1 ) {
|
18022 |
|
|
+ bitVectUnSetBit(rUse,i);
|
18023 |
|
|
+ }
|
18024 |
|
|
+ else {
|
18025 |
|
|
+ bitVectSetBit(rUse,i);
|
18026 |
|
|
+ }
|
18027 |
|
|
+ }
|
18028 |
|
|
+
|
18029 |
|
|
+ for (ic = lic; ic; ic = ic->next) {
|
18030 |
|
|
+
|
18031 |
|
|
+ if( !SKIP_NO_OP(ic) ) {
|
18032 |
|
|
+
|
18033 |
|
|
+ if(IC_LEFT(ic) != NULL && isOpInReg(IC_LEFT(ic)) && !testIFXConflict(ic, IC_LEFT(ic)) ) {
|
18034 |
|
|
+ testOperand(IC_LEFT(ic), 0, rUse);
|
18035 |
|
|
+ }
|
18036 |
|
|
+
|
18037 |
|
|
+ if(IC_RIGHT(ic) != NULL && isOpInReg(IC_RIGHT(ic)) && !testIFXConflict(ic, IC_RIGHT(ic)) ) {
|
18038 |
|
|
+ testOperand(IC_RIGHT(ic), 0, rUse);
|
18039 |
|
|
+ }
|
18040 |
|
|
+
|
18041 |
|
|
+ if(IC_RESULT(ic) != NULL && isOpInReg(IC_RESULT(ic)) && !testIFXConflict(ic, IC_RESULT(ic)) ) {
|
18042 |
|
|
+ testOperand(IC_RESULT(ic), 0, rUse);
|
18043 |
|
|
+ }
|
18044 |
|
|
+
|
18045 |
|
|
+ }
|
18046 |
|
|
+ }
|
18047 |
|
|
+
|
18048 |
|
|
+ // move LRU temp variable into memory
|
18049 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
18050 |
|
|
+ if(bitVectBitValue(rUse,i) && free > nFreeRegs() ) {
|
18051 |
|
|
+ moveOffsetToMem (regsPBLAZE[i].currOper, regsPBLAZE[i].offset);
|
18052 |
|
|
+ }
|
18053 |
|
|
+ }
|
18054 |
|
|
+
|
18055 |
|
|
+ remainOp = bitVectRemainRegs(rUse);
|
18056 |
|
|
+
|
18057 |
|
|
+ */
|
18058 |
|
|
+
|
18059 |
|
|
+ if (nFreeRegs() < free) {
|
18060 |
|
|
+ return 1;
|
18061 |
|
|
+ }
|
18062 |
|
|
+
|
18063 |
|
|
+ return 0;
|
18064 |
|
|
+}
|
18065 |
|
|
+
|
18066 |
|
|
+/*-----------------------------------------------------------------*/
|
18067 |
|
|
+/* globalChanged - global value changed */
|
18068 |
|
|
+/*-----------------------------------------------------------------*/
|
18069 |
|
|
+void globalChanged(operand * op, short c)
|
18070 |
|
|
+{
|
18071 |
|
|
+ int i, size;
|
18072 |
|
|
+
|
18073 |
|
|
+ if (!op)
|
18074 |
|
|
+ return;
|
18075 |
|
|
+
|
18076 |
|
|
+ size = getSize(operandType(op));
|
18077 |
|
|
+
|
18078 |
|
|
+ for (i = 0; i < size; i++) {
|
18079 |
|
|
+ if (OP_SYMBOL(op)->regs[i]) {
|
18080 |
|
|
+ OP_SYMBOL(op)->regs[i]->changed = c;
|
18081 |
|
|
+ }
|
18082 |
|
|
+ }
|
18083 |
|
|
+
|
18084 |
|
|
+}
|
18085 |
|
|
+
|
18086 |
|
|
+/*-----------------------------------------------------------------*/
|
18087 |
|
|
+/* freeGlobalsFromReg - move globals into the memory if changed */
|
18088 |
|
|
+/*-----------------------------------------------------------------*/
|
18089 |
|
|
+void freeGlobalsFromReg(void)
|
18090 |
|
|
+{
|
18091 |
|
|
+ int i;
|
18092 |
|
|
+
|
18093 |
|
|
+ for (i = pblaze_fReg; i < pblaze_nRegs; i++) {
|
18094 |
|
|
+ if (regsPBLAZE[i].currOper && IS_OP_GLOBAL(regsPBLAZE[i].currOper)) {
|
18095 |
|
|
+ if (regsPBLAZE[i].changed == IN_REG) {
|
18096 |
|
|
+ moveOpToMem(regsPBLAZE[i].currOper);
|
18097 |
|
|
+ } else
|
18098 |
|
|
+ freeOpFromReg(regsPBLAZE[i].currOper);
|
18099 |
|
|
+ }
|
18100 |
|
|
+ }
|
18101 |
|
|
+
|
18102 |
|
|
+
|
18103 |
|
|
+}
|
18104 |
|
|
+
|
18105 |
|
|
+/*-----------------------------------------------------------------*/
|
18106 |
|
|
+/* getReg - returns pointer to a free register */
|
18107 |
|
|
+/*-----------------------------------------------------------------*/
|
18108 |
|
|
+reg_info *getReg(iCode * ic)
|
18109 |
|
|
+{
|
18110 |
|
|
+ reg_info *rtmp;
|
18111 |
|
|
+
|
18112 |
|
|
+ clearUnusedOpFromReg(ic);
|
18113 |
|
|
+
|
18114 |
|
|
+ rtmp = firstFreeReg();
|
18115 |
|
|
+ if (rtmp) {
|
18116 |
|
|
+ /* callee saves */
|
18117 |
|
|
+ if (isCalleesaves()) {
|
18118 |
|
|
+ if (!isRegUsed(rtmp->rIdx)) {
|
18119 |
|
|
+ pushStack(rtmp->rIdx, 0);
|
18120 |
|
|
+ }
|
18121 |
|
|
+ setRegUsed(rtmp->rIdx);
|
18122 |
|
|
+ }
|
18123 |
|
|
+
|
18124 |
|
|
+ return rtmp;
|
18125 |
|
|
+ } else {
|
18126 |
|
|
+ rtmp = pblaze_regWithIdx(pblaze_nRegs + ctr);
|
18127 |
|
|
+
|
18128 |
|
|
+ ctr++;
|
18129 |
|
|
+ if (ctr >= SEND_REG_COUNT)
|
18130 |
|
|
+ ctr = 0;
|
18131 |
|
|
+
|
18132 |
|
|
+ return rtmp;
|
18133 |
|
|
+ }
|
18134 |
|
|
+ return NULL;
|
18135 |
|
|
+}
|
18136 |
|
|
+
|
18137 |
|
|
+/*-----------------------------------------------------------------*/
|
18138 |
|
|
+/* getTempReg - returns pointer to a next temp register */
|
18139 |
|
|
+/*-----------------------------------------------------------------*/
|
18140 |
|
|
+reg_info *getTempReg(void)
|
18141 |
|
|
+{
|
18142 |
|
|
+ reg_info *rtmp;
|
18143 |
|
|
+ rtmp = pblaze_regWithIdx(pblaze_nRegs + ctr);
|
18144 |
|
|
+
|
18145 |
|
|
+ ctr++;
|
18146 |
|
|
+ if (ctr >= SEND_REG_COUNT)
|
18147 |
|
|
+ ctr = 0;
|
18148 |
|
|
+
|
18149 |
|
|
+ return rtmp;
|
18150 |
|
|
+}
|
18151 |
|
|
+
|
18152 |
|
|
+/*-----------------------------------------------------------------*/
|
18153 |
|
|
+/* getRegOper - returns pointer to a free register */
|
18154 |
|
|
+/*-----------------------------------------------------------------*/
|
18155 |
|
|
+reg_info *getRegOper(iCode * ic, operand * op, int offset)
|
18156 |
|
|
+{
|
18157 |
|
|
+ reg_info *rtmp;
|
18158 |
|
|
+
|
18159 |
|
|
+ clearUnusedOpFromReg(ic);
|
18160 |
|
|
+ if (nFreeRegs() == 0) {
|
18161 |
|
|
+
|
18162 |
|
|
+ spillRegsIntoMem(ic, op, offset, 1);
|
18163 |
|
|
+
|
18164 |
|
|
+ }
|
18165 |
|
|
+
|
18166 |
|
|
+ rtmp = firstFreeReg();
|
18167 |
|
|
+ if (rtmp) {
|
18168 |
|
|
+ /* callee saves */
|
18169 |
|
|
+ if (isCalleesaves()) {
|
18170 |
|
|
+ if (!isRegUsed(rtmp->rIdx)) {
|
18171 |
|
|
+ pushStack(rtmp->rIdx, 0);
|
18172 |
|
|
+ }
|
18173 |
|
|
+ setRegUsed(rtmp->rIdx);
|
18174 |
|
|
+ }
|
18175 |
|
|
+
|
18176 |
|
|
+ return rtmp;
|
18177 |
|
|
+ } else {
|
18178 |
|
|
+ rtmp = pblaze_regWithIdx(pblaze_nRegs + ctr);
|
18179 |
|
|
+
|
18180 |
|
|
+ ctr++;
|
18181 |
|
|
+ if (ctr >= SEND_REG_COUNT)
|
18182 |
|
|
+ ctr = 0;
|
18183 |
|
|
+
|
18184 |
|
|
+ return rtmp;
|
18185 |
|
|
+ }
|
18186 |
|
|
+ return NULL;
|
18187 |
|
|
+}
|
18188 |
|
|
+
|
18189 |
|
|
+
|
18190 |
|
|
+/*-----------------------------------------------------------------*/
|
18191 |
|
|
+/* assignOptTest - checking whether the assignment can be optimized*/
|
18192 |
|
|
+/* there can be some conflict in IFX */
|
18193 |
|
|
+/*-----------------------------------------------------------------*/
|
18194 |
|
|
+int assignOptTest(iCode * lic, operand * to)
|
18195 |
|
|
+{
|
18196 |
|
|
+ iCode *ic, *ifxs, *ifxe;
|
18197 |
|
|
+ short isIFX = 0;
|
18198 |
|
|
+ short isIFEND = 0;
|
18199 |
|
|
+ short isAssign = 0;
|
18200 |
|
|
+ short isGoto = 0;
|
18201 |
|
|
+
|
18202 |
|
|
+ if (!lic)
|
18203 |
|
|
+ return 1;
|
18204 |
|
|
+
|
18205 |
|
|
+ /* check whether we are nested in ifx */
|
18206 |
|
|
+ for (ic = lic; ic; ic = ic->prev) {
|
18207 |
|
|
+
|
18208 |
|
|
+ if (ic->op == IFX) {
|
18209 |
|
|
+ isIFX = 1;
|
18210 |
|
|
+ ifxs = ic;
|
18211 |
|
|
+ break;
|
18212 |
|
|
+ } else if (IS_ENDLABEL(ic))
|
18213 |
|
|
+ break;
|
18214 |
|
|
+ }
|
18215 |
|
|
+
|
18216 |
|
|
+ if (!isIFX)
|
18217 |
|
|
+ return 1;
|
18218 |
|
|
+
|
18219 |
|
|
+ /* find end of the current IFX */
|
18220 |
|
|
+ for (ic = lic->next; ic; ic = ic->next) {
|
18221 |
|
|
+ if (IS_ENDLABEL(ic)) {
|
18222 |
|
|
+ isIFEND = 1;
|
18223 |
|
|
+ ifxe = ic;
|
18224 |
|
|
+ break;
|
18225 |
|
|
+ }
|
18226 |
|
|
+ }
|
18227 |
|
|
+
|
18228 |
|
|
+ if (!isIFEND)
|
18229 |
|
|
+ return 0;
|
18230 |
|
|
+
|
18231 |
|
|
+ /* find assing conflicts (forward) */
|
18232 |
|
|
+ for (ic = lic->next; ic && ic != ifxe; ic = ic->next) {
|
18233 |
|
|
+ if (ic->op == GOTO)
|
18234 |
|
|
+ isGoto = 1;
|
18235 |
|
|
+ else if (ic->op == '=' && isGoto && pblaze_operandsEqu(to, IC_RESULT(ic))) {
|
18236 |
|
|
+ return 0;
|
18237 |
|
|
+ }
|
18238 |
|
|
+ }
|
18239 |
|
|
+
|
18240 |
|
|
+ isGoto = 0;
|
18241 |
|
|
+
|
18242 |
|
|
+ /* find assing conflicts (backward) */
|
18243 |
|
|
+ for (ic = lic; ic && ic != ifxs; ic = ic->prev) {
|
18244 |
|
|
+ if (ic->op == GOTO)
|
18245 |
|
|
+ isGoto = 1;
|
18246 |
|
|
+ else if (IS_ENDLABEL(ic))
|
18247 |
|
|
+ break;
|
18248 |
|
|
+ else if (ic->op == '=' && isGoto && pblaze_operandsEqu(to, IC_RESULT(ic))) {
|
18249 |
|
|
+ return 0;
|
18250 |
|
|
+ }
|
18251 |
|
|
+ }
|
18252 |
|
|
+
|
18253 |
|
|
+ return 1;
|
18254 |
|
|
+}
|
18255 |
|
|
+
|
18256 |
|
|
+/*-----------------------------------------------------------------*/
|
18257 |
|
|
+/* assignOpt - assign optimalization */
|
18258 |
|
|
+/*-----------------------------------------------------------------*/
|
18259 |
|
|
+void assignOpt(iCode * ic, operand * to, operand * from)
|
18260 |
|
|
+{
|
18261 |
|
|
+ int size, nReg, i;
|
18262 |
|
|
+ reg_info *rtmp;
|
18263 |
|
|
+ memMap *mem;
|
18264 |
|
|
+
|
18265 |
|
|
+ if (IS_OP_GLOBAL(to))
|
18266 |
|
|
+ freeOpFromReg(to);
|
18267 |
|
|
+ else
|
18268 |
|
|
+ freeOperand(to);
|
18269 |
|
|
+
|
18270 |
|
|
+ size = getSize(operandType(to));
|
18271 |
|
|
+ nReg = getSize(operandType(from));
|
18272 |
|
|
+ OP_SYMBOL(to)->nRegs = size;
|
18273 |
|
|
+
|
18274 |
|
|
+ if (nReg == 0) {
|
18275 |
|
|
+ return;
|
18276 |
|
|
+ }
|
18277 |
|
|
+
|
18278 |
|
|
+ for (i = 0; i < size; i++) {
|
18279 |
|
|
+
|
18280 |
|
|
+ rtmp = OP_SYMBOL(from)->regs[i];
|
18281 |
|
|
+ if (!rtmp) {
|
18282 |
|
|
+ mem = isOffsetInMem(from, i);
|
18283 |
|
|
+ if (mem != NULL)
|
18284 |
|
|
+ mem->currOper = to;
|
18285 |
|
|
+ else {
|
18286 |
|
|
+ //exit (1);
|
18287 |
|
|
+ rtmp = getReg(ic);
|
18288 |
|
|
+ if (rtmp->rIdx < pblaze_nRegs) {
|
18289 |
|
|
+ rtmp->isFree = 0;
|
18290 |
|
|
+ rtmp->offset = i;
|
18291 |
|
|
+ //emitLoadNumb(rtmp->name, 0);
|
18292 |
|
|
+ }
|
18293 |
|
|
+ }
|
18294 |
|
|
+ }
|
18295 |
|
|
+ OP_SYMBOL(to)->regs[i] = rtmp;
|
18296 |
|
|
+ if (rtmp) {
|
18297 |
|
|
+ rtmp->currOper = to;
|
18298 |
|
|
+ }
|
18299 |
|
|
+ OP_SYMBOL(from)->regs[i] = NULL;
|
18300 |
|
|
+ }
|
18301 |
|
|
+
|
18302 |
|
|
+ for (i = size; i < nReg; i++) {
|
18303 |
|
|
+ rtmp = OP_SYMBOL(from)->regs[i];
|
18304 |
|
|
+ freeReg(rtmp);
|
18305 |
|
|
+ OP_SYMBOL(from)->regs[i] = NULL;
|
18306 |
|
|
+ }
|
18307 |
|
|
+
|
18308 |
|
|
+ OP_SYMBOL(from)->nRegs = 0;
|
18309 |
|
|
+}
|
18310 |
|
|
+
|
18311 |
|
|
+
|
18312 |
|
|
+
|
18313 |
|
|
+/*-----------------------------------------------------------------*/
|
18314 |
|
|
+/* aopGetReg - assign an operand's offset into registers if necessary*/
|
18315 |
|
|
+/* and returns that register */
|
18316 |
|
|
+/*-----------------------------------------------------------------*/
|
18317 |
|
|
+reg_info *aopGetReg(iCode * ic, operand * op, int offset)
|
18318 |
|
|
+{
|
18319 |
|
|
+ reg_info *rs;
|
18320 |
|
|
+ int size;
|
18321 |
|
|
+ memMap *mem, *mtmp;
|
18322 |
|
|
+ reg_info *rtmp;
|
18323 |
|
|
+
|
18324 |
|
|
+ // symbol only
|
18325 |
|
|
+ if (op->type == SYMBOL) {
|
18326 |
|
|
+ size = getSize(OP_SYMBOL(op)->type);
|
18327 |
|
|
+ if (offset >= size)
|
18328 |
|
|
+ return NULL;
|
18329 |
|
|
+
|
18330 |
|
|
+ /* operand is already in the registers */
|
18331 |
|
|
+ if (OP_SYMBOL(op)->regs[offset] != NULL && OP_SYMBOL(op)->regs[offset]->rIdx < pblaze_nRegs) {
|
18332 |
|
|
+ rs = OP_SYMBOL(op)->regs[offset];
|
18333 |
|
|
+ return rs;
|
18334 |
|
|
+ }
|
18335 |
|
|
+ // operand is in the memory
|
18336 |
|
|
+ else if ((mem = isOffsetInMem(op, offset)) != NULL) {
|
18337 |
|
|
+
|
18338 |
|
|
+ // get a register for the operand
|
18339 |
|
|
+ if (mem->isOnlyInMem)
|
18340 |
|
|
+ rtmp = getTempReg();
|
18341 |
|
|
+ else {
|
18342 |
|
|
+ rtmp = getRegOper(ic, op, offset);
|
18343 |
|
|
+ rtmp->ptrOffset = mem->ptrOffset;
|
18344 |
|
|
+ }
|
18345 |
|
|
+
|
18346 |
|
|
+ // no free registers, make this offset being pernament in the memory
|
18347 |
|
|
+ if (rtmp->rIdx >= pblaze_nRegs && !IS_OP_GLOBALVOLATILE(op)) {
|
18348 |
|
|
+ mem->isOnlyInMem = 1;
|
18349 |
|
|
+ OP_SYMBOL(op)->regs[offset] = rtmp;
|
18350 |
|
|
+ }
|
18351 |
|
|
+
|
18352 |
|
|
+ if (mem->isOnlyInMem == 0) {
|
18353 |
|
|
+ rtmp->isFree = 0;
|
18354 |
|
|
+ rtmp->currOper = op;
|
18355 |
|
|
+ rtmp->offset = offset;
|
18356 |
|
|
+
|
18357 |
|
|
+ OP_SYMBOL(op)->regs[offset] = rtmp;
|
18358 |
|
|
+ }
|
18359 |
|
|
+ // load operand from the memory into registers
|
18360 |
|
|
+ if (((ic->prev || ic->next)))
|
18361 |
|
|
+ emitFetch(rtmp->name, mem->addr);
|
18362 |
|
|
+
|
18363 |
|
|
+ // clear memory, if its a temporary variable
|
18364 |
|
|
+ //if( !IS_OP_GLOBAL(op) ) IS_ITEMP(op) && OP_LIVETO(op) != 0
|
18365 |
|
|
+ if (!IS_OP_GLOBAL(op) && OP_LIVETO(op) != 0 && mem->isOnlyInMem == 0)
|
18366 |
|
|
+ freeOffsetFromMem(op, offset);
|
18367 |
|
|
+
|
18368 |
|
|
+ return rtmp;
|
18369 |
|
|
+ }
|
18370 |
|
|
+ // not in registers or the memory
|
18371 |
|
|
+ else {
|
18372 |
|
|
+ rtmp = getRegOper(ic, op, offset);
|
18373 |
|
|
+
|
18374 |
|
|
+ // enought free registers
|
18375 |
|
|
+ if (rtmp->rIdx < pblaze_nRegs) {
|
18376 |
|
|
+ rtmp->isFree = 0;
|
18377 |
|
|
+ rtmp->currOper = op;
|
18378 |
|
|
+ rtmp->offset = offset;
|
18379 |
|
|
+ rtmp->ptrOffset = 0;
|
18380 |
|
|
+
|
18381 |
|
|
+ OP_SYMBOL(op)->regs[offset] = rtmp;
|
18382 |
|
|
+ OP_SYMBOL(op)->nRegs = size;
|
18383 |
|
|
+
|
18384 |
|
|
+ }
|
18385 |
|
|
+ // not enought free registers - use memory for storing the operand
|
18386 |
|
|
+ else {
|
18387 |
|
|
+ mem = firstFreeMem();
|
18388 |
|
|
+ if (!mem) {
|
18389 |
|
|
+ fprintf(stderr, "%s:%d: pblaze port error: not enough memory\n", __FILE__, __LINE__);
|
18390 |
|
|
+ exit(1);
|
18391 |
|
|
+ }
|
18392 |
|
|
+
|
18393 |
|
|
+ OP_SYMBOL(op)->nRegs = size;
|
18394 |
|
|
+ OP_SYMBOL(op)->regs[offset] = rtmp;
|
18395 |
|
|
+ mem->currOper = op;
|
18396 |
|
|
+ mem->offset = offset;
|
18397 |
|
|
+ mem->ptrOffset = 0;
|
18398 |
|
|
+ mem->isOnlyInMem = 1;
|
18399 |
|
|
+ mem->isFree = 0;
|
18400 |
|
|
+ mem->isGlobal = IS_OP_GLOBAL(op);
|
18401 |
|
|
+
|
18402 |
|
|
+ mtmp = isOffsetInMem(op, offset + 1);
|
18403 |
|
|
+ mem->nextPart = mtmp == NULL ? -1 : mtmp->addr;
|
18404 |
|
|
+ mtmp = isOffsetInMem(op, offset - 1);
|
18405 |
|
|
+ if (mtmp)
|
18406 |
|
|
+ mtmp->nextPart = mem->addr;
|
18407 |
|
|
+
|
18408 |
|
|
+ }
|
18409 |
|
|
+
|
18410 |
|
|
+ rs = rtmp;
|
18411 |
|
|
+ return rs;
|
18412 |
|
|
+ }
|
18413 |
|
|
+ }
|
18414 |
|
|
+ return NULL;
|
18415 |
|
|
+}
|
18416 |
|
|
+
|
18417 |
|
|
+/*-----------------------------------------------------------------*/
|
18418 |
|
|
+/* aopGetRegName - assign an operand's offset into registers */
|
18419 |
|
|
+/* if necessary and returns that register's name */
|
18420 |
|
|
+/*-----------------------------------------------------------------*/
|
18421 |
|
|
+char *aopGetRegName(iCode * ic, operand * op, int offset)
|
18422 |
|
|
+{
|
18423 |
|
|
+ reg_info *rs;
|
18424 |
|
|
+ rs = aopGetReg(ic, op, offset);
|
18425 |
|
|
+ return rs != NULL ? rs->name : NULL;
|
18426 |
|
|
+}
|
18427 |
|
|
+
|
18428 |
|
|
+/*-----------------------------------------------------------------*/
|
18429 |
|
|
+/* aopUpdateOpInMeme - save value of operand which is pernamently */
|
18430 |
|
|
+/* in the memory (due to no free registers ) */
|
18431 |
|
|
+/*-----------------------------------------------------------------*/
|
18432 |
|
|
+void aopUpdateOpInMem(iCode * ic, operand * op, int offset)
|
18433 |
|
|
+{
|
18434 |
|
|
+ memMap *mem;
|
18435 |
|
|
+
|
18436 |
|
|
+ mem = isOffsetInMem(op, offset);
|
18437 |
|
|
+
|
18438 |
|
|
+ if (mem && mem->isOnlyInMem == 1 && OP_SYMBOL(op) && OP_SYMBOL(op)->regs[offset] != NULL
|
18439 |
|
|
+ && !IS_OP_GLOBALVOLATILE(op)) {
|
18440 |
|
|
+ emitStore(OP_SYMBOL(op)->regs[offset]->name, mem->addr);
|
18441 |
|
|
+ OP_SYMBOL(op)->regs[offset] = NULL;
|
18442 |
|
|
+ }
|
18443 |
|
|
+}
|
18444 |
|
|
+
|
18445 |
|
|
+/*-----------------------------------------------------------------*/
|
18446 |
|
|
+/* aopMoveReg - move register to an operand */
|
18447 |
|
|
+/*-----------------------------------------------------------------*/
|
18448 |
|
|
+void aopMoveReg(iCode * ic, operand * result, reg_info * rFrom, int offset)
|
18449 |
|
|
+{
|
18450 |
|
|
+ memMap *mem;
|
18451 |
|
|
+ reg_info *reg;
|
18452 |
|
|
+
|
18453 |
|
|
+ if (result->type == SYMBOL) {
|
18454 |
|
|
+ if (rFrom->rIdx >= pblaze_nRegs) {
|
18455 |
|
|
+ mem = isOffsetInMem(result, offset);
|
18456 |
|
|
+
|
18457 |
|
|
+ if ((mem && mem->isOnlyInMem == 1) || (mem && !isOffsetInReg(result, offset))) {
|
18458 |
|
|
+ emitStore(rFrom->name, mem->addr);
|
18459 |
|
|
+ } else {
|
18460 |
|
|
+ reg = aopGetReg(ic, result, offset);
|
18461 |
|
|
+ if (reg->rIdx >= pblaze_nRegs) {
|
18462 |
|
|
+ emitLoad(reg->name, rFrom->name);
|
18463 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
18464 |
|
|
+ } else {
|
18465 |
|
|
+ emitLoad(reg->name, rFrom->name);
|
18466 |
|
|
+ }
|
18467 |
|
|
+
|
18468 |
|
|
+ }
|
18469 |
|
|
+ } else {
|
18470 |
|
|
+ if (rFrom->currOper && IS_SYMOP(rFrom->currOper))
|
18471 |
|
|
+ OP_SYMBOL(rFrom->currOper)->regs[rFrom->offset] = NULL;
|
18472 |
|
|
+
|
18473 |
|
|
+ mem = isOffsetInMem(result, offset);
|
18474 |
|
|
+ if (mem && mem->isOnlyInMem == 1) {
|
18475 |
|
|
+ emitStore(rFrom->name, mem->addr);
|
18476 |
|
|
+ } else {
|
18477 |
|
|
+ rFrom->isFree = 0;
|
18478 |
|
|
+ rFrom->currOper = result;
|
18479 |
|
|
+ rFrom->offset = offset;
|
18480 |
|
|
+ rFrom->ptrOffset = 0;
|
18481 |
|
|
+
|
18482 |
|
|
+ OP_SYMBOL(result)->regs[offset] = rFrom;
|
18483 |
|
|
+ }
|
18484 |
|
|
+ }
|
18485 |
|
|
+ }
|
18486 |
|
|
+}
|
18487 |
|
|
+
|
18488 |
|
|
+/*-----------------------------------------------------------------*/
|
18489 |
|
|
+/* aopPutReg */
|
18490 |
|
|
+/*-----------------------------------------------------------------*/
|
18491 |
|
|
+void aopPutReg(iCode * ic, operand * result, reg_info * rFrom, int offset)
|
18492 |
|
|
+{
|
18493 |
|
|
+ reg_info *res;
|
18494 |
|
|
+ memMap *mem;
|
18495 |
|
|
+
|
18496 |
|
|
+ if (result->type == SYMBOL) {
|
18497 |
|
|
+
|
18498 |
|
|
+ if (IS_OP_GLOBALVOLATILE(result) || (result->isaddr && LOCAL_POINTER)) {
|
18499 |
|
|
+ mem = isOffsetInMem(result, offset);
|
18500 |
|
|
+ if (mem)
|
18501 |
|
|
+ emitStore(rFrom->name, mem->addr);
|
18502 |
|
|
+ else
|
18503 |
|
|
+ fprintf(stderr, "%s:%d: pblaze port warning: operand %s is not in the memory\n", __FILE__, __LINE__,
|
18504 |
|
|
+ OP_SYMBOL(result)->name);
|
18505 |
|
|
+ }
|
18506 |
|
|
+
|
18507 |
|
|
+ else if (IS_OP_GLOBAL(result)) {
|
18508 |
|
|
+ lockReg(rFrom);
|
18509 |
|
|
+ mem = isOffsetInMem(result, offset);
|
18510 |
|
|
+ if (mem && mem->isOnlyInMem == 1) {
|
18511 |
|
|
+ emitStore(rFrom->name, mem->addr);
|
18512 |
|
|
+ return;
|
18513 |
|
|
+ }
|
18514 |
|
|
+
|
18515 |
|
|
+ res = aopGetReg(ic, result, offset);
|
18516 |
|
|
+ if (res->rIdx >= pblaze_nRegs && mem) {
|
18517 |
|
|
+ emitStore(rFrom->name, mem->addr);
|
18518 |
|
|
+ } else
|
18519 |
|
|
+ emitLoad(res->name, rFrom->name);
|
18520 |
|
|
+ unlockReg(rFrom);
|
18521 |
|
|
+ }
|
18522 |
|
|
+ /* result is a pointer into memory */
|
18523 |
|
|
+ else if (POINTER_SET(ic)) {
|
18524 |
|
|
+ if(isInOutRef(result)) {
|
18525 |
|
|
+ pblaze_emitcodeOutput(ic, rFrom->name, result);
|
18526 |
|
|
+ }
|
18527 |
|
|
+ else {
|
18528 |
|
|
+ res = aopGetReg(ic, result, 0);
|
18529 |
|
|
+
|
18530 |
|
|
+ /* move value into a pointed memory */
|
18531 |
|
|
+ emitStoreReg(rFrom->name, res->name);
|
18532 |
|
|
+ res->ptrOffset = offset;
|
18533 |
|
|
+ }
|
18534 |
|
|
+ }
|
18535 |
|
|
+ /* normal operation */
|
18536 |
|
|
+ else {
|
18537 |
|
|
+ /* temporarly source register (unassigned to any operand) */
|
18538 |
|
|
+ if (rFrom->isReserved == 1 && SEND_REG_FIRST > rFrom->rIdx && !rFrom->currOper) {
|
18539 |
|
|
+ aopMoveReg(ic, result, rFrom, offset);
|
18540 |
|
|
+ } else {
|
18541 |
|
|
+ res = aopGetReg(ic, result, offset);
|
18542 |
|
|
+ mem = isOffsetInMem(result, offset);
|
18543 |
|
|
+ /* operand only in memory */
|
18544 |
|
|
+ if (mem && mem->isOnlyInMem && rFrom->rIdx >= pblaze_nRegs) {
|
18545 |
|
|
+ emitStore(rFrom->name, mem->addr);
|
18546 |
|
|
+ }
|
18547 |
|
|
+ /* normal operation */
|
18548 |
|
|
+ else {
|
18549 |
|
|
+ if (strcmp(res->name, rFrom->name) != 0)
|
18550 |
|
|
+ emitLoad(res->name, rFrom->name);
|
18551 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
18552 |
|
|
+ }
|
18553 |
|
|
+ }
|
18554 |
|
|
+ }
|
18555 |
|
|
+ }
|
18556 |
|
|
+}
|
18557 |
|
|
+
|
18558 |
|
|
+/*-----------------------------------------------------------------*/
|
18559 |
|
|
+/* aopPutVal */
|
18560 |
|
|
+/*-----------------------------------------------------------------*/
|
18561 |
|
|
+void aopPutVal(iCode * ic, operand * result, char *val, int offset)
|
18562 |
|
|
+{
|
18563 |
|
|
+ reg_info *rtmp, *res;
|
18564 |
|
|
+ memMap *mem;
|
18565 |
|
|
+
|
18566 |
|
|
+ if (result->type == SYMBOL) {
|
18567 |
|
|
+
|
18568 |
|
|
+ if (IS_OP_GLOBALVOLATILE(result) || (result->isaddr && LOCAL_POINTER)) {
|
18569 |
|
|
+ mem = isOffsetInMem(result, offset);
|
18570 |
|
|
+ if (mem) {
|
18571 |
|
|
+ rtmp = getReg(ic);
|
18572 |
|
|
+ lockReg(rtmp);
|
18573 |
|
|
+ emitLoad(rtmp->name, val);
|
18574 |
|
|
+ emitStore(rtmp->name, mem->addr);
|
18575 |
|
|
+ unlockReg(rtmp);
|
18576 |
|
|
+ } else
|
18577 |
|
|
+ fprintf(stderr, "%s:%d: pblaze port warning: operand %s is not in the memory\n", __FILE__, __LINE__,
|
18578 |
|
|
+ OP_SYMBOL(result)->name);
|
18579 |
|
|
+ }
|
18580 |
|
|
+
|
18581 |
|
|
+ else if (IS_OP_GLOBAL(result)) {
|
18582 |
|
|
+ res = aopGetReg(ic, result, offset);
|
18583 |
|
|
+ emitLoad(res->name, val);
|
18584 |
|
|
+
|
18585 |
|
|
+ if (res->rIdx >= pblaze_nRegs) {
|
18586 |
|
|
+ mem = isOffsetInMem(result, offset);
|
18587 |
|
|
+ if (mem && mem->isOnlyInMem == 1) {
|
18588 |
|
|
+ emitStore(res->name, mem->addr);
|
18589 |
|
|
+ }
|
18590 |
|
|
+ }
|
18591 |
|
|
+
|
18592 |
|
|
+ }
|
18593 |
|
|
+
|
18594 |
|
|
+ /* result is a pointer into memory */
|
18595 |
|
|
+ else if (POINTER_SET(ic)) {
|
18596 |
|
|
+
|
18597 |
|
|
+ if(isInOutRef(result)) {
|
18598 |
|
|
+ rtmp = getReg(ic);
|
18599 |
|
|
+ emitLoad(rtmp->name, val);
|
18600 |
|
|
+ pblaze_emitcodeOutput(ic, rtmp->name, result);
|
18601 |
|
|
+ }
|
18602 |
|
|
+ else {
|
18603 |
|
|
+ res = aopGetReg(ic, result, 0);
|
18604 |
|
|
+
|
18605 |
|
|
+ /* move value into a pointed memory */
|
18606 |
|
|
+ rtmp = getReg(ic);
|
18607 |
|
|
+ emitLoad(rtmp->name, val);
|
18608 |
|
|
+ emitStoreReg(rtmp->name, res->name);
|
18609 |
|
|
+ res->ptrOffset = offset;
|
18610 |
|
|
+ }
|
18611 |
|
|
+ }
|
18612 |
|
|
+ /* basic load into a register */
|
18613 |
|
|
+ else {
|
18614 |
|
|
+ res = aopGetReg(ic, result, offset);
|
18615 |
|
|
+
|
18616 |
|
|
+ emitLoad(res->name, val);
|
18617 |
|
|
+ aopUpdateOpInMem(ic, result, offset);
|
18618 |
|
|
+ }
|
18619 |
|
|
+
|
18620 |
|
|
+ }
|
18621 |
|
|
+ //Safe_free(val);
|
18622 |
|
|
+}
|
18623 |
|
|
+
|
18624 |
|
|
+/*-----------------------------------------------------------------*/
|
18625 |
|
|
+/* findAndAllocGlobals - alloc memory for global variables */
|
18626 |
|
|
+/*-----------------------------------------------------------------*/
|
18627 |
|
|
+static void findAndAllocGlobals(iCode * lic)
|
18628 |
|
|
+{
|
18629 |
|
|
+ iCode *ic;
|
18630 |
|
|
+ operand *op;
|
18631 |
|
|
+
|
18632 |
|
|
+ if (!lic)
|
18633 |
|
|
+ return;
|
18634 |
|
|
+
|
18635 |
|
|
+ for (ic = lic; ic; ic = ic->next) {
|
18636 |
|
|
+ if (!SKIP_NO_OP(ic)) {
|
18637 |
|
|
+
|
18638 |
|
|
+ if (IC_LEFT(ic) && (IS_OP_GLOBAL(IC_LEFT(ic)))) {
|
18639 |
|
|
+ op = IC_LEFT(ic);;
|
18640 |
|
|
+ if (!IS_FUNC(OP_SYM_TYPE(op)) && !isOpInMem(op))
|
18641 |
|
|
+ allocOpInMem(op);
|
18642 |
|
|
+ }
|
18643 |
|
|
+
|
18644 |
|
|
+ if (IC_RIGHT(ic) && (IS_OP_GLOBAL(IC_RIGHT(ic)))) {
|
18645 |
|
|
+ op = IC_RIGHT(ic);
|
18646 |
|
|
+ if (!IS_FUNC(OP_SYM_TYPE(op)) && !isOpInMem(op))
|
18647 |
|
|
+ allocOpInMem(op);
|
18648 |
|
|
+ }
|
18649 |
|
|
+
|
18650 |
|
|
+ if (IC_RESULT(ic) && (IS_OP_GLOBAL(IC_RESULT(ic)))) {
|
18651 |
|
|
+ op = IC_RESULT(ic);
|
18652 |
|
|
+ if (!IS_FUNC(OP_SYM_TYPE(op)) && !isOpInMem(op))
|
18653 |
|
|
+ allocOpInMem(op);
|
18654 |
|
|
+ }
|
18655 |
|
|
+ }
|
18656 |
|
|
+ }
|
18657 |
|
|
+
|
18658 |
|
|
+}
|
18659 |
|
|
+
|
18660 |
|
|
+/*-----------------------------------------------------------------*/
|
18661 |
|
|
+/* findIndirectOperands - alloc memory for arrays or pointed operands*/
|
18662 |
|
|
+/*-----------------------------------------------------------------*/
|
18663 |
|
|
+static void findIndirectOperands(iCode * lic)
|
18664 |
|
|
+{
|
18665 |
|
|
+ iCode *ic;
|
18666 |
|
|
+ operand *op;
|
18667 |
|
|
+
|
18668 |
|
|
+ if (!lic)
|
18669 |
|
|
+ return;
|
18670 |
|
|
+
|
18671 |
|
|
+ for (ic = lic; ic; ic = ic->next) {
|
18672 |
|
|
+
|
18673 |
|
|
+ if (!SKIP_NO_OP(ic)) {
|
18674 |
|
|
+
|
18675 |
|
|
+ // indirect address
|
18676 |
|
|
+ if (IC_RESULT(ic) && IC_RESULT(ic)->isaddr && !IS_OP_GLOBAL(IC_RESULT(ic)) &&
|
18677 |
|
|
+ !isOpVolatile(IC_RESULT(ic)) && OP_LIVEFROM(IC_RESULT(ic)) == 0 && OP_LIVETO(IC_RESULT(ic)) == 0) {
|
18678 |
|
|
+ op = IC_RESULT(ic);
|
18679 |
|
|
+ if (!IS_FUNC(OP_SYM_TYPE(op)) && !isOpInMem(op))
|
18680 |
|
|
+ allocOpInMem(op);
|
18681 |
|
|
+ }
|
18682 |
|
|
+
|
18683 |
|
|
+ if (IC_LEFT(ic) && IS_SYMOP(IC_LEFT(ic)) && !isOpVolatile(IC_LEFT(ic)) &&
|
18684 |
|
|
+ (IS_ARRAY(OP_SYM_TYPE(IC_LEFT(ic))) || IS_STRUCT(OP_SYM_TYPE(IC_LEFT(ic)))
|
18685 |
|
|
+ || IS_TYPEDEF(OP_SYM_TYPE(IC_LEFT(ic))) || (IC_LEFT(ic)->isaddr && !IS_ITEMP(IC_LEFT(ic))))) {
|
18686 |
|
|
+ op = IC_LEFT(ic);
|
18687 |
|
|
+ if (!IS_FUNC(OP_SYM_TYPE(op)) && !isOpInMem(op))
|
18688 |
|
|
+ allocOpInMem(op);
|
18689 |
|
|
+
|
18690 |
|
|
+ }
|
18691 |
|
|
+ }
|
18692 |
|
|
+ }
|
18693 |
|
|
+
|
18694 |
|
|
+}
|
18695 |
|
|
+
|
18696 |
|
|
+/*-----------------------------------------------------------------*/
|
18697 |
|
|
+/* pblaze_genCodeLoop */
|
18698 |
|
|
+/*-----------------------------------------------------------------*/
|
18699 |
|
|
+void pblaze_genCodeLoop(void)
|
18700 |
|
|
+{
|
18701 |
|
|
+ ebbIndex *ebbi;
|
18702 |
|
|
+ eBBlock **ebbs;
|
18703 |
|
|
+ int count;
|
18704 |
|
|
+ iCode *ic;
|
18705 |
|
|
+
|
18706 |
|
|
+ _G_glueCalled = 1;
|
18707 |
|
|
+ pblaze_interrupt = NULL;
|
18708 |
|
|
+
|
18709 |
|
|
+ if (_G_codeSet) {
|
18710 |
|
|
+
|
18711 |
|
|
+ // optimalization phase
|
18712 |
|
|
+ for (ebbi = setFirstItem(_G_codeSet); ebbi; ebbi = setNextItem(_G_codeSet)) {
|
18713 |
|
|
+ ebbs = ebbi->bbOrder;
|
18714 |
|
|
+ count = ebbi->count;
|
18715 |
|
|
+
|
18716 |
|
|
+ /* now get back the chain */
|
18717 |
|
|
+ //ic = iCodeLabelOptimize (iCodeFromeBBlock (ebbs, count));
|
18718 |
|
|
+ ic = iCodeFromeBBlock(ebbs, count);
|
18719 |
|
|
+ findAndAllocGlobals(ic);
|
18720 |
|
|
+ }
|
18721 |
|
|
+
|
18722 |
|
|
+ // code generation phase
|
18723 |
|
|
+ for (ebbi = setFirstItem(_G_codeSet); ebbi; ebbi = setNextItem(_G_codeSet)) {
|
18724 |
|
|
+ ebbs = ebbi->bbOrder;
|
18725 |
|
|
+ count = ebbi->count;
|
18726 |
|
|
+
|
18727 |
|
|
+ setToNull((void *) &_G.funcrUsed);
|
18728 |
|
|
+ /* now get back the chain */
|
18729 |
|
|
+ ic = iCodeFromeBBlock(ebbs, count);
|
18730 |
|
|
+
|
18731 |
|
|
+ findIndirectOperands(ic);
|
18732 |
|
|
+ //resetRegs ();
|
18733 |
|
|
+
|
18734 |
|
|
+ genPBLAZECode(ic);
|
18735 |
|
|
+ resetRegs();
|
18736 |
|
|
+ }
|
18737 |
|
|
+ }
|
18738 |
|
|
+
|
18739 |
|
|
+}
|
18740 |
|
|
+
|
18741 |
|
|
+
|
18742 |
|
|
+
|
18743 |
|
|
+/*-----------------------------------------------------------------*/
|
18744 |
|
|
+/* assignRegisters */
|
18745 |
|
|
+/*-----------------------------------------------------------------*/
|
18746 |
|
|
+void pblaze_assignRegisters(ebbIndex * ebbi)
|
18747 |
|
|
+{
|
18748 |
|
|
+ eBBlock **ebbs = ebbi->bbOrder;
|
18749 |
|
|
+ int count = ebbi->count;
|
18750 |
|
|
+ iCode *ic;
|
18751 |
|
|
+
|
18752 |
|
|
+ if (gInit == 0) {
|
18753 |
|
|
+ gInit = 1;
|
18754 |
|
|
+ initPBLAZEMem();
|
18755 |
|
|
+ }
|
18756 |
|
|
+ //doOverlays (ebbs, count);
|
18757 |
|
|
+ //iCodeLabelOptimize(iCodeFromeBBlock (ebbs, count) );
|
18758 |
|
|
+
|
18759 |
|
|
+ if (!_G_glueCalled) {
|
18760 |
|
|
+ addSet(&_G_codeSet, ebbi);
|
18761 |
|
|
+
|
18762 |
|
|
+ } else {
|
18763 |
|
|
+
|
18764 |
|
|
+
|
18765 |
|
|
+ setToNull((void *) &_G.funcrUsed);
|
18766 |
|
|
+
|
18767 |
|
|
+ /* now get back the chain */
|
18768 |
|
|
+ //ic = iCodeLabelOptimize (iCodeFromeBBlock (ebbs, count));
|
18769 |
|
|
+ ic = iCodeFromeBBlock(ebbs, count);
|
18770 |
|
|
+
|
18771 |
|
|
+ //findAndAllocGlobals(ic);
|
18772 |
|
|
+
|
18773 |
|
|
+ genPBLAZECode(ic);
|
18774 |
|
|
+ }
|
18775 |
|
|
+ return;
|
18776 |
|
|
+}
|
18777 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/pblaze/ralloc.h sdcc-src-3.1.0-pblaze/src/pblaze/ralloc.h
|
18778 |
|
|
--- sdcc-src-3.1.0/src/pblaze/ralloc.h 1970-01-01 01:00:00.000000000 +0100
|
18779 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/pblaze/ralloc.h 2011-12-05 23:42:54.284169700 +0100
|
18780 |
|
|
@@ -0,0 +1,142 @@
|
18781 |
|
|
+/*-------------------------------------------------------------------------
|
18782 |
|
|
+ralloc.h - source file for register allocation. (XILINX PICOBLAZE) specific
|
18783 |
|
|
+
|
18784 |
|
|
+Author:
|
18785 |
|
|
+ Jakub Hornik, xhorni00<at>stud.fit.vutbr.cz
|
18786 |
|
|
+Master Thesis Project:
|
18787 |
|
|
+ Compiler Back-End of Subset of Language C for 8-Bit Processor
|
18788 |
|
|
+Date:
|
18789 |
|
|
+ 2011
|
18790 |
|
|
+
|
18791 |
|
|
+ This program is free software; you can redistribute it and/or modify it
|
18792 |
|
|
+ under the terms of the GNU General Public License as published by the
|
18793 |
|
|
+ Free Software Foundation; either version 2, or (at your option) any
|
18794 |
|
|
+ later version.
|
18795 |
|
|
+
|
18796 |
|
|
+ This program is distributed in the hope that it will be useful,
|
18797 |
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18798 |
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18799 |
|
|
+ GNU General Public License for more details.
|
18800 |
|
|
+
|
18801 |
|
|
+ You should have received a copy of the GNU General Public License
|
18802 |
|
|
+ along with this program; if not, write to the Free Software
|
18803 |
|
|
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
18804 |
|
|
+
|
18805 |
|
|
+ In other words, you are welcome to use, share and improve this program.
|
18806 |
|
|
+ You are forbidden to forbid anyone else to use, share and improve
|
18807 |
|
|
+ what you give them. Help stamp out software-hoarding!
|
18808 |
|
|
+-------------------------------------------------------------------------*/
|
18809 |
|
|
+#include "SDCCicode.h"
|
18810 |
|
|
+#include "SDCCBBlock.h"
|
18811 |
|
|
+#ifndef PBLAZERALLOC_H
|
18812 |
|
|
+#define PBLAZERALLOC_H
|
18813 |
|
|
+
|
18814 |
|
|
+enum {
|
18815 |
|
|
+ S0_IDX = 0,
|
18816 |
|
|
+ S1_IDX, S2_IDX, S3_IDX, S4_IDX,
|
18817 |
|
|
+ S5_IDX, S6_IDX, S7_IDX, S8_IDX,
|
18818 |
|
|
+ S9_IDX, SA_IDX, SB_IDX, SC_IDX,
|
18819 |
|
|
+ SD_IDX, SE_IDX, SF_IDX
|
18820 |
|
|
+};
|
18821 |
|
|
+
|
18822 |
|
|
+enum {
|
18823 |
|
|
+ SAME_VAL = 0,
|
18824 |
|
|
+ IN_REG,
|
18825 |
|
|
+ IN_MEM
|
18826 |
|
|
+};
|
18827 |
|
|
+
|
18828 |
|
|
+
|
18829 |
|
|
+#define REG_PTR 0x01
|
18830 |
|
|
+#define REG_GPR 0x02 /* general purpose registers */
|
18831 |
|
|
+
|
18832 |
|
|
+/* definition of the stack size and the stack bottom */
|
18833 |
|
|
+#define PBLAZE_STACK_SIZE 32
|
18834 |
|
|
+#define PBLAZE_STACK_BOTTOM 0x3F
|
18835 |
|
|
+
|
18836 |
|
|
+/* first register used in send/receive function passing */
|
18837 |
|
|
+#define SEND_REG_FIRST SB_IDX
|
18838 |
|
|
+/* number of send/receive registers */
|
18839 |
|
|
+#define SEND_REG_COUNT 4
|
18840 |
|
|
+
|
18841 |
|
|
+/* PicoBlaze's data memory size */
|
18842 |
|
|
+#define MEMSIZE 64
|
18843 |
|
|
+#define PBLAZENREGS 16
|
18844 |
|
|
+
|
18845 |
|
|
+static set *_G_codeSet;
|
18846 |
|
|
+static int _G_glueCalled = 0;
|
18847 |
|
|
+
|
18848 |
|
|
+/* definition for the registers */
|
18849 |
|
|
+typedef struct reg_info {
|
18850 |
|
|
+ short type; /* PicoBlaze have only REG_GPR */
|
18851 |
|
|
+ short rIdx; /* index into register table */
|
18852 |
|
|
+ char *name; /* name */
|
18853 |
|
|
+ operand *currOper; /* current operand in the register */
|
18854 |
|
|
+ short offset; /* offset of the operand */
|
18855 |
|
|
+ short ptrOffset; /* offset of the current pointer */
|
18856 |
|
|
+ short changed; /* global variable is actual in the register */
|
18857 |
|
|
+ unsigned isFree:1; /* is currently unassigned */
|
18858 |
|
|
+ unsigned isReserved:1; /* is reserved */
|
18859 |
|
|
+} reg_info;
|
18860 |
|
|
+
|
18861 |
|
|
+
|
18862 |
|
|
+
|
18863 |
|
|
+/* definition for the memory */
|
18864 |
|
|
+typedef struct memMap {
|
18865 |
|
|
+ unsigned int addr; /* address of the memory cell */
|
18866 |
|
|
+ operand *currOper; /* current operand in the register */
|
18867 |
|
|
+ short offset; /* offset of the operand (if larger than 1B) */
|
18868 |
|
|
+ short ptrOffset; /* offset of the current pointer */
|
18869 |
|
|
+ short nextPart; /* index into memory with next part of the operand */
|
18870 |
|
|
+ unsigned reserved:1; /* is reserved */
|
18871 |
|
|
+ unsigned isGlobal:1; /* contains global value */
|
18872 |
|
|
+ unsigned isFree:1; /* is currently free */
|
18873 |
|
|
+ unsigned isOnlyInMem:1; /* temporary variable which is only in the memory due to no avaiable registers */
|
18874 |
|
|
+} memMap;
|
18875 |
|
|
+
|
18876 |
|
|
+extern reg_info regsPBLAZE[];
|
18877 |
|
|
+extern memMap memPBLAZE[];
|
18878 |
|
|
+
|
18879 |
|
|
+void staticMemoryCheck(int top);
|
18880 |
|
|
+
|
18881 |
|
|
+char *aopGetRegName(iCode * ic, operand * op, int offset);
|
18882 |
|
|
+reg_info *aopGetReg(iCode * ic, operand * op, int offset);
|
18883 |
|
|
+void aopPutReg(iCode * ic, operand * result, reg_info * rFrom, int offset);
|
18884 |
|
|
+void aopPutVal(iCode * ic, operand * result, char *val, int offset);
|
18885 |
|
|
+void aopMoveReg(iCode * ic, operand * result, reg_info * rFrom, int offset);
|
18886 |
|
|
+void aopUpdateOpInMem(iCode * ic, operand * op, int offset);
|
18887 |
|
|
+
|
18888 |
|
|
+reg_info *getReg(iCode * ic);
|
18889 |
|
|
+
|
18890 |
|
|
+int isOpInReg(operand * op);
|
18891 |
|
|
+reg_info *isOffsetInReg(operand * op, int offset);
|
18892 |
|
|
+
|
18893 |
|
|
+memMap *isOpInMem(operand * op);
|
18894 |
|
|
+memMap *isOffsetInMem(operand * op, int offset);
|
18895 |
|
|
+
|
18896 |
|
|
+void assignOpt(iCode * ic, operand * to, operand * from);
|
18897 |
|
|
+int assignOptTest(iCode * lic, operand * to);
|
18898 |
|
|
+
|
18899 |
|
|
+int clearUnusedOpFromReg(iCode * ic);
|
18900 |
|
|
+int clearUnusedOpFromMem(iCode * ic);
|
18901 |
|
|
+void clearMemEndFunc(void);
|
18902 |
|
|
+void globalChanged(operand * op, short c);
|
18903 |
|
|
+void freeGlobalsFromReg(void);
|
18904 |
|
|
+void allocOpInMem(operand * op);
|
18905 |
|
|
+void freeOpFromReg(operand * op);
|
18906 |
|
|
+memMap *firstFreeMem(void);
|
18907 |
|
|
+void moveOpToMem(operand * op);
|
18908 |
|
|
+
|
18909 |
|
|
+void printRegs(void);
|
18910 |
|
|
+void printMemory(void);
|
18911 |
|
|
+void printConstants(FILE * of);
|
18912 |
|
|
+char *operName(int addr);
|
18913 |
|
|
+
|
18914 |
|
|
+void setReserved(operand * oper);
|
18915 |
|
|
+void unSetReserved(operand * oper);
|
18916 |
|
|
+void unlockReg(reg_info * r);
|
18917 |
|
|
+void lockReg(reg_info * r);
|
18918 |
|
|
+
|
18919 |
|
|
+reg_info *pblaze_regWithIdx(int);
|
18920 |
|
|
+void pblaze_genCodeLoop(void);
|
18921 |
|
|
+
|
18922 |
|
|
+#endif
|
18923 |
|
|
diff -NaurbB sdcc-src-3.1.0/src/port.h sdcc-src-3.1.0-pblaze/src/port.h
|
18924 |
|
|
--- sdcc-src-3.1.0/src/port.h 2011-10-09 20:21:10.000000000 +0200
|
18925 |
|
|
+++ sdcc-src-3.1.0-pblaze/src/port.h 2011-12-04 15:56:51.809631700 +0100
|
18926 |
|
|
@@ -22,6 +22,7 @@
|
18927 |
|
|
#define TARGET_ID_HC08 11
|
18928 |
|
|
#define TARGET_ID_Z180 12
|
18929 |
|
|
#define TARGET_ID_R2K 13
|
18930 |
|
|
+#define TARGET_ID_PBLAZE 14
|
18931 |
|
|
|
18932 |
|
|
/* Macro to test the target we are compiling for.
|
18933 |
|
|
Can only be used after SDCCmain has defined the port
|
18934 |
|
|
@@ -38,6 +39,7 @@
|
18935 |
|
|
#define TARGET_IS_XA51 (port->id == TARGET_ID_XA51)
|
18936 |
|
|
#define TARGET_IS_HC08 (port->id == TARGET_ID_HC08)
|
18937 |
|
|
#define TARGET_IS_R2K (port->id == TARGET_ID_R2K)
|
18938 |
|
|
+#define TARGET_IS_PBLAZE (port->id == TARGET_ID_PBLAZE)
|
18939 |
|
|
|
18940 |
|
|
#define TARGET_MCS51_LIKE (TARGET_IS_MCS51 || TARGET_IS_DS390 || TARGET_IS_DS400)
|
18941 |
|
|
#define TARGET_Z80_LIKE (TARGET_IS_Z80 || TARGET_IS_Z180 || TARGET_IS_GBZ80 || TARGET_IS_R2K)
|
18942 |
|
|
@@ -427,5 +429,8 @@
|
18943 |
|
|
#if !OPT_DISABLE_HC08
|
18944 |
|
|
extern PORT hc08_port;
|
18945 |
|
|
#endif
|
18946 |
|
|
+#if !OPT_DISABLE_PBLAZE
|
18947 |
|
|
+extern PORT pblaze_port;
|
18948 |
|
|
+#endif
|
18949 |
|
|
|
18950 |
|
|
#endif /* PORT_INCLUDE */
|