#define small(x) ((x)>=1 && (x)<=8) /******************************************************************************/ /* */ /* Group 1 : Load instructions */ /* */ /******************************************************************************/ /* a6 : local base. * sp : stack pointer */ C_loc ==> "pea ($1)". C_lol ==> "move.l ($1, a6), -(sp)". C_loe.. ==> "move.l ($1+$2), -(sp)". C_lil ==> "move.l ([$1,a6]), -(sp)". C_lof ==> "move.l (sp)+, a0"; "move.l ($1,a0),-(sp)". C_lal ==> "pea ($1,a6)". C_lae.. ==> "pea ($1+$2)". C_lxl $1 == 0 ==> "move.l a6, -(sp)". $1 == 1 ==> "move.l (8, a6), -(sp)". default ==> "move.l (8, a6), a0"; "move.l #$1-2, d0"; "1: move.l (8,a0), a0"; "dbf d0, 1b"; "move.l a0, -(sp)". C_lxa $1 == 0 ==> "pea (8,a6)". $1 == 1 ==> "pea ([8,a6],8)". default ==> "move.l (8, a6), a0"; "move.l #$1-2, d0"; "1: move.l (8,a0), a0"; "dbf d0, 1b"; "pea (8,a0)". C_loi $1 == 1 ==> "move.l (sp)+, a0"; "clr.l -(sp)"; "move.b (a0), (3,sp)". $1 == 2 ==> "move.l (sp)+, a0"; "clr.l -(sp)"; "move.w (a0), (2,sp)". $1 == 4 ==> "move.l (sp)+, a0"; "move.l (a0),-(sp)". $1 == 8 ==> "move.l (sp)+, a0"; "move.l (4,a0),-(sp)"; "move.l (a0), -(sp)". $1 % 4 == 0 ==> "move.l (sp)+, a0"; "move.l #$1/4-1, d0"; "add.l #$1, a0"; "1:"; "move.l -(a0), -(sp)"; "dbf d0, 1b". default ==> arg_error( "loi", $1). C_los $1 == 4 ==> "jsr (.los)". default ==> arg_error( "los", $1). C_ldl ==> "move.l ($1+4, a6), -(sp)"; "move.l ($1, a6), -(sp)". C_lde.. ==> "move.l ($1+$2+4), -(sp)"; "move.l ($1+$2), -(sp)". C_ldf ==> "move.l (sp)+, a0"; "move.l ($1+4,a0),-(sp)"; "move.l ($1,a0), -(sp)". C_lpi ==> "pea ($1)". /******************************************************************************/ /* */ /* Group 2 : Store instructions */ /* */ /******************************************************************************/ C_stl ==> "move.l (sp)+, ($1,a6)". C_ste.. ==> "move.l (sp)+, ($1+$2)". C_sil ==> "move.l (sp)+, ([$1,a6])". C_stf ==> "move.l (sp)+, a0"; "move.l (sp)+, ($1,a0)". C_sti $1 == 1 ==> "move.l (sp)+, a0"; "move.l (sp)+, d0"; "move.b d0, (a0)". $1 == 2 ==> "move.l (sp)+, a0"; "move.l (sp)+, d0"; "move.w d0, (a0)". $1 == 4 ==> "move.l (sp)+, a0"; "move.l (sp)+, (a0)". $1 % 4 == 0 ==> "move.l (sp)+, a0"; "move.l #$1/4-1, d0"; "1:move.l (sp)+, (a0)+"; "dbf d0, 1b". default ==> arg_error( "sti", (arith) $1). C_sts ==> "jsr (.sts)". C_sdl ==> "move.l (sp)+, ($1,a6)"; "move.l (sp)+, ($1+4,a6)". C_sde.. ==> "move.l (sp)+, ($1+$2)"; "move.l (sp)+, ($1+$2+4)". C_sdf ==> "move.l (sp)+, a0"; "move.l (sp)+, ($1,a0)"; "move.l (sp)+, ($1+4,a0)". /******************************************************************************/ /* */ /* Group 3 : Integer arithmetic */ /* */ /******************************************************************************/ C_adi $1 == 4 ==> "move.l (sp)+, d0"; "add.l d0, (sp)". default ==> arg_error( "adi", $1). C_sbi $1 == 4 ==> "move.l (sp)+, d0"; "sub.l d0, (sp)". default ==> arg_error( "sbi", $1). C_mli $1 == 4 ==> "move.l (sp)+, d0"; "muls.l (sp)+, d0"; "move.l d0,-(sp)". default ==> arg_error( "mli", $1). C_dvi $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp)+, d1"; "divs.l d0, d1"; "move.l d1,-(sp)". default ==> arg_error( "dvi", $1). C_rmi $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp), d1"; "move.l d0,(sp)"; "divsl.l (sp)+, d0:d1"; "move.l d0,-(sp)". default ==> arg_error( "rmi", $1). C_ngi $1 == 4 ==> "neg.l (sp)". default ==> arg_error( "ngi", $1). C_sli $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp)+, d1"; "asl.l d0, d1"; "move.l d1,-(sp)". default ==> arg_error( "sli", $1). C_sri $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp)+, d1"; "asr.l d0, d1"; "move.l d1,-(sp)". default ==> arg_error( "sri", $1). /******************************************************************************/ /* */ /* Group 4 : Unsigned arithmetic */ /* */ /******************************************************************************/ C_adu ==> C_adi( w). C_sbu ==> C_sbi( w). C_mlu $1 == 4 ==> "move.l (sp)+, d0"; "mulu.l (sp)+, d0"; "move.l d0, -(sp)". default ==> arg_error( "mlu", $1). C_dvu $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp)+, d1"; "divu.l d0, d1"; "move.l d1, -(sp)". default ==> arg_error( "dvu", $1). C_rmu $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp), d1"; "move.l d0, (sp)"; "divul.l (sp)+, d0:d1"; "move.l d0, -(sp)". default ==> arg_error( "rmu", $1). C_slu ==> C_sli( w). C_sru $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp)+, d1"; "lsr.l d0, d1"; "move.l d1, -(sp)". default ==> arg_error( "sru", $1). /******************************************************************************/ /* */ /* Group 5 : Floating point arithmetic */ /* */ /******************************************************************************/ C_adf $1 == 4 ==> "jsr (adf4)". $1 == 8 ==> "jsr (adf8)". default ==> arg_error( "adf", $1). C_sbf $1 == 4 ==> "jsr (sbf4)". $1 == 8 ==> "jsr (sbf8)". default ==> arg_error( "sbf", $1). C_mlf $1 == 4 ==> "jsr (mlf4)". $1 == 8 ==> "jsr (mlf8)". default ==> arg_error( "mlf", $1). C_dvf $1 == 4 ==> "jsr (dvf4)". $1 == 8 ==> "jsr (dvf8)". default ==> arg_error( "dvf", $1). C_ngf ==> "move.l #7,d0"; "bchg d0,(sp)". C_fif $1 == 4 ==> "jsr (fif4)". $1 == 8 ==> "jsr (fif8)". default ==> arg_error( "fif", $1). C_fef $1 == 4 ==> "jsr (fef4)". $1 == 8 ==> "jsr (fef8)". default ==> arg_error( "fef", $1). /******************************************************************************/ /* */ /* Group 6 : Pointer arithmetic */ /* */ /******************************************************************************/ C_adp $1 == 0 ==> . default ==> "add.l #$1, (sp)". C_ads $1 == 4 ==> "move.l (sp)+, d0"; "add.l d0, (sp)". default ==> arg_error( "ads", $1). C_sbs $1 == 4 ==> "move.l (sp)+, d0"; "sub.l d0, (sp)". default ==> arg_error( "sbs", $1). /******************************************************************************/ /* */ /* Group 7 : Increment/decrement/zero */ /* */ /******************************************************************************/ C_inc ==> "add.l #1, (sp)". C_inl ==> "add.l #1, ($1, a6)". C_ine.. ==> "add.l #1, ($1+$2)". C_dec ==> "sub.l #1, (sp)". C_del ==> "sub.l #1, ($1, a6)". C_dee.. ==> "sub.l #1, ($1+$2)". C_zrl ==> "clr.l ($1, a6)". C_zre.. ==> "clr.l ($1+$2)". C_zrf ==> C_zer( $1). C_zer $1 == 4 ==> "clr.l -(sp)". $1 == 8 ==> "clr.l -(sp)"; "clr.l -(sp)". default ==> "move.l #$1/4-1, d0"; "1:"; "clr.l -(sp)"; "dbf d0, 1b". /******************************************************************************/ /* */ /* Group 8 : Convert */ /* */ /******************************************************************************/ /* cii, ciu, cuu, cui are assumed to be called with legal arguments only */ C_cii ==> " move.l (sp)+, d0"; " move.l (sp)+, d1"; " cmp.l d1, d0"; " ble 4f"; " move.l (sp), d0"; " cmp.l #1, d1"; " bne 2f"; " ext.w d0"; "2: ext.l d0"; " move.l d0,(sp)"; "4:". C_cuu ==> "lea (8,sp),sp". C_ciu ==> C_cuu(). C_cui ==> C_cuu(). C_cfi ==> "jsr (cfi)". C_cfu ==> "jsr (cfu)". C_cff ==> "jsr (cff)". C_cif ==> "jsr (cif)". C_cuf ==> "jsr (cuf)". /******************************************************************************/ /* */ /* Group 9 : Logical */ /* */ /******************************************************************************/ C_and $1 == 4 ==> "move.l (sp)+, d0"; "and.l d0, (sp)". default ==> "move.l #$1/4-1, d0"; "lea ($1, sp), a0"; "1:"; "move.l (sp)+, d1"; "and.l d1, (a0)+"; "dbf d0, 1b". C_ior $1 == 4 ==> "move.l (sp)+, d0"; "or.l d0, (sp)". default ==> "move.l #$1/4-1, d0"; "lea ($1, sp), a0"; "1:"; "move.l (sp)+, d1"; "or.l d1, (a0)+"; "dbf d0, 1b". C_xor $1 == 4 ==> "move.l (sp)+, d0"; "eor.l d0, (sp)". default ==> "move.l #$1/4-1, d0"; "lea ($1, sp), a0"; "1:"; "move.l (sp)+, d1"; "eor.l d1, (a0)+"; "dbf d0, 1b". C_com $1 == 4 ==> "not.l (sp)". $1 == 8 ==> "not.l (sp)"; "not.l (4, sp)". default ==> "move.l #$1/4-1, d0"; "move.l sp, a0"; "1:"; "not.l (a0)+"; "dbf d0, 1b". C_rol $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp)+, d1"; "rol.l d0, d1"; "move.l d1, -(sp)". default ==> arg_error( "rol", $1). C_ror $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp)+, d1"; "ror.l d0, d1"; "move.l d1, -(sp)". default ==> arg_error( "ror", $1). /******************************************************************************/ /* */ /* Group 10 : Sets */ /* */ /******************************************************************************/ C_inn $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp)+, d1"; "btst d0, d1"; "sne d1"; "and.l #1, d1"; "move.l d1, -(sp)". default ==> "move.l (sp)+, d0"; "move.l #$1, d1"; "jsr (.inn)"; "move.l d0, -(sp)". C_inn_narg ==> "move.l (sp)+, d1"; "move.l (sp)+, d0"; "jsr (.inn)"; "move.l d0, -(sp)". C_set $1 == 4 ==> "move.l (sp)+, d0"; "clr.l d1"; "bset d0, d1"; "move.l d1, -(sp)". default ==> "move.l (sp)+, d0"; "move.l #$1, d1"; "jsr (.set)". C_set_narg ==> "move.l (sp)+, d1"; "move.l (sp)+, d0"; "jsr (.set)". /******************************************************************************/ /* */ /* Group 11 : Array */ /* */ /******************************************************************************/ C_lar ==> "move.l #$1, d0"; "jsr (.lar)". C_lar_narg ==> "move.l (sp)+, d0"; "jsr (.lar)". C_sar ==> "move.l #$1, d0"; "jsr (.sar)". C_sar_narg ==> "move.l (sp)+, d0"; "jsr (.sar)". C_aar ==> "move.l #$1, d0"; "jsr (.aar)"; "move.l a0, -(sp)". C_aar_narg ==> "move.l (sp)+, d0"; "jsr (.aar)"; "move.l a0, -(sp)". /******************************************************************************/ /* */ /* Group 12 : Compare */ /* */ /******************************************************************************/ C_cmi $1 == 4 ==> "clr.l d0"; "cmp.l (sp)+, (sp)+"; "beq 2f"; "blt 1f"; "add.l #1, d0"; "bra 2f"; "1 : sub.l #1, d0"; "2 : move.l d0, -(sp)". default ==> "move.l #$1, d0"; "jsr (.cmi)"; "move.l d0, -(sp)". C_cmu $1 == 4 ==> "clr.l d0"; "cmp.l (sp)+, (sp)+"; "beq 2f"; "bcs 1f"; "add.l #1, d0"; "bra 2f"; "1 : sub.l #1, d0"; "2 : move.l d0, -(sp)". default ==> "move.l #$1, d0"; "jsr (.cmu)"; "move.l d0, -(sp)". C_cmu_narg ==> "move.l (sp)+, d0"; "jsr (.cmu)"; "move.l d0, -(sp)". C_cms ==> "move.l #$1, d0"; "jsr (.cms)"; "move.l d0, -(sp)". C_cms_narg ==> "move.l (sp)+, d0"; "jsr (.cms)"; "move.l d0, -(sp)". C_cmp ==> C_cmu( (arith)4). C_tlt ==> "move.l (sp), d0"; "move.l #1, (sp)"; "tst.l d0"; "blt 1f"; "clr.l (sp)"; "1:". C_tle ==> "move.l (sp), d0"; "move.l #1, (sp)"; "tst.l d0"; "ble 1f"; "clr.l (sp)"; "1:". C_teq ==> "move.l (sp), d0"; "move.l #1, (sp)"; "tst.l d0"; "beq 1f"; "clr.l (sp)"; "1:". C_tne ==> "move.l (sp), d0"; "move.l #1, (sp)"; "tst.l d0"; "bne 1f"; "clr.l (sp)"; "1:". C_tge ==> "move.l (sp), d0"; "move.l #1, (sp)"; "tst.l d0"; "bge 1f"; "clr.l (sp)"; "1:". C_tgt ==> "move.l (sp), d0"; "move.l #1, (sp)"; "tst.l d0"; "bgt 1f"; "clr.l (sp)"; "1:". C_cmf $1 == 4 ==> "jsr (cmf4)". $1 == 8 ==> "jsr (cmf8)". default ==> arg_error("cmf", $1). /******************************************************************************/ /* */ /* Group 13 : Branch */ /* */ /******************************************************************************/ C_bra ==> "bra $1". C_blt ==> "move.l (sp)+, d0"; "cmp.l (sp)+, d0"; "bgt $1". C_ble ==> "move.l (sp)+, d0"; "cmp.l (sp)+, d0"; "bge $1". C_beq ==> "move.l (sp)+, d0"; "cmp.l (sp)+, d0"; "beq $1". C_bne ==> "move.l (sp)+, d0"; "cmp.l (sp)+, d0"; "bne $1". C_bge ==> "move.l (sp)+, d0"; "cmp.l (sp)+, d0"; "ble $1". C_bgt ==> "move.l (sp)+, d0"; "cmp.l (sp)+, d0"; "blt $1". C_zlt ==> "tst.l (sp)+"; "blt $1". C_zle ==> "tst.l (sp)+"; "ble $1". C_zeq ==> "tst.l (sp)+"; "beq $1". C_zne ==> "tst.l (sp)+"; "bne $1". C_zge ==> "tst.l (sp)+"; "bge $1". C_zgt ==> "tst.l (sp)+"; "bgt $1". /******************************************************************************/ /* */ /* Group 14 : Procedure call instructions */ /* */ /******************************************************************************/ C_cai ==> "move.l (sp)+, a0"; "jsr (a0)". C_cal ==> "jsr ($1)". C_lfr $1 == 4 ==> "move.l d0, -(sp)". $1 == 8 ==> "move.l d1, -(sp)"; "move.l d0, -(sp)". default ==> arg_error( "lfr", $1). C_ret $1 == 0 ==> "unlk a6"; "rts". $1 == 4 ==> "move.l (sp)+, d0"; "unlk a6"; "rts". $1 == 8 ==> "move.l (sp)+, d0"; "move.l (sp)+, d1"; "unlk a6"; "rts". default ==> arg_error( "ret", $1). /******************************************************************************/ /* */ /* Group 15 : Miscellaneous instructions */ /* */ /******************************************************************************/ C_asp small( $1) ==> "add.l #$1, sp". default ==> "lea ($1, sp), sp". C_ass $1 == 4 ==> "add.l (sp)+, sp". default ==> arg_error( "ass", $1). C_blm $1 == 4 ==> "move.l (sp)+, a0"; "move.l (sp)+, a1"; "move.l (a1), (a0)". $1 == 8 ==> "move.l (sp)+, a0"; "move.l (sp)+, a1"; "move.l (a1), (a0)"; "move.l (4, a1), (4, a0)". default ==> "move.l (sp)+, a0"; "move.l (sp)+, a1"; "move.l #$1/4-1, d0"; "1:"; "move.l (a1)+, (a0)+"; "dbf d0, 1b". C_bls $1 == 4 ==> "move.l (sp)+, d0"; "move.l (sp)+, a0"; "move.l (sp)+, a1"; "asr.l #2, d1"; "beq 2f"; "1:"; "move.l (a1)+, (a0)+"; "dbf d0, 1b"; "2:". default ==> arg_error( "bls", $1). C_csa $1 == 4 ==> "jmp (.csa)". default ==> arg_error( "csa", $1). C_csb $1 == 4 ==> "jmp (.csb)". default ==> arg_error( "csb", $1). C_dch ==> C_loi( (arith)4). C_dup $1 == 4 ==> "move.l (sp), -(sp)". $1 == 8 ==> "move.l (4, sp), -(sp)"; "move.l (4, sp), -(sp)". default ==> "move.l #$1/4-1, d0"; "1:"; "move.l ($1-4, sp), -(sp)"; "dbf d0, 1b". C_dus $1 == 4 ==> "move.l (sp)+, d0"; "lea (0, sp, d0.l*1), a0"; "asr.l #2, d0"; "beq 2f"; "sub.l #1, d0"; "1:"; "move.l -(a0), -(sp)"; "dbf d0, 1b"; "2:". default ==> arg_error( "dus", $1). C_exg ==> "move.l #$1, d0"; "jsr (.exg)". C_fil.. ==> "move.l #$1+$2, (.filn)". C_gto.. ==> "move.l #$1+$2, a0"; "move.l (8, a0), a6"; "move.l (4, a0), sp"; "jmp ([0,a0], 0)". C_lim ==> "move.l (.trpim), -(sp)". C_lin ==> "move.l #$1, (.lino)". C_lni ==> "add.l #1, (.lino)". C_lor $1 == 0 ==> "move.l a6, -(sp)". $1 == 1 ==> "move.l sp, -(sp)". $1 == 2 ==> "move.l (.reghp), -(sp)". default ==> arg_error( "lor", $1). C_lpb ==> C_adp( (arith)8). C_mon ==> "jsr (.mon)". C_nop ==> "jsr (.nop)". C_rck $1 == 4 ==> "move.l (sp)+, a0"; "move.l (sp)+, d0"; "cmp2.l (a0), d0"; "bcc 1f"; "pea (1)"; /* push constant 1 == ERANGE */ "jsr (.trp)"; "1: move.l d0, -(sp)". default ==> arg_error( "rck", $1). C_rtt ==> C_ret( (arith)0). C_sig ==> "move.l (.trppc), a0"; "move.l (sp)+, (.trppc)"; "move.l a0, -(sp)". C_sim ==> "move.l (sp)+, (.trpim)". C_str $1 == 0 ==> "move.l (sp)+, a6". $1 == 1 ==> "move.l (sp)+, sp". $1 == 2 ==> "jsr (.strhp)". default ==> arg_error( "str", $1). C_trp ==> "jsr (.trp)". /*****************************************************************************/ ..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", $2). ..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( "icon", $2). ..fcon ==> con_float($1, $2). /*****************************************************************************/ C_prolog ==> . C_jump ==> "bra $1". C_locals ==> "link a6, #-$1".