--- /dev/null
+EM_table
+Makefile
+as.c
+as.h
+as_table
+mach.c
+mach.h
--- /dev/null
+#define PUSH_POP_OPT TRUE
+
+/******************************************************************************/
+/* */
+/* Group 1 : load instructions */
+/* */
+/******************************************************************************/
+
+C_loc ==> "push $1".
+
+C_lol ==> "push $1(ebp)".
+
+C_loe.. ==> "push ($1+$2)".
+
+C_lil ==> "mov eax, $1(ebp)";
+ "push (eax)".
+
+C_lof ==> "pop eax";
+ "push $1(eax)".
+
+C_lal ==> "lea eax, $1(ebp)";
+ "push eax".
+
+C_lae.. ==> "push $1+$2".
+
+C_lxl
+ $1 == 0 ==> "push ebp".
+
+ $1 == 1 ==> "push 8(ebp)".
+
+ default ==> "mov ecx, $1-1";
+ "mov eax, 8(ebp)";
+ "1: mov eax, 8(eax)";
+ "loop 1b";
+ "push eax".
+
+C_lxa
+ $1 == 0 ==> "lea eax, 8(ebp)";
+ "push eax".
+
+ $1 == 1 ==> "mov eax, 8(ebp)";
+ "add eax, 8";
+ "push eax".
+
+ default ==> "mov ecx, $1-1";
+ "mov eax, 8(ebp)";
+ "1: mov eax, 8(eax)";
+ "loop 1b";
+ "add eax, 8";
+ "push eax".
+
+C_loi
+ $1 == 1 ==> "pop ecx";
+ "movzx eax, (ecx)";
+ "push eax".
+
+ $1 == 2 ==> "pop ecx";
+ "xor eax,eax";
+ "o16";
+ "mov eax, (ecx)";
+ "push (eax)".
+
+ $1 == 4 ==> "pop eax";
+ "push (eax)".
+
+ default ==> "pop ebx";
+ "mov ecx, $1";
+ "call .loi".
+
+C_los
+ $1 == 4 ==> "pop ecx";
+ "pop ebx";
+ "call .los".
+
+ default ==> arg_error( "C_los", $1).
+
+C_los_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop ecx";
+ "pop ebx";
+ "call .los".
+
+C_ldl ==> "push $1+4(ebp)";
+ "push $1(ebp)".
+
+C_lde.. ==> "push ($1+$2+4)";
+ "push ($1+$2)".
+
+C_ldf ==> "pop eax";
+ "push $1+4(eax)";
+ "push $1(eax)".
+
+C_lpi ==> "push $1".
+
+/******************************************************************************/
+/* */
+/* Group 2 : store instructions */
+/* */
+/******************************************************************************/
+
+C_stl ==> "pop $1(ebp)".
+
+C_ste.. ==> "pop ($1+$2)".
+
+C_sil ==> "mov eax, $1(ebp)";
+ "pop (eax)".
+
+C_stf ==> "pop eax";
+ "pop $1(eax)".
+
+C_sti
+ $1 == 1 ==> "pop ecx";
+ "pop eax";
+ "movb (ecx), al".
+
+ $1 == 2 ==> "pop eax";
+ "pop ecx";
+ "o16";
+ "mov (eax),ecx".
+
+ $1 == 4 ==> "pop eax";
+ "pop (eax)".
+
+ default ==> "pop ebx";
+ "mov ecx, $1";
+ "call .sti".
+
+C_sts
+ $1 == 4 ==> "pop ecx";
+ "pop ebx";
+ "call .sti".
+
+ default ==> arg_error( "C_sts", $1).
+
+C_sts_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop ecx";
+ "pop ebx";
+ "call .sti".
+
+C_sdl ==> "pop $1(ebp)";
+ "pop $1+4(ebp)".
+
+C_sde.. ==> "pop ($1+$2)";
+ "pop ($1+$2+4)".
+
+C_sdf ==> "pop eax";
+ "pop $1(eax)";
+ "pop $1+4(eax)".
+
+/******************************************************************************/
+/* */
+/* Group 3 : integer arithmetic */
+/* */
+/******************************************************************************/
+
+C_adi
+ $1 == 4 ==> "pop eax";
+ "pop ecx";
+ "add eax, ecx";
+ "push eax".
+
+ default ==> arg_error("C_adi", $1).
+
+C_adi_narg ==> "pop ecx";
+ "pop eax";
+ "call .adi";
+ "push eax".
+
+C_sbi
+ $1 == 4 ==> "pop ecx";
+ "pop eax";
+ "sub eax, ecx";
+ "push eax".
+
+ default ==> arg_error("C_sbi", $1).
+
+C_sbi_narg ==> "pop ecx";
+ "pop eax";
+ "call .sbi";
+ "push eax".
+
+C_mli
+ $1 == 4 ==> "pop eax";
+ "pop ecx";
+ "imul ecx";
+ "push eax".
+
+ default ==> arg_error( "C_mli", $1).
+
+C_mli_narg ==> "pop eax";
+ "call .mli".
+
+C_dvi
+ $1 == 4 ==> "pop ecx";
+ "pop eax";
+ "cdq";
+ "idiv ecx";
+ "push eax".
+
+ default ==> arg_error( "C_dvi", $1).
+
+C_dvi_narg ==> "pop eax";
+ "call .dvi".
+
+C_rmi
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "cdq";
+ "idiv ebx";
+ "push edx".
+
+ default ==> arg_error( "C_rmi", $1).
+
+C_rmi_narg ==> "pop eax";
+ "call .rmi".
+
+C_ngi
+ $1 == 4 ==> "pop eax";
+ "neg eax";
+ "push eax".
+
+ default ==> "mov eax, $1";
+ "call .ngi".
+
+C_ngi_narg ==> "pop eax";
+ "call .ngi".
+
+C_sli
+ $1 == 4 ==> "pop ecx";
+ "pop eax";
+ "sal eax, cl";
+ "push eax".
+
+ default ==> "mov eax, $1";
+ "call .sli".
+
+C_sli_narg ==> "pop eax";
+ "call .sli".
+
+C_sri
+ $1 == 4 ==> "pop ecx";
+ "pop eax";
+ "sar eax, cl";
+ "push eax".
+
+ default ==> "mov eax, $1";
+ "call .sri".
+
+C_sri_narg ==> "pop eax";
+ "call .sri".
+
+/******************************************************************************/
+/* */
+/* Group 4 : Unsigned arithmetic */
+/* */
+/******************************************************************************/
+
+C_adu ==> C_adi( $1).
+
+C_adu_narg ==> C_adi_narg().
+
+C_sbu ==> C_sbi( $1).
+
+C_sbu_narg ==> C_sbi_narg().
+
+C_mlu ==> C_mli( $1).
+
+C_mlu_narg ==> C_mli_narg().
+
+C_dvu
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "xor edx, edx";
+ "div ebx";
+ "push eax".
+
+ default ==> "mov eax, $1";
+ "call .dvu".
+
+C_dvu_narg ==> "pop eax";
+ "call .dvu".
+
+C_rmu
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "xor edx, edx";
+ "div ebx";
+ "push edx".
+
+ default ==> "mov eax, $1";
+ "call .rmu".
+
+C_rmu_narg ==> "pop eax";
+ "call .rmu".
+
+C_slu ==> C_sli( $1).
+
+C_slu_narg ==> C_sli_narg().
+
+C_sru
+ $1 == 4 ==> "pop ecx";
+ "pop eax";
+ "shr eax, cl";
+ "push eax".
+
+ default ==> arg_error( "C_sru", $1).
+
+/******************************************************************************/
+/* */
+/* Group 5 : Floating point arithmetic */
+/* */
+/******************************************************************************/
+
+C_adf
+ $1 == 4 ==> "call .adf4";
+ "pop ebx".
+ $1 == 8 ==> "call .adf8";
+ "add esp,8".
+ default ==> arg_error("C_adf", $1).
+
+C_sbf
+ $1 == 4 ==> "call .sbf4";
+ "pop ebx".
+ $1 == 8 ==> "call .sbf8";
+ "add esp,8".
+ default ==> arg_error("C_sbf", $1).
+
+C_mlf
+ $1 == 4 ==> "call .mlf4";
+ "pop ebx".
+ $1 == 8 ==> "call .mlf8";
+ "add esp,8".
+ default ==> arg_error("C_mlf", $1).
+
+C_dvf
+ $1 == 4 ==> "call .dvf4";
+ "pop ebx".
+ $1 == 8 ==> "call .dvf8";
+ "add esp,8".
+ default ==> arg_error("C_dvf", $1).
+
+C_fif
+ $1 == 4 ==> "call .fif4".
+ $1 == 8 ==> "call .fif8".
+ default ==> arg_error("C_fif", $1).
+
+C_fef
+ $1 == 4 ==> "pop eax";
+ "push eax";
+ "push eax";
+ "call .fef4".
+ $1 == 8 ==> "pop eax";
+ "pop ebx";
+ "push eax";
+ "push ebx";
+ "push eax";
+ "call .fef8".
+ default ==> arg_error("C_fef", $1).
+
+/******************************************************************************/
+/* */
+/* Group 6 : Pointer arithmetic */
+/* */
+/******************************************************************************/
+
+C_adp
+
+ $1 == 0 ==> .
+
+ $1 == 1 ==> "pop eax";
+ "inc eax";
+ "push eax".
+
+ $1 == -1 ==> "pop eax";
+ "dec eax";
+ "push eax".
+
+ default ==> "pop eax";
+ "add eax, $1";
+ "push eax".
+
+C_ads
+ $1 == 4 ==> "pop eax";
+ "pop ebx";
+ "add eax, ebx";
+ "push eax".
+
+ default ==> arg_error( "C_ads", $1).
+
+C_ads_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop eax";
+ "pop ebx";
+ "add eax, ebx";
+ "push eax".
+
+C_sbs
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "sub eax, ebx";
+ "push eax".
+
+ default ==> arg_error( "C_sbs", $1).
+
+C_sbs_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop ebx";
+ "pop eax";
+ "sub eax, ebx";
+ "push eax".
+
+/******************************************************************************/
+/* */
+/* Group 7 : Increment/decrement/zero */
+/* */
+/******************************************************************************/
+
+C_inc ==> "pop eax";
+ "inc eax";
+ "push eax".
+
+C_inl ==> "inc $1(ebp)".
+
+C_ine.. ==> "inc ($1+$2)".
+
+C_dec ==> "pop eax";
+ "dec eax";
+ "push eax".
+
+C_del ==> "dec $1(ebp)".
+
+C_dee.. ==> "dec ($1+$2)".
+
+C_zrl ==> "mov $1(ebp), 0".
+
+C_zre.. ==> "mov ($1+$2), 0".
+
+C_zer
+ $1 == 4 ==> "xor eax, eax";
+ "push eax".
+
+ $1 == 8 ==> "xor eax, eax";
+ "push eax";
+ "push eax".
+
+ $1 % 4 == 0 ==> "mov ecx, $1/4";
+ "xor eax, eax";
+ "1: push eax";
+ "loop 1b".
+
+ default ==> arg_error( "C_zer", $1).
+
+C_zrf ==> C_zer($1).
+
+C_zer_narg ==> "pop ecx";
+ "sar ecx, 2";
+ "xor eax, eax";
+ "1: push eax";
+ "loop 1b".
+
+/******************************************************************************/
+/* */
+/* Group 8 : Convert */
+/* */
+/******************************************************************************/
+
+C_cii ==> "pop ecx";
+ "pop edx";
+ "pop eax";
+ "call .cii";
+ "push eax".
+
+C_cui ==> C_cuu().
+
+C_ciu ==> C_cuu().
+
+C_cuu ==> "pop ecx";
+ "pop edx".
+
+C_cif ==> "pop eax";
+ "cmp eax,4";
+ "jne 1f";
+ "call .cif4";
+ "pop ebx";
+ "jmp 2f";
+ "1: call .cif8";
+ "2:".
+
+C_cuf ==> "pop eax";
+ "cmp eax,4";
+ "jne 1f";
+ "call .cuf4";
+ "pop ebx";
+ "jmp 2f";
+ "1: call .cuf8";
+ "2:".
+
+C_cfi ==> "call .cfi";
+ "pop ecx";
+ "pop ebx";
+ "cmp ebx,4";
+ "je 1f";
+ "pop ebx";
+ "1:".
+
+C_cfu ==> "call .cfu";
+ "pop ecx";
+ "pop ebx";
+ "cmp ebx,4";
+ "je 1f";
+ "pop ebx";
+ "1:".
+
+C_cff ==> "pop eax";
+ "pop ebx";
+ "cmp eax,ebx";
+ "je 1f";
+ "cmp eax,4";
+ "jne 2f";
+ "call .cff4";
+ "pop ebx";
+ "jmp 1f";
+ "2: pop eax";
+ "xor ebx,ebx";
+ "push ebx";
+ "push eax";
+ "call .cff8";
+ "1:".
+
+/******************************************************************************/
+/* */
+/* Group 9 : Logical */
+/* */
+/******************************************************************************/
+
+C_and
+ $1 == 4 ==> "pop eax";
+ "pop ebx";
+ "and eax, ebx";
+ "push eax".
+
+ default ==> "mov ecx, $1";
+ "call .and".
+
+C_and_narg ==> "pop ecx";
+ "call .and".
+
+C_ior
+ $1 == 4 ==> "pop eax";
+ "pop ebx";
+ "or eax, ebx";
+ "push eax".
+
+ default ==> "mov ecx, $1";
+ "call .ior".
+
+C_ior_narg ==> "pop ecx";
+ "call .ior".
+
+C_xor
+ $1 == 4 ==> "pop eax";
+ "pop ebx";
+ "xor eax, ebx";
+ "push eax".
+
+ default ==> "mov ecx, $1";
+ "call .xor".
+
+C_xor_narg ==> "pop ecx";
+ "call .xor".
+
+C_com
+ $1 == 4 ==> "pop eax";
+ "not eax";
+ "push eax".
+
+ default ==> "mov ecx, $1";
+ "call .com".
+
+C_com_narg ==> "pop ecx";
+ "call .com".
+
+C_rol
+ $1 == 4 ==> "pop ecx";
+ "pop eax";
+ "rol eax, cl";
+ "push eax".
+
+ default ==> "mov ecx, $1";
+ "call .rol".
+
+C_rol_narg ==> "pop ecx";
+ "call .rol".
+
+C_ror
+ $1 == 4 ==> "pop ecx";
+ "pop eax";
+ "ror eax, cl";
+ "push eax".
+
+ default ==> "mov ecx, $1";
+ "call .ror".
+
+C_ror_narg ==> "pop ecx";
+ "call .ror".
+
+/******************************************************************************/
+/* */
+/* Group 10 : Sets */
+/* */
+/******************************************************************************/
+
+C_inn
+ $1 == 4 ==> "pop ecx";
+ "pop eax";
+ "shr eax, cl";
+ "and eax, 1";
+ "push eax".
+
+ default ==> "pop eax";
+ "mov ecx, $1";
+ "call .inn";
+ "push eax".
+
+C_inn_narg ==> "pop ecx";
+ "pop eax";
+ "call .inn";
+ "push eax".
+
+C_set
+ $1 == 4 ==> "pop ecx";
+ "mov eax, 1";
+ "shl eax, cl";
+ "push eax".
+
+ default ==> "pop eax";
+ "mov ecx, $1";
+ "call .set".
+
+C_set_narg ==> "pop ecx";
+ "pop eax";
+ "call .set".
+
+/******************************************************************************/
+/* */
+/* Group 11 : Array */
+/* */
+/******************************************************************************/
+
+C_lar
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "call .lar4".
+
+ default ==> arg_error( "C_lar", $1).
+
+C_lar_narg ==> "call .ilar".
+
+C_sar
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "call .sar4".
+
+ default ==> arg_error( "C_sar", $1).
+
+C_sar_narg ==> "call .isar".
+
+C_aar
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "pop ecx";
+ "sub eax, (ebx)";
+ "mul 8(ebx)";
+ "add eax, ecx";
+ "push eax".
+
+ default ==> arg_error( "C_aar", $1).
+
+C_aar_narg ==> "call .iaar";
+ "push ebx".
+
+/******************************************************************************/
+/* */
+/* Group 12 : Compare */
+/* */
+/******************************************************************************/
+
+C_cmi
+ $1 == 4 ==> "pop ebx";
+ "pop ecx";
+ "xor eax, eax";
+ "cmp ecx, ebx";
+ "je 2f";
+ "jl 1f";
+ "inc eax";
+ "jmp 2f";
+ "1: dec eax";
+ "2: push eax".
+
+ default ==> arg_error( "C_cmi", $1).
+
+C_cmu
+ $1 == 4 ==> C_cmp().
+
+ default ==> arg_error( "C_cmu", $1).
+
+C_cms
+ $1 == 4 ==> C_sbi( (arith) 4).
+
+ default ==> "mov ecx, $1";
+ "call .cms";
+ "push ecx".
+
+C_cms_narg ==> "pop ecx";
+ "call .cms";
+ "push ecx".
+
+C_cmp ==> "pop ebx";
+ "pop ecx";
+ "xor eax, eax";
+ "cmp ecx, ebx";
+ "je 2f";
+ "jb 1f";
+ "inc eax";
+ "jmp 2f";
+ "1: dec eax";
+ "2: push eax".
+
+C_cmf
+ $1 == 4 ==> "call .cmf4";
+ "pop ebx";
+ "pop ebx";
+ "push eax".
+ $1 == 8 ==> "call .cmf8";
+ "add esp,16";
+ "push eax".
+ default ==> arg_error("C_cmf", $1).
+
+C_tlt ==> "pop eax";
+ "xor ebx, ebx";
+ "test eax, eax";
+ "jge 1f";
+ "inc ebx";
+ "1: push ebx".
+
+C_tle ==> "pop eax";
+ "xor ebx, ebx";
+ "test eax, eax";
+ "jg 1f";
+ "inc ebx";
+ "1: push ebx".
+
+C_teq ==> "pop eax";
+ "xor ebx, ebx";
+ "test eax, eax";
+ "jne 1f";
+ "inc ebx";
+ "1: push ebx".
+
+C_tne ==> "pop eax";
+ "xor ebx, ebx";
+ "test eax, eax";
+ "je 1f";
+ "inc ebx";
+ "1: push ebx".
+
+C_tge ==> "pop eax";
+ "xor ebx, ebx";
+ "test eax, eax";
+ "jl 1f";
+ "inc ebx";
+ "1: push ebx".
+
+C_tgt ==> "pop eax";
+ "xor ebx, ebx";
+ "test eax, eax";
+ "jle 1f";
+ "inc ebx";
+ "1: push ebx".
+
+/******************************************************************************/
+/* */
+/* Group 13 : Branch */
+/* */
+/******************************************************************************/
+
+C_bra ==> "jmp $1".
+
+C_blt ==> "pop eax";
+ "pop ebx";
+ "cmp ebx, eax";
+ "jl $1".
+
+C_ble ==> "pop eax";
+ "pop ebx";
+ "cmp ebx, eax";
+ "jle $1".
+
+C_beq ==> "pop eax";
+ "pop ebx";
+ "cmp ebx, eax";
+ "je $1".
+
+C_bne ==> "pop eax";
+ "pop ebx";
+ "cmp ebx, eax";
+ "jne $1".
+
+C_bge ==> "pop eax";
+ "pop ebx";
+ "cmp ebx, eax";
+ "jge $1".
+
+C_bgt ==> "pop eax";
+ "pop ebx";
+ "cmp ebx, eax";
+ "jg $1".
+
+C_zlt ==> "pop eax";
+ "test eax, eax";
+ "jl $1".
+
+C_zle ==> "pop eax";
+ "test eax, eax";
+ "jle $1".
+
+C_zeq ==> "pop eax";
+ "test eax, eax";
+ "je $1".
+
+C_zne ==> "pop eax";
+ "test eax, eax";
+ "jne $1".
+
+C_zge ==> "pop eax";
+ "test eax, eax";
+ "jge $1".
+
+C_zgt ==> "pop eax";
+ "test eax, eax";
+ "jg $1".
+
+/******************************************************************************/
+/* */
+/* Group 14 : Procedure call instructions */
+/* */
+/******************************************************************************/
+
+C_cai ==> "pop ebx";
+ "call ebx".
+
+C_cal ==> "call $1".
+
+C_lfr
+ $1 == 4 ==> "push eax".
+
+ $1 == 8 ==> "push edx";
+ "push eax".
+
+ default ==> arg_error( "C_lfr", $1).
+
+C_ret
+ $1 == 0 ==> "leave";
+ "ret".
+
+ $1 == 4 ==> "pop eax";
+ "leave";
+ "ret".
+
+ $1 == 8 ==> "pop eax";
+ "pop edx";
+ "leave";
+ "ret".
+
+ default ==> arg_error( "C_ret", $1).
+
+/******************************************************************************/
+/* */
+/* Group 15 : Miscellaneous instructions */
+/* */
+/******************************************************************************/
+
+C_asp
+ $1 == 4 ==> "pop ebx".
+
+ $1 == 8 ==> "pop ebx";
+ "pop ebx".
+
+ $1 == -4 ==> "push eax".
+
+ $1 == -8 ==> "push eax";
+ "push eax".
+
+ default ==> "add esp, $1".
+
+C_ass
+ $1 == 4 ==> "pop eax";
+ "add esp, eax".
+
+ default ==> arg_error( "C_ass", $1).
+
+C_ass_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop eax";
+ "add esp, eax".
+
+C_blm
+ $1 % 4 == 0 ==> "mov ecx, $1/4";
+ "call .blm".
+
+ default ==> arg_error( "C_blm", $1).
+
+C_bls
+ $1 == 4 ==> "pop ecx";
+ "sar ecx,2";
+ "call .blm".
+
+ default ==> arg_error( "C_bls", $1).
+
+C_bls_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop ecx";
+ "sar ecx, 2";
+ "call .blm".
+
+C_csa
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "jmp .csa4".
+
+ default ==> arg_error( "C_csa", $1).
+
+C_csa_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop ebx";
+ "pop eax";
+ "jmp .csa4".
+
+C_csb
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "jmp .csb4".
+
+ default ==> arg_error( "C_csb", $1).
+
+C_csb_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop ebx";
+ "pop eax";
+ "jmp .csb4".
+
+C_dch ==> "mov ebp, (ebp)".
+
+C_dup
+ $1 == 4 ==> "pop eax";
+ "push eax";
+ "push eax".
+
+ $1 == 8 ==> "pop eax";
+ "pop ebx";
+ "push ebx";
+ "push eax";
+ "push ebx";
+ "push eax".
+
+ default ==> "mov ecx, $1";
+ "call .dup".
+
+C_dus
+ $1 == 4 ==> "pop ecx";
+ "call .dup".
+
+ default ==> arg_error( "C_dus", $1).
+
+C_dus_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop ecx";
+ "call .dup".
+
+C_exg ==> "mov ecx, $1";
+ "call .exg".
+
+C_exg_narg ==> "pop ecx";
+ "call .exg".
+
+C_fil.. ==> "mov (hol0+4), $1+$2".
+
+C_gto.. ==> "mov ebx, $1+$2";
+ "call .gto".
+
+C_lim ==> "push (.ignmask)".
+
+C_lin ==> "mov (hol0), $1".
+
+C_lni ==> "inc (hol0)".
+
+C_lor
+ $1 == 0 ==> "push ebp".
+
+ $1 == 1 ==> "mov eax, esp";
+ "push eax".
+
+ $1 == 2 ==> "push (.reghp)".
+
+ default ==> arg_error( "C_lor", $1).
+
+C_lpb ==> "pop eax";
+ "add eax, 8";
+ "push eax".
+
+C_mon ==> "pop eax";
+ "call .mon".
+
+C_nop ==> "call .nop".
+
+C_rck
+ $1 == 4 ==> "pop ebx";
+ "pop eax";
+ "call .rck";
+ "push eax".
+
+ default ==> arg_error( "C_rck", $1).
+
+C_rck_narg ==> "pop eax";
+ "cmp eax, 4";
+ "jne .unknown";
+ "pop ebx";
+ "pop eax";
+ "call .rck";
+ "push eax".
+
+
+C_rtt ==> C_ret( (arith) 0).
+
+C_sig ==> "pop eax";
+ "xchg (.trppc), eax";
+ "push eax".
+
+C_sim ==> "pop (.ignmask)".
+
+C_str
+ $1 == 0 ==> "pop ebp".
+
+ $1 == 1 ==> "pop esp".
+
+ $1 == 2 ==> "pop (.reghp)".
+
+ default ==> arg_error( "C_str", $1).
+
+C_trp ==> "pop eax";
+ "call .trp".
+
+/******************************************************************************/
+/* */
+/* Storage-routines */
+/* */
+/******************************************************************************/
+
+
+..icon
+ $2 == 1 ==> gen1( (ONE_BYTE) atoi( $1)).
+ $2 == 2 ==> gen2( (TWO_BYTES) atoi( $1)).
+ $2 == 4 ==> gen4( (FOUR_BYTES) atol( $1)).
+ default ==> arg_error( "..icon", $1).
+
+..ucon
+ $2 == 1 ==> gen1( (ONE_BYTE) atoi( $1)).
+ $2 == 2 ==> gen2( (TWO_BYTES) atoi( $1)).
+ $2 == 4 ==> gen4( (FOUR_BYTES) atol( $1)).
+ default ==> arg_error( "..ucon", $1).
+
+..fcon ==> con_float($1, $2).
+
+/******************************************************************************/
+/* */
+/* Extra-routines */
+/* */
+/******************************************************************************/
+
+#ifdef PUSH_POP_OPT
+
+C_df_ilb ==> clean_push_buf();
+ symbol_definition( $1);
+ set_local_visible( $1).
+#endif
+
+C_jump ==> "jmp $1".
+
+C_prolog ==> .
+
+C_locals
+ $1 < 32767 ==> "enter $1,0".
+ default ==> "enter 0,0";
+ "sub esp, $1".
--- /dev/null
+EMHOME = ../../..
+CEG = $(EMHOME)/lib/ceg/util
+VERSION = make_obj
+
+all:
+ make -f $(CEG)/$(VERSION)
+
+install:
+ make -f $(CEG)/$(VERSION) install
+
+cmp:
+ -make -f $(CEG)/$(VERSION) cmp
+
+pr:
+ @pr Makefile EM_table mach.h mach.c as_table as.h as.c
+
+opr:
+ make pr | opr
+
+# total cleanup
+clean:
+ make -f $(CEG)/$(VERSION) clean
+
+# only remove ce, ceg, and back directories
+dclean:
+ make -f $(CEG)/$(VERSION) dclean
--- /dev/null
+#include "arg_type.h"
+#include "as.h"
+
+#define last( s) ( s + strlen( s) - 1)
+#define LEFT '('
+#define RIGHT ')'
+#define DOLLAR '$'
+
+block_assemble( instr, nr, first, Last)
+char **instr;
+int nr, first, Last;
+{
+ int i;
+
+/*
+ if ( first) {
+ if( strncmp( instr[0], "pop", 3) == 0) {
+ *instr[0] = 'P';
+ *( instr[0]+1) = 'O';
+ *( instr[0]+2) = 'P';
+ }
+ else
+ @clean_push_buf();
+ }
+ if ( Last && strncmp( instr[nr-1], "push", 4) == 0) {
+ *instr[nr-1] = 'P';
+ *( instr[nr-1]+1) = 'U';
+ *( instr[nr-1]+2) = 'S';
+ *( instr[nr-1]+3) = 'H';
+ }
+*/
+ for( i=0; i<nr; i++)
+ assemble( instr[i]);
+}
+
+
+process_label( l)
+char *l;
+{
+}
+
+
+process_mnemonic( m)
+char *m;
+{
+}
+
+
+process_operand( str, op)
+char *str;
+struct t_operand *op;
+
+/* expr -> IS_DATA en IS_LABEL
+ * reg -> IS_REG en IS_ACCU
+ * (expr) -> IS_ADDR
+ * expr(reg) -> IS_MEM
+ */
+{
+ char *ptr, *index();
+
+ op->type = UNKNOWN;
+ if ( *last( str) == RIGHT) {
+ ptr = index( str, LEFT);
+ *last( str) = '\0';
+ *ptr = '\0';
+ if ( is_reg( ptr+1, op)) {
+ op->type = IS_MEM;
+ op->expr = ( *str == '\0' ? "0" : str);
+ }
+ else {
+ set_label( ptr+1, op);
+ op->type = IS_ADDR;
+ }
+ }
+ else
+ if ( is_reg( str, op))
+ op->type = IS_REG;
+ else {
+ if ( contains_label( str))
+ set_label( str, op);
+ else {
+ op->type = IS_DATA;
+ op->expr = str;
+ }
+ }
+}
+
+static struct regnam {
+ char *regstr;
+ int regval;
+} regnam[] = {
+ { "eax", 0 },
+ { "ebx", 3 },
+ { "ecx", 1 },
+ { "edx", 2 },
+ { "esp", 4 },
+ { "ebp", 5 },
+ { "esi", 6 },
+ { "edi", 7 },
+ { "al", 0 },
+ { "bl", 3 },
+ { "cl", 1 },
+ { "dl", 2 },
+ { "ah", 4 },
+ { "bh", 7 },
+ { "ch", 5 },
+ { "dh", 6 },
+ { 0, 0}
+}
+;
+
+int is_reg( str, op)
+char *str;
+struct t_operand *op;
+{
+ register struct regnam *p = regnam;
+
+ while (p->regstr) {
+ if (! strcmp(p->regstr, str)) {
+ op->reg = p->regval;
+ return TRUE;
+ }
+ p++;
+ }
+ return FALSE;
+}
+
+#include <ctype.h>
+#define isletter( c) ( isalpha( c) || c == '_')
+
+int contains_label( str)
+char *str;
+{
+ while( !isletter( *str) && *str != '\0')
+ if ( *str == '$')
+ if ( arg_type( str) == STRING)
+ return( TRUE);
+ else
+ str += 2;
+ else
+ str++;
+
+ return( isletter( *str));
+}
+
+set_label( str, op)
+char *str;
+struct t_operand *op;
+{
+ char *ptr, *index(), *sprint();
+ static char buf[256];
+
+ ptr = index( str, '+');
+
+ if ( ptr == 0)
+ op->off = "0";
+ else {
+ *ptr = '\0';
+ op->off = ptr + 1;
+ }
+
+ if ( isdigit( *str) && ( *(str+1) == 'b' || *(str+1) == 'f') &&
+ *(str+2) == '\0') {
+ *(str+1) = '\0'; /* remove b or f! */
+ op->lab = str;
+ op->type = IS_ILB;
+ }
+ else {
+ op->type = IS_LABEL;
+ if ( index( str, DOLLAR) != 0)
+ op->lab = str;
+ else
+ op->lab = sprint( buf, "\"%s\"", str);
+ }
+}
+
+
+/******************************************************************************/
+
+
+
+mod_RM( reg, op)
+int reg;
+struct t_operand *op;
+{
+ if ( REG( op))
+ R233( 0x3, reg, op->reg);
+ else if ( ADDR( op)) {
+ R233( 0x0, reg, 0x5);
+ @reloc4( %$(op->lab), %$(op->off), ABSOLUTE);
+ }
+ else if ( strcmp( op->expr, "0") == 0)
+ switch( op->reg) {
+ case AX:
+ case BX:
+ case CX:
+ case DX:
+ case DI:
+ case SI: R233( 0x0, reg, op->reg);
+ break;
+
+ case BP : R233( 0x1, reg, 0x6); /* Exception! */
+ @text1( 0);
+ break;
+
+ default : fprint( STDERR, "Wrong index register %d\n",
+ op->reg);
+ }
+ else {
+ if (isdigit(op->expr[0])) {
+ long l, atol();
+
+ l = atol(op->expr);
+ if ( l <= 127 && l >= -128) {
+ switch( op->reg) {
+ case AX:
+ case BX:
+ case CX:
+ case DX:
+ case DI:
+ case BP:
+ case SI : R233( 0x1, reg, op->reg);
+ break;
+
+ default : fprint( STDERR, "Wrong index register %d\n",
+ op->reg);
+ }
+ @text1( %$(op->expr));
+ } else {
+ switch( op->reg) {
+ case AX:
+ case BX:
+ case CX:
+ case DX:
+ case DI:
+ case BP:
+ case SI : R233( 0x2, reg, op->reg);
+ break;
+
+ default : fprint( STDERR, "Wrong index register %d\n",
+ op->reg);
+ }
+ @text4( %$(op->expr));
+ }
+ } else {
+ @if ( fit_byte( %$(op->expr)))
+ switch( op->reg) {
+ case AX:
+ case BX:
+ case CX:
+ case DX:
+ case DI:
+ case BP:
+ case SI : R233( 0x1, reg, op->reg);
+ break;
+
+ default : fprint( STDERR, "Wrong index register %d\n",
+ op->reg);
+ }
+ @text1( %$(op->expr));
+ @else
+ switch( op->reg) {
+ case AX:
+ case BX:
+ case CX:
+ case DX:
+ case DI:
+ case BP:
+ case SI : R233( 0x2, reg, op->reg);
+ break;
+
+ default : fprint( STDERR, "Wrong index register %d\n",
+ op->reg);
+ }
+ @text4( %$(op->expr));
+ @fi
+ }
+ }
+}
+
+mv_RG_EADDR( dst, src)
+struct t_operand *dst, *src;
+{
+ if ( REG(src) && dst->reg == src->reg)
+ ; /* Nothing!! result of push/pop optimization */
+ else {
+ @text1( 0x8b);
+ mod_RM( dst->reg, src);
+ }
+}
+
+
+R233( a, b, c)
+int a,b,c;
+{
+ @text1( %d( (a << 6) | ( b << 3) | c));
+}
+
+
+R53( a, b)
+int a,b;
+{
+ @text1( %d( (a << 3) | b));
+}
+
+small_const(opc, src)
+ struct t_operand *src;
+{
+ if (isdigit(src->expr[0])) {
+ long l, atol();
+
+ l = atol(src->expr);
+ if (l >= -128 && l <= 127) {
+ @text1(%d(opc|02));
+ @text1(%$(src->expr));
+ }
+ else {
+ @text1(%d(opc));
+ @text4(%$(src->expr));
+ }
+ }
+ else {
+ @if (fit_byte(%$(src->expr)))
+ @text1(%d(opc|02));
+ @text1(%$(src->expr));
+ @else
+ @text1(%d(opc));
+ @text1(%$(src->expr));
+ @fi
+ }
+}
+
+small_RMconst(opc, reg, dst, src)
+ struct t_operand *dst, *src;
+{
+ if (isdigit(src->expr[0])) {
+ long l, atol();
+
+ l = atol(src->expr);
+ if (l >= -128 && l <= 127) {
+ @text1(%d(opc|02));
+ mod_RM(reg, dst);
+ @text1(%$(src->expr));
+ }
+ else {
+ @text1(%d(opc));
+ mod_RM(reg, dst);
+ @text4(%$(src->expr));
+ }
+ }
+ else {
+ @if (fit_byte(%$(src->expr)))
+ @text1(%d(opc|02));
+ mod_RM(reg, dst);
+ @text1(%$(src->expr));
+ @else
+ @text1(%d(opc));
+ mod_RM(reg, dst);
+ @text1(%$(src->expr));
+ @fi
+ }
+}
--- /dev/null
+#define UNKNOWN 0
+#define IS_REG 0x1
+#define IS_ACCU 0x2
+#define IS_DATA 0x4
+#define IS_LABEL 0x8
+#define IS_MEM 0x10
+#define IS_ADDR 0x20
+#define IS_ILB 0x40
+
+#define AX 0
+#define BX 3
+#define CX 1
+#define DX 2
+#define CL 1
+#define SP 4
+#define BP 5
+#define SI 6
+#define DI 7
+
+#define REG( op) ( op->type & IS_REG)
+#define ACCU( op) ( op->type & IS_REG && op->reg == AX)
+#define REG_CL( op) ( op->type & IS_REG && op->reg == CL)
+#define DATA( op) ( op->type & IS_DATA)
+#define lABEL( op) ( op->type & IS_LABEL)
+#define ILB( op) ( op->type & IS_ILB)
+/*#define MEM( op) ( op->type & IS_MEM)*/
+#define ADDR( op) ( op->type & IS_ADDR)
+#define EADDR( op) ( op->type & ( IS_ADDR | IS_MEM | IS_REG))
+
+#define TRUE 1
+#define FALSE 0
+
+struct t_operand {
+ unsigned type;
+ int reg;
+ char *expr, *lab, *off;
+ };
--- /dev/null
+add dst:REG, src:EADDR ==> @text1( 0x3);
+ mod_RM( dst->reg, src).
+
+... dst:ACCU, src:DATA ==> @text1( 0x5);
+ @text4( %$(src->expr)).
+
+... dst:EADDR, src:DATA ==> small_RMconst(0x81, 0, dst, src).
+
+and dst:REG, src:EADDR ==> @text1( 0x23);
+ mod_RM( dst->reg, src).
+
+... dst:ACCU, src:DATA ==> @text1( 0x25);
+ @text4( %$(src->expr)).
+
+call dst:lABEL ==> @text1( 0xe8);
+ @reloc4( %$(dst->lab), %$(dst->off), PC_REL).
+
+... dst:EADDR ==> @text1( 0xff);
+ mod_RM( 2, dst).
+
+cdq ==> @text1(0x99).
+
+cmp dst:REG, src:EADDR ==> @text1( 0x3b);
+ mod_RM( dst->reg, src).
+
+... dst:ACCU, src:DATA ==> @text1( 0x3d);
+ @text4( %$(src->expr)).
+
+... dst:EADDR, src:DATA ==> small_RMconst(0x81, 7, dst, src).
+
+dec dst:REG ==> R53( 9, dst->reg).
+
+... dst:EADDR ==> @text1( 0xff);
+ mod_RM( 1, dst).
+
+div divisor:EADDR ==> @text1( 0xf7);
+ mod_RM( 6, divisor).
+
+enter nm:DATA, nm1:DATA ==> @text1( 0xc8);
+ @text2( %$(nm->expr));
+ @text1( %$(nm1->expr)).
+
+idiv divisor:EADDR ==> @text1( 0xf7);
+ mod_RM( 7, divisor).
+
+imul mplier:EADDR ==> @text1( 0xf7);
+ mod_RM( 5, mplier).
+
+inc dst:REG ==> R53( 8, dst->reg).
+
+... dst:EADDR ==> @text1( 0xff);
+ mod_RM( 0, dst).
+
+jb dst:ILB ==> @text1( 0x72);
+ @text1( %dist( dst->lab)).
+
+... dst:lABEL ==> @text1(0x0f);
+ @text1(0x12);
+ @reloc4( %$(dst->lab), %$(dst->off), PC_REL).
+
+je dst:ILB ==> @text1( 0x74);
+ @text1( %dist( dst->lab)).
+
+... dst:lABEL ==> @text1(0x0f);
+ @text1(0x14);
+ @reloc4( %$(dst->lab), %$(dst->off), PC_REL).
+
+jg dst:ILB ==> @text1( 0x7f);
+ @text1( %dist( dst->lab)).
+
+... dst:lABEL ==> @text1(0x0f);
+ @text1(0x1f);
+ @reloc4( %$(dst->lab), %$(dst->off), PC_REL).
+
+jge dst:ILB ==> @text1( 0x7d);
+ @text1( %dist( dst->lab)).
+
+... dst:lABEL ==> @text1(0x0f);
+ @text1(0x1d);
+ @reloc4( %$(dst->lab), %$(dst->off), PC_REL).
+
+jl dst:ILB ==> @text1( 0x7c);
+ @text1( %dist( dst->lab)).
+
+... dst:lABEL ==> @text1(0x0f);
+ @text1(0x1c);
+ @reloc4( %$(dst->lab), %$(dst->off), PC_REL).
+
+jle dst:ILB ==> @text1( 0x7e);
+ @text1( %dist( dst->lab)).
+
+... dst:lABEL ==> @text1(0x0f);
+ @text1(0x1e);
+ @reloc4( %$(dst->lab), %$(dst->off), PC_REL).
+
+jmp dst:ILB ==> @text1( 0xeb);
+ @text1( %dist( dst->lab)).
+
+... dst:lABEL ==> @text1( 0xe9);
+ @reloc4( %$(dst->lab), %$(dst->off), PC_REL).
+
+jne dst:ILB ==> @text1( 0x75);
+ @text1( %dist( dst->lab)).
+
+... dst:lABEL ==> @text1(0x0f);
+ @text1(0x85);
+ @reloc4( %$(dst->lab), %$(dst->off), PC_REL).
+
+lea dst:REG, src:EADDR ==> @text1( 0x8d);
+ mod_RM( dst->reg, src).
+
+loop dst:ILB ==> @text1( 0xe2);
+ @text1( %dist( dst->lab)).
+
+mov dst:REG, src:EADDR ==> mv_RG_EADDR( dst, src).
+
+... dst:REG, src:DATA ==> R53( 0x17, dst->reg);
+ @text4(%$(src->expr)).
+
+... dst:EADDR, src:REG ==> @text1( 0x89);
+ mod_RM( src->reg, dst).
+
+... dst:EADDR, src:DATA ==> @text1( 0xc7);
+ mod_RM( 0, dst);
+ @text4( %$(src->expr)).
+
+... dst:EADDR, src:lABEL ==> @text1( 0xc7);
+ mod_RM( 0, dst);
+ @reloc4( %$(src->lab), %$(src->off), ABSOLUTE).
+
+movb dst:EADDR, src:REG ==> @text1( 0x88);
+ mod_RM( src->reg, dst).
+
+movzx dst:REG, src:EADDR ==> @text1(0x0f);
+ @text1(0xb7);
+ mod_RM(dst->reg, src).
+
+mul mplier:EADDR ==> @text1( 0xf7);
+ mod_RM( 4, mplier).
+
+neg dst:EADDR ==> @text1( 0xf7);
+ mod_RM( 3, dst).
+
+not dst:EADDR ==> @text1( 0xf7);
+ mod_RM( 2, dst).
+
+o16 ==> @text1(0x66).
+
+or dst:REG, src:EADDR ==> @text1( 0x0b);
+ mod_RM( dst->reg, src).
+
+pop dst:REG ==> R53( 0xb, dst->reg).
+
+... dst:EADDR ==> @text1( 0x8f);
+ mod_RM( 0, dst).
+
+/*
+POP dst ==> @if ( push_waiting)
+ mov_instr( dst, AX_oper);
+ @assign( push_waiting, FALSE).
+ @else
+ pop_instr( dst).
+ @fi.
+*/
+
+push src:REG ==> R53( 0xa, src->reg).
+
+... src:DATA ==> small_const(0x68, src).
+
+... src:lABEL ==> @emit1(0x68);
+ @reloc4(%$(src->lab), %$(src->off), ABSOLUTE).
+
+... src:EADDR ==> @text1( 0xff);
+ mod_RM( 6, src).
+
+/*
+PUSH src ==> mov_instr( AX_oper, src);
+ @assign( push_waiting, TRUE).
+*/
+ret ==> @text1( 0xc3). /* Always NEAR! */
+
+leave ==> @text1( 0xc9). /* Always NEAR! */
+
+rol dst:EADDR, src:REG_CL ==> @text1( 0xd3);
+ mod_RM( 0, dst).
+
+ror dst:EADDR, src:REG_CL ==> @text1( 0xd3);
+ mod_RM( 1, dst).
+
+sal dst:EADDR, src:REG_CL ==> @text1( 0xd3);
+ mod_RM( 4, dst).
+
+sar dst:EADDR, src:REG_CL ==> @text1( 0xd3);
+ mod_RM( 7, dst).
+
+... dst:EADDR, src:DATA ==> @text1( 0xc1);
+ mod_RM( 7, dst);
+ @text1(%$(src->expr)).
+
+shl dst:EADDR, src:REG_CL ==> @text1(0xd3);
+ mod_RM(4, dst).
+
+shr dst:EADDR, src:REG_CL ==> @text1( 0xd3);
+ mod_RM( 5, dst).
+
+sub dst:REG, src:EADDR ==> @text1( 0x2b);
+ mod_RM( dst->reg, src).
+
+... dst:EADDR, src:DATA ==> small_RMconst(0x81, 5, dst, src).
+
+test dst:REG, src:EADDR ==> @text1( 0x85);
+ mod_RM( dst->reg, src).
+
+xchg dst:EADDR, src:REG ==> @text1( 0x87);
+ mod_RM( src->reg, dst).
+
+xor dst:REG, src:EADDR ==> @text1( 0x33);
+ mod_RM( dst->reg, src).
--- /dev/null
+#define CODE_EXPANDER
+#include <system.h>
+#include "back.h"
+#include "mach.h"
+
+#ifdef DEBUG
+arg_error( s, arg)
+char *s;
+int arg;
+{
+ fprint( STDERR, "arg_error %s %d\n", s, arg);
+}
+#endif
+
+int push_waiting = FALSE;
+
+int fit_byte( val)
+int val;
+{
+ return( val >= -128 && val <= 127);
+}
+
+con_float(str, argval)
+ char *str;
+ int argval;
+{
+#ifdef NOFLOAT
+
+static int been_here;
+ if (argval != 4 && argval != 8)
+ arg_error("fcon", argval);
+ if (argval == 8)
+ gen4((FOUR_BYTES) 0);
+ gen4((FOUR_BYTES) 0);
+ if ( !been_here++)
+ {
+ fprint(STDERR, "Warning : dummy float-constant(s)\n");
+ }
+#else
+#define IEEEFLOAT
+ double f;
+ double atof();
+ int i;
+ int j;
+ double frexp();
+#ifndef OWNFLOAT
+ int sign = 0;
+ int fraction[4] ;
+#else OWNFLOAT
+ float fl;
+ char *p;
+#endif OWNFLOAT
+
+ if (argval!= 4 && argval!= 8) {
+ arg_error("fcon", argval);
+ argval = 8;
+ }
+ f = atof(str);
+ if (f == 0) {
+ if (argval == 8) gen4((FOUR_BYTES) 0);
+ gen4((FOUR_BYTES) 0);
+ return;
+ }
+#ifdef OWNFLOAT
+ if (argval == 4) {
+ /* careful: avoid overflow */
+ double ldexp();
+ f = frexp(f, &i);
+ fl = f;
+ fl = frexp(fl,&j);
+ if (i+j > 127) {
+ /* overflow situation */
+ gen1(f<0?0377:0177);
+ gen1(0377);
+ gen1(0377);
+ gen1(0377);
+ return;
+ }
+ if (i+j < -127) {
+ /* underflow situation */
+ gen1(f<0?0200:0);
+ gen1(0200);
+ gen1(0);
+ gen1(0);
+ return;
+ }
+ fl = ldexp(fl, i+j);
+ p = (char *) &fl;
+ }
+ else {
+ p = (char *) &f;
+ }
+ gen1(*p++&0377);
+ for (i = argval-1; i; i--) {
+ gen1(*p++&0377);
+ }
+#else OWNFLOAT
+ f = frexp(f, &i);
+ if (f < 0) {
+ f = -f;
+ sign = 1;
+ }
+ while (f < 0.5) {
+ f += f;
+ i --;
+ }
+ f = 2*f - 1.0; /* hidden bit */
+#ifdef IEEEFLOAT
+ if (argval == 4) {
+#endif IEEEFLOAT
+ i = (i + 128) & 0377;
+ fraction[0] = (sign << 15) | (i << 7);
+ for (j = 6; j>= 0; j--) {
+ f *= 2;
+ if (f >= 1.0) {
+ f -= 1.0;
+ fraction[0] |= (1 << j);
+ }
+ }
+#ifdef IEEEFLOAT
+ }
+ else {
+ i = (i + 1024) & 03777;
+ fraction[0] = (sign << 15) | (i << 4);
+ for (j = 3; j>= 0; j--) {
+ f *= 2;
+ if (f >= 1.0) {
+ fraction[0] |= (1 << j);
+ f -= 1.0;
+ }
+ }
+ }
+#endif IEEEFLOAT
+ for (i = 1; i < argval / 2; i++) {
+ fraction[i] = 0;
+ for (j = 15; j>= 0; j--) {
+ f *= 2;
+ if (f >= 1.0) {
+ fraction[i] |= (1 << j);
+ f -= 1.0;
+ }
+ }
+ }
+ if (f >= 0.5) {
+ for (i = argval/2 - 1; i >= 0; i--) {
+ for (j = 0; j < 16; j++) {
+ if (fraction[i] & (1 << j)) {
+ fraction[i] &= ~(1 << j);
+ }
+ else {
+ fraction[i] |= (1 << j);
+ break;
+ }
+ }
+ if (j != 16) break;
+ }
+ }
+ for (i = 0; i < argval/2; i++) {
+ gen1((fraction[i]>>8)&0377);
+ gen1(fraction[i]&0377);
+ }
+#endif OWNFLOAT
+#endif
+}
+
+/* as long as we generate assembler ...
+
+do_open(filename)
+ char *filename;
+{
+ if (filename == 0 || ! sys_open(filename, OP_WRITE, &codefile))
+ return FALSE;
+
+ fprint( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n"); return TRUE;
+}
+*/
--- /dev/null
+#define BSS_INIT 0
+
+#define ONE_BYTE int
+#define TWO_BYTES int
+#define FOUR_BYTES long
+
+
+#define EM_WSIZE 4
+#define EM_PSIZE 4
+#define EM_BSIZE 8
+
+
+#define NAME_FMT "_%s"
+#define DNAM_FMT "_%s"
+#define DLB_FMT "I_%ld"
+#define ILB_FMT "I%03d%ld"
+#define HOL_FMT "hol%d"
+
+#define ALIGN_FMT ".align\n"
+
+#define BYTE_FMT ".data1 %ld\n"
+#define WORD_FMT ".data2 %ld\n"
+#define LONG_FMT ".data4 %ld\n"
+#define BSS_FMT ".space %ld\n"
+
+#define SEGTXT_FMT ".sect .text\n"
+#define SEGDAT_FMT ".sect .data\n"
+#define SEGBSS_FMT ".sect .bss\n"
+
+#define SYMBOL_DEF_FMT "%s :\n"
+#define GLOBAL_FMT ".extern %s\n"
+#define LOCAL_FMT ""
+
+#define RELOC1_FMT ".data1 %s + %ld\n"
+#define RELOC2_FMT ".data2 %s + %ld\n"
+#define RELOC4_FMT ".data4 %s + %ld\n"
+
+#define COMM_FMT ".comm %s,%ld\n"
+#define GENLAB 'I'
+
+#define TRUE 1
+#define FALSE 0
+
+#define clean_push_buf() if(push_waiting){text1(0x50);push_waiting=FALSE;}
+#define assign( l, r) l = r
+extern int push_waiting;
+
+#ifndef DEBUG
+#define arg_error(s,i)
+#endif
--- /dev/null
+SUF=o
+MAKEFILE=../../proto/libg/Makefile
+MACHDEF="MACH=i386" "SUF=$(SUF)" "ASAR=aal"
+BCDEF="PREF=bc" "SUB=" "SRC=lang/basic/lib"
+
+install:
+ make -f $(MAKEFILE) $(BCDEF) $(MACHDEF) tailcp
+
+cmp:
+ make -f $(MAKEFILE) $(BCDEF) $(MACHDEF) tail
+ -../../compare head_bc
+ -../../compare tail_bc
+
+clean:
+ -rm -f *.old *.[ce$(SUF)] tail* head*
+
+opr:
+ make pr | opr
+
+pr:
+ @pr Makefile
--- /dev/null
+if ${MACH?} -I../../../h ${MACHFL?} $1 1>&2
+then
+ echo `basename $1 $2`.o
+else
+ exit 1
+fi