home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / CCDL122.ZIP / INCLUDE / GEN.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-24  |  4.5 KB  |  136 lines

  1. /*
  2.  * 68K/386 32-bit C compiler.
  3.  *
  4.  * copyright (c) 1996, David Lindauer
  5.  * 
  6.  * This compiler is intended for educational use.  It may not be used
  7.  * for profit without the express written consent of the author.
  8.  *
  9.  * It may be freely redistributed, as long as this notice remains intact
  10.  * and sources are distributed along with any executables derived from them.
  11.  *
  12.  * The author is not responsible for damages, either direct or consequential,
  13.  * that may arise from use of this software.
  14.  *
  15.  * v1.5 August 1996
  16.  * David Lindauer, gclind01@starbase.spd.louisville.edu
  17.  *
  18.  * Credits to Mathew Brandt for original K&R C compiler
  19.  *
  20.  */
  21. /*
  22.  *      code generation structures and constants
  23.  */
  24.  
  25. /* address mode specifications */
  26. #define F_DREG  1       /* data register direct mode allowed */
  27. #define F_AREG  2       /* address register direct mode allowed */
  28. #define F_MEM   4       /* memory alterable modes allowed */
  29. #define F_IMMED 8       /* immediate mode allowed */
  30. #define F_ALT   7       /* alterable modes */
  31. #define F_DALT  5       /* data alterable modes */
  32. #define F_FREG  16      /* FP register */
  33. #define F_INDX  32    /* indexed memory alterable mode allowed */
  34. #define F_ALL   31      /* all modes allowed */
  35. #define F_VOL   64      /* need volitile operand */
  36. #define F_NOVALUE 128    /* dont need result value */
  37. #define F_NOBIT 256    /* Don't get the bit val, get the address */
  38.  
  39. /*      addressing mode structure       */
  40.  
  41. struct amode {
  42.         char            mode;
  43.         char            preg;
  44.         char            sreg;
  45.         char            tempflag;
  46. #ifdef i386
  47.     char        scale;
  48. #endif
  49.         struct enode    *offset;
  50.         };
  51.  
  52. /*      output code structure   */
  53.  
  54. struct ocode {
  55.         struct ocode    *fwd, *back;
  56.         short           opcode;
  57.         char            length;
  58. #ifdef i386
  59.     char        length2;
  60. #endif        
  61.         struct amode    *oper1, *oper2,*oper3;
  62.     int addr;
  63.     int size;
  64.     char diag;
  65.         };
  66.  
  67. /* Used for fixup gen */
  68. typedef struct dl {
  69.         struct dl *next;
  70.         char *string;
  71.         int offset;
  72.         short type;
  73. } DATALINK;
  74.  
  75. #define AMODE struct amode
  76. #define OCODE struct ocode
  77.  
  78. #ifdef i386
  79. #define FLOAT printf("codegen-Floating point not implemented\n");
  80. /* 386 register set */
  81. #define EAX 0
  82. #define ECX 1
  83. #define EDX 2
  84. #define EBX 3
  85. #define ESP 4
  86. #define EBP 5
  87. #define ESI 6
  88. #define EDI 7
  89. #define AL 0
  90. #define CL 1
  91. #define DL 2
  92. #define BL 3
  93. #define ES 0
  94. #define CS 1
  95. #define SS 2
  96. #define DS 3
  97.  
  98. enum e_op { op_line, op_label, op_seq,op_genword,
  99.     op_add, op_and, op_call, op_cld, op_cmp, op_cmpsb, op_cmpsw, op_cmpsd,
  100.     op_cwd, op_cbw, op_cbd, op_dec,
  101.     op_div, op_idiv, op_imul, op_inc, op_jb, op_jbe,op_je, op_jl,
  102.     op_jle, op_jnc, op_ja, op_jne, op_jge, op_jg, op_jmp, op_lea, op_lodsb,
  103.     op_lodsw, op_lodsd,
  104.     op_mov, op_movsb, op_movsw, op_movsd, op_movsx, op_movzx, op_mul, 
  105.     op_neg, op_not, op_or, op_pop, op_push, op_rep, op_repnz, op_repz, 
  106.     op_ret, op_sahf, op_sal, op_sar, op_scasb, op_scasw, op_scasd,
  107.     op_shr, op_shl, op_std, op_stosb, op_stosw, op_stosd, op_sub,
  108.     op_test, op_xchg, op_xor, op_dd, op_pushfd, op_iretd, op_pushad, op_popad,
  109.     op_fadd, op_fiadd, op_fchs, op_fcom, op_fcomp, op_fcompp,
  110.     op_fdiv, op_fidiv, op_ficom, op_ficomp, op_fild, op_fist, op_fistp,
  111.     op_fld, op_fldz, op_fmul, op_fimul, op_fprem, op_fscale, op_fst, op_fstp,
  112.     op_fstcw, op_fstsw, op_fsub, op_fisub, op_ftst, op_fxch, op_fwait
  113.     };
  114. enum e_am {
  115.         am_dreg, am_freg, am_indisp, am_indispscale,
  116.         am_direct, am_immed, am_none, am_cs };
  117. #else
  118. enum e_op {
  119.         op_line, op_seq, op_genword, op_move, op_moveq, op_add, op_addi, op_addq, op_sub, op_subi,
  120.         op_subq, op_muls, op_mulu, op_divs, op_divu, op_and, op_andi,
  121.         op_or, op_ori, op_eor, op_asl, op_asr, op_jmp, op_jsr, op_movem,
  122.         op_rts, op_rte, op_bra, op_beq, op_bne, op_blt, op_ble, op_bgt, op_bge,
  123.         op_bhi, op_bhs, op_blo, op_bls, op_tst, op_ext, op_lea, op_swap,
  124.         op_neg, op_not, op_cmp, op_clr, op_link, op_unlk, op_label,
  125.         op_pea, op_cmpi, op_dcl, op_dcr, op_bsr, op_divsl, op_divul, op_exg,
  126.     op_trap, op_lsl, op_lsr, op_bset,op_bclr,op_btst,
  127.     op_bfins, op_bfextu, op_bfexts, op_bfclr, op_bftst,
  128.     op_fmove, op_fmovem, op_fadd, op_fsub, op_fmul, op_fdiv, op_fmod,
  129.     op_fcmp, op_ftst, op_fneg, op_fbeq, op_fbne, op_fbgt, op_fbge,op_fblt,op_fble
  130. };
  131.  
  132. enum e_am {
  133.         am_dreg, am_areg, am_freg, am_ind, am_ainc, am_adec, am_indx, am_indx2,
  134.         am_xpc, am_direct, am_immed, am_mask, am_fmask, am_none, am_indx3, am_pcindx,
  135.     am_divsl, am_bf, am_sr };
  136. #endif