/******************************************************************************/ /* */ /* Group 1 : Load instructions */ /* */ /******************************************************************************/ C_loc ==> "pushl ~$1". C_ldc ==> "movq ~$1, -(sp)". C_lol $1 < 0 ==> "pushl $1(fp)". default ==> "pushl $1+4(ap)". C_loe.. ==> "pushl $1 + $2". C_lil $1 < 0 ==> "movl $1(fp), r0"; "pushl (r0)". default ==> "movl $1+4(ap), r0"; "pushl (r0)". C_lof ==> "movl (sp)+, r0"; "pushl $1(r0)". C_lal $1 < 0 ==> "pushal $1(fp)". default ==> "pushal $1+4(ap)". C_lae.. ==> "pushal $1 + $2". C_lxl $1 == 0 ==> "pushl fp". $1 == 1 ==> "pushl 4(ap)". default ==> "movl ~$1, r0"; "jsb .lxl"; "pushl r0". C_lxa $1 == 0 ==> "addl3 ~4, ap, -(sp)". $1 == 1 ==> "movl 4(ap), r0"; "jsb .lpb"; "pushl r0". default ==> "movl ~$1, r0"; "jsb .lxa"; "pushl r0". C_loi $1 == 1 ==> "movl (sp)+, r0"; "clrl -(sp)"; "movb (r0), (sp)". $1 == 2 ==> "movl (sp)+, r0"; "clrl -(sp)"; "movw (r0), (sp)". $1 == 4 ==> "movl (sp)+, r0"; "pushl (r0)". $1 == 8 ==> "movl (sp)+, r0"; "movq (r0), -(sp)". $1 % 4 == 0 ==> "movl (sp)+, r0"; "movl ~$1/4, r1"; "addl2 ~$1, r0"; "2:"; "pushl -(r0)"; "sobgtr r1, 2b". default ==> arg_error( "loi", $1). C_los ==> "movl ~$1, r0"; "jsb .los". C_los_narg ==> "movl (sp)+, r0"; "jsb .los". C_ldl $1 < 0 ==> "movq $1(fp), -(sp)". default ==> "movq $1+4(ap), -(sp)". C_lde.. ==> "movq $1 + $2, -(sp)". C_ldf ==> "movl (sp)+, r0"; "movq $1(r0), -(sp)". C_lpi ==> "pushal $1". /******************************************************************************/ /* */ /* Group 2 : Store instructions */ /* */ /******************************************************************************/ C_stl $1 < 0 ==> "movl (sp)+, $1(fp)". default ==> "movl (sp)+, $1+4(ap)". C_ste.. ==> "movl (sp)+, $1 + $2". C_sil $1 < 0 ==> "movl $1(fp) , r0"; "movl (sp)+, (r0)". default ==> "movl $1+4(ap), r0"; "movl (sp)+, (r0)". C_stf ==> "movl (sp)+, r0"; "movl (sp)+, $1(r0)". C_sti $1 == 1 ==> "movl (sp)+, r0"; "movl (sp)+, r1"; "movb r1, (r0)". $1 == 2 ==> "movl (sp)+, r0"; "movl (sp)+, r1"; "movw r1, (r0)". $1 == 4 ==> "movl (sp)+, r0"; "movl (sp)+, (r0)". $1 == 8 ==> "movl (sp)+, r0"; "movq (sp)+, (r0)". $1 % 4 == 0 ==> "movl (sp)+, r0"; "movl ~$1/4, r1"; "2:"; "movl (sp)+, (r0)+"; "sobgtr r1, 2b". default ==> arg_error( "sti", (arith) $1). C_sts ==> "movl ~$1, r0"; "jsb .sts". C_sts_narg ==> "movl (sp)+, r0"; "jsb .sts". C_sdl $1 < 0 ==> "movq (sp)+, $1(fp)". default ==> "movq (sp)+, $1+4(ap)". C_sde.. ==> "movq (sp)+, $1 + $2". C_sdf ==> "movl (sp)+, r0"; "movq (sp)+, $1(r0)". /******************************************************************************/ /* */ /* Group 3 : Integer arithmetic */ /* */ /******************************************************************************/ C_adi $1 == 4 ==> "addl2 (sp)+, (sp)". default ==> arg_error( "adi", $1). C_sbi $1 == 4 ==> "subl2 (sp)+, (sp)". default ==> arg_error( "sbi", $1). C_mli $1 == 4 ==> "mull2 (sp)+, (sp)". default ==> arg_error( "mli", $1). C_dvi $1 == 4 ==> "divl2 (sp)+, (sp)". default ==> arg_error( "dvi", $1). C_rmi $1 == 4 ==> "divl3 (sp), 4(sp), r0"; "mull2 (sp)+, r0"; "subl2 r0, (sp)". default ==> arg_error( "rmi", $1). C_ngi $1 == 4 ==> "mnegl (sp), (sp)". default ==> arg_error( "ngi", $1). C_sli $1 == 4 ==> "clrl r0"; "cvtlb (sp)+, r0"; "ashl r0, (sp), (sp)". default ==> arg_error( "sli", $1). C_sri $1 == 4 ==> "mnegl (sp)+, r0"; "clrl r1"; "cvtlb r0, r1"; "ashl r1, (sp), (sp)". default ==> arg_error( "sri", $1). /******************************************************************************/ /* */ /* Group 4 : Unsigned arithmetic */ /* */ /******************************************************************************/ C_adu ==> C_adi( w). C_sbu ==> C_sbi( w). C_mlu ==> C_mli( w). C_dvu $1 == 4 ==> "jsb .dvu4"; "pushl r0". default ==> arg_error( "dvu", $1). C_rmu $1 == 4 ==> "jsb .rmu4"; "pushl r0". default ==> arg_error( "rmu", $1). C_slu ==> C_sli( w). C_sru ==> "movl ~$1, r0"; "jsb .sru". /******************************************************************************/ /* */ /* Group 5 : Floating point arithmetic */ /* */ /******************************************************************************/ C_adf $1 == 4 ==> "addf2 (sp)+, (sp)". $1 == 8 ==> "addd2 (sp)+, (sp)". default ==> arg_error( "adf", $1). C_sbf $1 == 4 ==> "subf2 (sp)+, (sp)". $1 == 8 ==> "subd2 (sp)+, (sp)". default ==> arg_error( "sbf", $1). C_mlf $1 == 4 ==> "mulf2 (sp)+, (sp)". $1 == 8 ==> "muld2 (sp)+, (sp)". default ==> arg_error( "mlf", $1). C_dvf $1 == 4 ==> "divf2 (sp)+, (sp)". $1 == 8 ==> "divd2 (sp)+, (sp)". default ==> arg_error( "dvf", $1). C_ngf $1 == 4 ==> "mnegf (sp), (sp)". $1 == 8 ==> "mnegd (sp), (sp)". default ==> arg_error( "ngf", $1). C_fif ==> "movl ~$1,r0"; "jsb .fif". C_fef ==> "movl ~$1,r0"; "jsb .fef". /******************************************************************************/ /* */ /* Group 6 : Pointer arithmetic */ /* */ /******************************************************************************/ C_adp ==> "addl2 ~$1, (sp)". C_ads $1 == 4 ==> "addl2 (sp)+, (sp)". default ==> arg_error( "ads", $1). C_sbs $1 == 4 ==> "subl2 (sp)+, (sp)". default ==> arg_error( "sbs", $1). /******************************************************************************/ /* */ /* Group 7 : Increment/decrement/zero */ /* */ /******************************************************************************/ C_inc ==> "incl (sp)". C_inl $1 < 0 ==> "incl $1(fp)". default ==> "incl $1+4(ap)". C_ine.. ==> "incl $1 + $2". C_dec ==> "decl (sp)". C_del $1 < 0 ==> "decl $1(fp)". default ==> "decl $1+4(ap)". C_dee.. ==> "decl $1 + $2". C_zrl $1 < 0 ==> "clrl $1(fp)". default ==> "clrl $1+4(ap)". C_zre.. ==> "clrl $1 + $2". C_zrf $1 == 4 ==> "clrl -(sp)". $1 == 8 ==> "clrq -(sp)". default ==> arg_error( "zrf", $1). C_zer $1 == 4 ==> "clrl -(sp)". $1 == 8 ==> "clrq -(sp)". default ==> "movl ~$1/4, r0"; "1:"; "clrl -(sp)"; "sobgtr r0, 1b". /******************************************************************************/ /* */ /* Group 8 : Convert */ /* */ /******************************************************************************/ C_cii ==> "jsb .cii". C_cui ==> C_cuu(). C_cfi ==> "jsb .cfi". C_cif ==> "jsb .cif". C_cuf ==> "jsb .cuf". C_cff ==> "jsb .cff". C_ciu ==> C_cuu(). C_cuu ==> "addl2 ~8,sp". C_cfu ==> "jsb .cfu". /******************************************************************************/ /* */ /* Group 9 : Logical */ /* */ /******************************************************************************/ C_and $1 == 4 ==> "mcoml (sp), (sp)"; "bicl2 (sp)+, (sp)". default ==> "movl ~$1/4, r0"; "addl3 ~$1, sp, r1"; "1:"; "mcoml (sp), (sp)"; "bicl2 (sp)+, (r1)+"; "sobgtr r0, 1b". C_ior $1 == 4 ==> "bisl2 (sp)+, (sp)". default ==> "movl ~$1/4, r0"; "addl3 ~$1, sp, r1"; "1:"; "bisl2 (sp)+, (r1)+"; "sobgtr r0, 1b". C_xor $1 == 4 ==> "xorl2 (sp)+, (sp)". default ==> "movl ~$1/4, r0"; "addl3 ~$1, sp, r1"; "1:"; "xorl2 (sp)+, (r1)+"; "sobgtr r0, 1b". C_com $1 == 4 ==> "mcoml (sp), (sp)". default ==> "movl ~$1, r0"; "jsb .com". C_rol $1 == 4 ==> "clrl r0"; "cvtlb (sp)+, r0"; "rotl r0, (sp), (sp)". default ==> arg_error( "rol", $1). C_ror $1 == 4 ==> "mnegl (sp)+, r0"; "clrl r1"; "cvtlb r0, r1"; "rotl r1, (sp), (sp)". default ==> arg_error( "rol", $1). /******************************************************************************/ /* */ /* Group 10 : Sets */ /* */ /******************************************************************************/ C_inn $1 == 4 ==> "mnegl (sp)+, r0"; "clrl r1"; "cvtlb r0, r1"; "ashl r1, (sp), (sp)"; "bicl2 ~~1, (sp)". default ==> "movl ~$1, r0"; "jsb .inn"; "pushl r1". C_inn_narg ==> "movl (sp)+, r0"; "jsb .inn"; "pushl r1". C_set $1 == 4 ==> "clrl r0"; "cvtlb (sp)+, r0"; "ashl r0, ~1, -(sp)". default ==> "movl ~$1, r0"; "jsb .setx". C_set_narg ==> "movl (sp)+, r0"; "jsb .setx". /******************************************************************************/ /* */ /* Group 11 : Array */ /* */ /******************************************************************************/ C_lar $1 == 4 ==> "jsb .lar4". default ==> "movl ~$1, r0"; "jsb .lar". C_lar_narg ==> "movl (sp)+, r0"; "jsb .lar". C_sar $1 == 4 ==> "jsb .sar4". default ==> "movl ~$1, r0"; "jsb .sar". C_sar_narg ==> "movl (sp)+, r0"; "jsb .sar". C_aar $1 == 4 ==> "jsb .aar4"; "pushl r0". default ==> "movl ~$1, r0"; "jsb .aar"; "pushl r0". C_aar_narg ==> "movl (sp)+, r0"; "jsb .aar"; "pushl r0". /******************************************************************************/ /* */ /* Group 12 : Compare */ /* */ /******************************************************************************/ C_cmi $1 == 4 ==> /* bug : "subl2 (sp)+, (sp)". */ "clrl r0"; "cmpl (sp)+, (sp)+"; "beql 2f"; "bgtr 1f"; "incl r0"; "br 2f"; "1 : decl r0"; "2 : pushl r0". default ==> arg_error( "cmi", $1). C_cmu $1 == 4 ==> /* bug : "subl2 (sp)+, (sp)". */ "clrl r0"; "cmpl (sp)+, (sp)+"; "beql 2f"; "bgtru 1f"; "incl r0"; "br 2f"; "1 : decl r0"; "2 : pushl r0". default ==> "movl ~$1, r0"; "jsb .cmu"; "pushl r0". C_cmu_narg ==> "movl (sp)+, r0"; "jsb .cmu"; "pushl r0". C_cms ==> "movl ~$1, r0"; "jsb .cms"; "pushl r0". C_cms_narg ==> "movl (sp)+, r0"; "jsb .cms"; "pushl r0". C_cmp ==> /* bug : "subl2 (sp)+, (sp)". */ "clrl r0"; "cmpl (sp)+, (sp)+"; "beql 2f"; "bgtru 1f"; "incl r0"; "br 2f"; "1 : decl r0"; "2 : pushl r0". C_cmf $1==4 ==> "clrl r0"; "cmpf (sp)+, (sp)+"; "beql 2f"; "bgtr 1f"; "incl r0"; "br 2f"; "1 : decl r0"; "2 : pushl r0". $1==8 ==> "clrl r0"; "cmpd (sp)+, (sp)+"; "beql 2f"; "bgtr 1f"; "incl r0"; "br 2f"; "1 : decl r0"; "2 : pushl r0". default ==> arg_error("cmf", $1). C_tlt ==> "movl (sp)+, r0"; "pushl ~1"; "tstl r0"; "blss 1f"; "clrl (sp)"; "1:". C_tle ==> "movl (sp)+, r0"; "pushl ~1"; "tstl r0"; "bleq 1f"; "clrl (sp)"; "1:". C_teq ==> "movl (sp)+, r0"; "pushl ~1"; "tstl r0"; "beql 1f"; "clrl (sp)"; "1:". C_tne ==> "movl (sp)+, r0"; "pushl ~1"; "tstl r0"; "bneq 1f"; "clrl (sp)"; "1:". C_tge ==> "movl (sp)+, r0"; "pushl ~1"; "tstl r0"; "bgeq 1f"; "clrl (sp)"; "1:". C_tgt ==> "movl (sp)+, r0"; "pushl ~1"; "tstl r0"; "bgtr 1f"; "clrl (sp)"; "1:". /******************************************************************************/ /* */ /* Group 13 : Branch */ /* */ /******************************************************************************/ C_bra ==> "jmp $1". C_blt ==> "movl (sp)+, r0"; "cmpl (sp)+, r0"; "jlss $1". C_ble ==> "movl (sp)+, r0"; "cmpl (sp)+, r0"; "jleq $1". C_beq ==> "movl (sp)+, r0"; "cmpl (sp)+, r0"; "jeql $1". C_bne ==> "movl (sp)+, r0"; "cmpl (sp)+, r0"; "jneq $1". C_bge ==> "movl (sp)+, r0"; "cmpl (sp)+, r0"; "jgeq $1". C_bgt ==> "movl (sp)+, r0"; "cmpl (sp)+, r0"; "jgtr $1". C_zlt ==> "tstl (sp)+"; "jlss $1". C_zle ==> "tstl (sp)+"; "jleq $1". C_zeq ==> "tstl (sp)+"; "jeql $1". C_zne ==> "tstl (sp)+"; "jneq $1". C_zge ==> "tstl (sp)+"; "jgeq $1". C_zgt ==> "tstl (sp)+"; "jgtr $1". /******************************************************************************/ /* */ /* Group 14 : Procedure call instructions */ /* */ /******************************************************************************/ C_cai ==> "movl (sp)+, r0"; "calls ~0, (r0)". C_cal ==> "calls ~0, $1". C_lfr $1 == 4 ==> "pushl r0". $1 == 8 ==> "movq r0, -(sp)". default ==> arg_error( "lfr", $1). C_ret $1 == 0 ==> "ret". $1 == 4 ==> "movl (sp)+, r0"; "ret". $1 == 8 ==> "movq (sp)+, r0"; "ret". default ==> arg_error( "ret", $1). /******************************************************************************/ /* */ /* Group 15 : Miscellaneous instructions */ /* */ /******************************************************************************/ C_asp ==> "addl2 ~$1, sp". C_ass $1 == 4 ==> "addl2 (sp)+, sp". default ==> "movl ~$1, r2"; "jsb .ass". C_ass_narg ==> "movl (sp)+, r2"; "jsb .ass". C_blm $1 == 4 ==> "movl (sp)+, r0"; "movl (sp)+, r1"; "movl (r1), (r0)". $1 == 8 ==> "movl (sp)+, r0"; "movl (sp)+, r1"; "movq (r1), (r0)". default ==> "movl (sp)+, r0"; "movl (sp)+, r1"; "movl ~$1/4, r2"; "1:"; "movl (r1)+, (r0)+"; "sobgtr r2, 1b". C_bls $1 == 4 ==> "movl ~4, r0"; "jsb .bls". default ==> arg_error( "bls", $1). C_csa $1 == 4 ==> "jmp .csa4". default ==> "movl ~$1, r0"; "jmp .csa". C_csb $1 == 4 ==> "jmp .csb4". default ==> "movl ~$1, r0"; "jmp .csb". C_dch ==> "movl (sp)+, r0"; "pushl (r0)". C_dup $1 == 4 ==> "pushl (sp)". $1 == 8 ==> "movq (sp), -(sp)". default ==> "movl ~$1/4, r0"; "addl3 ~$1, sp, r1"; "1:"; "pushl -(r1)"; "sobgtr r0, 1b". C_dus $1 == 4 ==> "movl (sp)+, r0"; "addl3 r0, sp, r1"; "ashl ~-2, r0, r0"; "1:"; "pushl -(r1)"; "sobgtr r0, 1b". default ==> arg_error( "dus", $1). C_exg ==> "movl ~$1, r0"; "jsb .exg". C_fil.. ==> "moval $1 + $2, hol0 + 4". C_gto.. ==> "pushal $1+$2"; "jmp .gto". C_lim ==> "pushl .trpim". C_lin ==> "movl ~$1, hol0". C_lni ==> "incl hol0". C_lor $1 == 0 ==> "pushl fp". $1 == 1 ==> "pushl sp". $1 == 2 ==> "pushl .reghp". default ==> arg_error( "lor", $1). C_lpb ==> "movl (sp)+, r0"; "jsb .lpb"; "pushl r0". C_mon ==> "jsb .mon". C_nop ==> . C_rck $1 == 4 ==> "jsb .rck4". default ==> "movl ~$1, r0"; "jsb .rck". C_rck_narg ==> "movl (sp)+, r0"; "jsb .rck". C_rtt ==> "ret". C_sig ==> "jsb .sig". C_sim ==> "jsb .sim". C_str $1 == 0 ==> "movl (sp)+, fp". $1 == 1 ==> "movl (sp)+, sp". $1 == 2 ==> "jsb .strhp". default ==> arg_error( "str", $1). C_trp ==> "jsb .trp". /*****************************************************************************/ ..icon $2 == 1 ==> gen1( (char) atoi( $1)). $2 == 2 ==> gen2( (short) atoi( $1)). $2 == 4 ==> gen4( (long) atol( $1)). default ==> arg_error( "icon", $2). ..ucon $2 == 1 ==> gen1( (char) atoi( $1)). $2 == 2 ==> gen2( (short) atoi( $1)). $2 == 4 ==> gen4( (long) atol( $1)). default ==> arg_error( "icon", $2). ..fcon ==> con_float($1, $2). /*****************************************************************************/ prolog ==> text2( 0x0). jump ==> "jmp $1". locals $1 == 0 ==> . $1 == 4 ==> "clrq -(sp)". $1 == 8 ==> "clrq -(sp)". default ==> "subl2 ~$1, sp".