mach4.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #define RCSID4 "$Id$"
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. *
  6. */
  7. operation
  8. : prefix oper
  9. ;
  10. prefix : /* empty */
  11. | prefix PREFIX
  12. { emit1($2);}
  13. ;
  14. oper : NOOP_1
  15. { emit1($1);}
  16. | NOOP_2
  17. { emit2($1);}
  18. | JOP expr
  19. { branch($1,$2);}
  20. | PUSHOP ea_1
  21. { pushop($1);}
  22. | IOOP expr
  23. { emit1($1);
  24. #ifdef RELOCATION
  25. newrelo($2.typ, RELO1);
  26. #endif
  27. emit1($2.val);
  28. }
  29. | IOOP R16
  30. { if ($2!=2) serror("register error");
  31. emit1($1+010);
  32. }
  33. | ADDOP ea_ea
  34. { addop($1);}
  35. | ROLOP ea_ea
  36. { rolop($1);}
  37. | INCOP ea_1
  38. { incop($1);}
  39. | IMUL ea_ea
  40. { imul($1);}
  41. | IMUL ea_1
  42. { regsize($1); emit1(0366|($1&1)); ea_1($1&070);}
  43. | NOTOP ea_1
  44. { regsize($1); emit1(0366|($1&1)); ea_1($1&070);}
  45. | CALLOP ea_1
  46. { callop($1&0xFFFF);}
  47. | CALFOP expr ':' expr
  48. { emit1($1>>8);
  49. #ifdef RELOCATION
  50. newrelo($4.typ, RELO2);
  51. #endif
  52. emit2($4.val);
  53. #ifdef RELOCATION
  54. newrelo($2.typ, RELO2);
  55. #endif
  56. emit2($2.val);
  57. }
  58. | CALFOP mem
  59. { emit1(0377); ea_2($1&0xFF);}
  60. | ENTER absexp ',' absexp
  61. { fit(fitw($2)); fit(fitb($4));
  62. emit1($1); emit2((int)$2); emit1((int)$4);
  63. }
  64. | LEAOP R16 ',' mem
  65. { emit1($1); ea_2($2<<3);}
  66. | ARPLOP mem ',' R16
  67. { emit1($1); ea_2($4<<3);}
  68. | EXTOP R16 ',' ea_2
  69. { emit1(0xF); emit1($1);
  70. ea_2($2<<3);
  71. }
  72. | EXTOP1 ea_1
  73. { regsize(1); emit1(0xF); emit1($1&07);
  74. ea_1($1&070);
  75. }
  76. | ESC absexp ',' mem
  77. { fit(fit6($2));
  78. emit1(0330 | $2>>3);
  79. ea_2(($2&7)<<3);
  80. }
  81. | INT absexp
  82. { if ($2==3)
  83. emit1(0314);
  84. else {
  85. emit1(0315); emit1($2);
  86. }
  87. }
  88. | RET
  89. { emit1($1);}
  90. | RET expr
  91. { emit1($1-1);
  92. #ifdef RELOCATION
  93. newrelo($2.typ, RELO2);
  94. #endif
  95. emit2($2.val);
  96. }
  97. | XCHG ea_ea
  98. { xchg($1);}
  99. | TEST ea_ea
  100. { test($1);}
  101. | MOV ea_ea
  102. { mov($1);}
  103. /* Intel 8087 coprocessor instructions */
  104. | FNOOP
  105. { emit1($1); emit1($1>>8);}
  106. | FMEM mem
  107. { emit1($1); ea_2(($1>>8)&070);}
  108. | FST_I st_i
  109. { emit1($1); emit1(($1>>8)|$2); }
  110. | FST_I ST
  111. { emit1($1); emit1($1>>8); }
  112. | FST_ST ST ',' st_i
  113. { emit1($1); emit1(($1>>8)|$4); }
  114. | FST_ST2 ST ',' st_i
  115. { emit1($1); emit1(($1>>8)|$4); }
  116. | FST_ST st_i ',' ST
  117. { emit1($1|4); emit1((($1>>8)|$2)); }
  118. | FST_ST2 st_i ',' ST
  119. { emit1($1|4); emit1((($1>>8)|$2)^010); }
  120. ;
  121. st_i : ST '(' absexp ')'
  122. { if (!fit3($3)) {
  123. serror("illegal index in FP stack");
  124. }
  125. $$ = $3;
  126. }
  127. ;
  128. mem : '(' expr ')'
  129. { mrg_2 = 6; exp_2 = $2;
  130. RELOMOVE(rel_2, relonami);
  131. }
  132. | bases
  133. { exp_2.val = 0; exp_2.typ = S_ABS; indexed();}
  134. | expr bases
  135. { exp_2 = $1; indexed();
  136. RELOMOVE(rel_2, relonami);
  137. }
  138. ;
  139. bases : '(' R16 ')'
  140. { mrg_2 = sr_m[$2];}
  141. | '(' R16 ')' '(' R16 ')'
  142. { mrg_2 = dr_m[$2][$5];}
  143. ;
  144. ea_2 : mem
  145. | R8
  146. { mrg_2 = $1 | 0300;}
  147. | R16
  148. { mrg_2 = $1 | 0310;}
  149. | RSEG
  150. { mrg_2 = $1 | 020;}
  151. | expr
  152. { mrg_2 = 040; exp_2 = $1;
  153. RELOMOVE(rel_2, relonami);
  154. }
  155. ;
  156. ea_1 : ea_2
  157. { mrg_1 = mrg_2; exp_1 = exp_2;
  158. RELOMOVE(rel_1, rel_2);
  159. }
  160. ;
  161. ea_ea : ea_1 ',' ea_2
  162. ;