1 #define PUSH_POP_OPT TRUE
3 /******************************************************************************/
5 /* Group 1 : load instructions */
7 /******************************************************************************/
9 C_loc ==> "mov ax, $1";
12 C_ldc ==> C_loc( $1>>16);
15 C_lol ==> "push $1(bp)".
17 C_loe.. ==> "push ($1+$2)".
19 C_lil ==> "mov bx, $1(bp)";
25 C_lal ==> "lea ax, $1(bp)";
28 C_lae.. ==> "mov ax, $1+$2";
32 $1 == 0 ==> "push bp".
34 $1 == 1 ==> "push 4(bp)".
36 default ==> "mov cx, $1-1";
43 $1 == 0 ==> "lea ax, 4(bp)";
46 $1 == 1 ==> "mov ax, 4(bp)";
50 default ==> "mov cx, $1-1";
79 default ==> arg_error( "C_los", $1).
81 C_los_narg ==> "pop ax";
88 C_ldl ==> "push $1+2(bp)";
91 C_lde.. ==> "push ($1+$2+2)";
98 C_lpi ==> "mov ax, $1";
101 /******************************************************************************/
103 /* Group 2 : store instructions */
105 /******************************************************************************/
107 C_stl ==> "pop $1(bp)".
109 C_ste.. ==> "pop ($1+$2)".
111 C_sil ==> "mov bx, $1(bp)";
118 $1 == 1 ==> "pop bx";
122 $1 == 2 ==> "pop bx";
125 $1 == 4 ==> "pop bx";
129 default ==> "pop bx";
134 $1 == 2 ==> "pop cx";
138 default ==> arg_error( "C_sts", $1).
140 C_sts_narg ==> "pop ax";
147 C_sdl ==> "pop $1(bp)";
150 C_sde.. ==> "pop ($1+$2)";
157 /******************************************************************************/
159 /* Group 3 : integer arithmetic */
161 /******************************************************************************/
164 $1 == 2 ==> "pop ax";
169 $1 == 4 ==> "pop ax";
178 default ==> "pop ax";
183 C_adi_narg ==> "pop cx";
189 $1 == 2 ==> "pop bx";
194 $1 == 4 ==> "pop ax";
203 default ==> "pop ax";
208 C_sbi_narg ==> "pop cx";
214 $1 == 2 ==> "pop ax";
219 $1 == 4 ==> "pop ax";
225 default ==> arg_error( "C_mli", $1).
227 C_mli_narg ==> "pop ax";
231 $1 == 2 ==> "pop bx";
237 $1 == 4 ==> "call .dvi4";
241 default ==> arg_error( "C_dvi", $1).
243 C_dvi_narg ==> "pop ax";
247 $1 == 2 ==> "pop bx";
253 $1 == 4 ==> "call .rmi4";
257 default ==> arg_error( "C_rmi", $1).
259 C_rmi_narg ==> "pop ax";
263 $1 == 2 ==> "pop ax";
267 $1 == 4 ==> "pop bx";
275 default ==> "mov ax, $1";
278 C_ngi_narg ==> "pop ax";
282 $1 == 2 ==> "pop cx";
287 default ==> "mov ax, $1";
290 C_sli_narg ==> "pop ax";
294 $1 == 2 ==> "pop cx";
299 default ==> "mov ax, $1";
302 C_sri_narg ==> "pop ax";
305 /******************************************************************************/
307 /* Group 4 : Unsigned arithmetic */
309 /******************************************************************************/
311 C_adu ==> C_adi( $1).
313 C_adu_narg ==> C_adi_narg().
315 C_sbu ==> C_sbi( $1).
317 C_sbu_narg ==> C_sbi_narg().
319 C_mlu ==> C_mli( $1).
321 C_mlu_narg ==> C_mli_narg().
324 $1 == 2 ==> "pop bx";
330 $1 == 4 ==> "call .dvu4";
334 default ==> "mov ax, $1";
337 C_dvu_narg ==> "pop ax";
341 $1 == 2 ==> "pop bx";
347 $1 == 4 ==> "call .dvu4";
351 default ==> "mov ax, $1";
354 C_rmu_narg ==> "pop ax";
357 C_slu ==> C_sli( $1).
359 C_slu_narg ==> C_sli_narg().
362 $1 == 2 ==> "pop cx";
367 $1 == 4 ==> "pop cx";
376 default ==> arg_error( "C_sru", $1).
378 /******************************************************************************/
380 /* Group 5 : Floating point arithmetic */
382 /******************************************************************************/
385 $1 == 4 ==> "call .adf4";
388 $1 == 8 ==> "call .adf8";
390 default ==> arg_error("C_adf", $1).
393 $1 == 4 ==> "call .sbf4";
396 $1 == 8 ==> "call .sbf8";
398 default ==> arg_error("C_sbf", $1).
401 $1 == 4 ==> "call .mlf4";
404 $1 == 8 ==> "call .mlf8";
406 default ==> arg_error("C_mlf", $1).
409 $1 == 4 ==> "call .dvf4";
412 $1 == 8 ==> "call .dvf8";
414 default ==> arg_error("C_dvf", $1).
417 $1 == 4 ==> "call .ngf4".
418 $1 == 8 ==> "call .ngf8".
419 default ==> arg_error("C_ngf", $1).
422 $1 == 4 ==> C_lor((arith)1);
425 $1 == 8 ==> C_lor((arith)1);
428 default ==> arg_error("C_fif", $1).
431 $1 == 4 ==> "mov ax,sp";
435 $1 == 8 ==> "mov ax,sp";
439 default ==> arg_error("C_fef", $1).
441 /******************************************************************************/
443 /* Group 6 : Pointer arithmetic */
445 /******************************************************************************/
453 $1 == 1 ==> "pop ax";
457 $1 == -1 ==> "pop ax";
461 default ==> "pop ax";
466 $1 == 2 ==> "pop ax";
471 default ==> arg_error( "C_ads", $1).
473 C_ads_narg ==> "pop ax";
482 $1 == 2 ==> "pop bx";
487 default ==> arg_error( "C_sbs", $1).
489 C_sbs_narg ==> "pop ax";
497 /******************************************************************************/
499 /* Group 7 : Increment/decrement/zero */
501 /******************************************************************************/
507 C_inl ==> "inc $1(bp)".
509 C_ine.. ==> "inc ($1+$2)".
515 C_del ==> "dec $1(bp)".
517 C_dee.. ==> "dec ($1+$2)".
519 C_zrl ==> "mov $1(bp), 0".
521 C_zre.. ==> "mov ($1+$2), 0".
524 $1 == 2 ==> "xor ax, ax";
527 $1 == 4 ==> "xor ax, ax";
531 $1 == 6 ==> "xor ax, ax";
536 $1 == 8 ==> "xor ax, ax";
542 $1 % 2 == 0 ==> "mov cx, $1/2";
547 default ==> arg_error( "C_zer", $1).
551 C_zer_narg ==> "pop cx";
557 /******************************************************************************/
559 /* Group 8 : Convert */
561 /******************************************************************************/
579 C_cif ==> "call .cif".
581 C_cuf ==> "call .cuf".
583 C_cfi ==> "call .cfi";
595 C_cfu ==> "call .cfu";
627 /******************************************************************************/
629 /* Group 9 : Logical */
631 /******************************************************************************/
634 $1 == 2 ==> "pop ax";
639 $1 == 4 ==> "pop ax";
648 default ==> "mov cx, $1";
651 C_and_narg ==> "pop cx";
655 $1 == 2 ==> "pop ax";
660 $1 == 4 ==> "pop ax";
669 default ==> "mov cx, $1";
672 C_ior_narg ==> "pop cx";
676 $1 == 2 ==> "pop ax";
681 $1 == 4 ==> "pop ax";
690 default ==> "mov cx, $1";
693 C_xor_narg ==> "pop cx";
697 $1 == 2 ==> "pop ax";
701 $1 == 4 ==> "pop ax";
708 default ==> "mov cx, $1";
711 C_com_narg ==> "pop cx";
715 $1 == 2 ==> "pop cx";
720 default ==> "mov cx, $1";
723 C_rol_narg ==> "pop cx";
727 $1 == 2 ==> "pop cx";
732 default ==> "mov cx, $1";
735 C_ror_narg ==> "pop cx";
738 /******************************************************************************/
740 /* Group 10 : Sets */
742 /******************************************************************************/
745 $1 == 2 ==> "pop cx";
751 default ==> "pop ax";
756 C_inn_narg ==> "pop cx";
762 $1 == 2 ==> "pop cx";
767 default ==> "pop ax";
771 C_set_narg ==> "pop cx";
775 /******************************************************************************/
777 /* Group 11 : Array */
779 /******************************************************************************/
782 $1 == 2 ==> "pop bx";
786 default ==> arg_error( "C_lar", $1).
788 C_lar_narg ==> "call .ilar".
791 $1 == 2 ==> "pop bx";
795 default ==> arg_error( "C_sar", $1).
797 C_sar_narg ==> "call .isar".
800 $1 == 2 ==> "pop bx";
808 default ==> arg_error( "C_aar", $1).
810 C_aar_narg ==> "call .iaar";
813 /******************************************************************************/
815 /* Group 12 : Compare */
817 /******************************************************************************/
820 $1 == 2 ==> /* bug : C_sbi( (arith) 2). */
832 $1 == 4 ==> "call .cmi4";
835 default ==> arg_error( "C_cmi", $1).
840 $1 == 4 ==> "call .cmu4";
843 default ==> arg_error( "C_cmu", $1).
846 $1 == 2 ==> C_sbi( (arith) 2).
848 $1 == 4 ==> "pop ax";
858 default ==> "mov cx, $1";
862 C_cms_narg ==> "pop cx";
878 $1 == 4 ==> "call .cmf4";
881 $1 == 8 ==> "call .cmf8";
884 default ==> arg_error("C_cmf", $1).
928 /******************************************************************************/
930 /* Group 13 : Branch */
932 /******************************************************************************/
990 /******************************************************************************/
992 /* Group 14 : Procedure call instructions */
994 /******************************************************************************/
1002 $1 == 2 ==> "push ax".
1004 $1 == 4 ==> "push dx";
1007 $1 == 6 ==> "call .lfr6".
1009 $1 == 8 ==> "call .lfr8".
1011 default ==> arg_error( "C_lfr", $1).
1014 $1 == 0 ==> "mov sp, bp";
1018 $1 == 2 ==> "pop ax";
1023 $1 == 4 ==> "pop ax";
1029 $1 == 6 ==> "call .ret6";
1034 $1 == 8 ==> "call .ret8";
1039 default ==> arg_error( "C_ret", $1).
1041 /******************************************************************************/
1043 /* Group 15 : Miscellaneous instructions */
1045 /******************************************************************************/
1048 $1 == 2 ==> "pop bx".
1050 $1 == 4 ==> "pop bx";
1053 $1 == -2 ==> "push ax".
1055 default ==> "add sp, $1".
1058 $1 == 2 ==> "pop ax";
1061 default ==> arg_error( "C_ass", $1).
1063 C_ass_narg ==> "pop ax";
1070 $1 % 2 == 0 ==> "mov cx, $1/2";
1073 default ==> arg_error( "C_blm", $1).
1076 $1 == 2 ==> "pop cx";
1080 default ==> arg_error( "C_bls", $1).
1082 C_bls_narg ==> "pop ax";
1090 $1 == 2 ==> "pop bx";
1094 default ==> arg_error( "C_csa", $1).
1096 C_csa_narg ==> "pop ax";
1104 $1 == 2 ==> "pop bx";
1108 default ==> arg_error( "C_csb", $1).
1110 C_csb_narg ==> "pop ax";
1117 C_dch ==> "mov bp, (bp)".
1120 $1 == 2 ==> "pop ax";
1124 $1 == 4 ==> "pop ax";
1131 default ==> "mov cx, $1";
1135 $1 == 2 ==> "pop cx";
1138 default ==> arg_error( "C_dus", $1).
1140 C_dus_narg ==> "pop ax";
1146 C_exg ==> "mov cx, $1";
1149 C_exg_narg ==> "pop cx";
1152 C_fil.. ==> "mov (hol0+4), $1+$2".
1154 C_gto.. ==> "mov bx, $1+$2";
1157 C_lim ==> "push (.ignmask)".
1159 C_lin ==> "mov (hol0), $1".
1161 C_lni ==> "inc (hol0)".
1164 $1 == 0 ==> "push bp".
1166 $1 == 1 ==> "mov ax, sp";
1169 $1 == 2 ==> "push (.reghp)".
1171 default ==> arg_error( "C_lor", $1).
1183 $1 == 2 ==> "pop bx";
1188 default ==> arg_error( "C_rck", $1).
1190 C_rck_narg ==> "pop ax";
1199 C_rtt ==> C_ret( (arith) 0).
1202 "xchg (.trppc), ax";
1205 C_sim ==> "pop (.ignmask)".
1208 $1 == 0 ==> "pop bp".
1210 $1 == 1 ==> "pop sp".
1212 $1 == 2 ==> "pop (.reghp)".
1214 default ==> arg_error( "C_str", $1).
1219 /******************************************************************************/
1221 /* Storage-routines */
1223 /******************************************************************************/
1227 $2 == 1 ==> gen1( (ONE_BYTE) atoi( $1)).
1228 $2 == 2 ==> gen2( (TWO_BYTES) atoi( $1)).
1229 $2 == 4 ==> gen4( (FOUR_BYTES) atol( $1)).
1230 default ==> arg_error( "..icon", $1).
1233 $2 == 1 ==> gen1( (ONE_BYTE) atoi( $1)).
1234 $2 == 2 ==> gen2( (TWO_BYTES) atoi( $1)).
1235 $2 == 4 ==> gen4( (FOUR_BYTES) atol( $1)).
1236 default ==> arg_error( "..ucon", $1).
1238 ..fcon ==> con_float($1, $2).
1240 /******************************************************************************/
1242 /* Extra-routines */
1244 /******************************************************************************/
1248 C_df_ilb ==> clean_push_buf();
1249 symbol_definition( $1);
1250 set_local_visible( $1).
1253 C_jump ==> "jmp $1".
1255 C_prolog ==> "push bp";
1261 $1 == 2 ==> "push ax".
1263 $1 == 4 ==> "push ax";
1266 default ==> "sub sp, $1".