mach4.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* $Id: mach4.c, v1.9 15-Mar-89 AJM */
  2. operation : BRANCH optlink expr
  3. {branch($1, $2, $3.val);}
  4. | DATA1 optcond opts optp REG ',' REG ',' operand
  5. {data($1,$2|$3|$4|$5<<12|$7<<16,$9.val,$9.typ);}
  6. | DATA2 optcond opts optp REG ',' operand
  7. {data($1,$2|$3|$4|$5<<12,$7.val,$7.typ);}
  8. | DATA3 optcond opts optp REG ',' operand
  9. {data($1,$2|$3|$4|$5<<16,$7.val,$7.typ);}
  10. | SDT optcond optb optt REG ',' address
  11. {strldr($1,$2|$3|$4|$5<<12,$7);}
  12. | BDT optcond REG optexc ',' reglist optpsr
  13. {emit4($1|$2|$3<<16|$4|$6|$7);}
  14. | SWI optcond expr
  15. {emit4($1|$2|$3.val);}
  16. | ADR optcond REG ',' expr
  17. {calcadr($2,$3,$5.val,$5.typ);}
  18. | MUL optcond REG ',' REG ',' REG
  19. {emit4($1|$2|$3<<16|$5|$7<<8);}
  20. | MLA optcond REG ',' REG ',' REG ',' REG
  21. {emit4($1|$2|$3<<16|$5|$7<<8|$9<<12);}
  22. ;
  23. optlink : {$$=0;}
  24. | LINK
  25. {$$=$1;}
  26. ;
  27. optcond : {$$=0xE0000000;}
  28. | COND
  29. {$$=$1;}
  30. ;
  31. opts : {$$=0;}
  32. | SET
  33. {$$=$1;}
  34. ;
  35. optt : {$$=0;}
  36. | TRANS
  37. {$$=$1;}
  38. ;
  39. optp : {$$=0;}
  40. | PEE
  41. {$$=$1;}
  42. ;
  43. optb : {$$=0;}
  44. | BYTE
  45. {$$=$1;}
  46. ;
  47. optexc : {$$=0;}
  48. | '<'
  49. {$$=0x00200000;}
  50. ;
  51. optpsr : {$$=0;}
  52. | '^'
  53. {$$=0x00400000;}
  54. ;
  55. operand : REG optshift
  56. {$$.val = $1|$2; $$.typ = S_REG;}
  57. | '#'expr
  58. {$$ = $2;}
  59. ;
  60. optshift : ',' SHIFT shftcnt
  61. {$$ = $2|$3;}
  62. | ',' RRX
  63. {$$ = $2;}
  64. |
  65. {$$ = 0;}
  66. ;
  67. aoptshift : ',' SHIFT '#' expr
  68. {$$ = $2|calcshft($4.val, $4.typ, $<y_word>0);}
  69. | ',' RRX
  70. {$$ = $2;}
  71. |
  72. {$$ = 0;}
  73. ;
  74. shftcnt : '#' expr
  75. {$$ = calcshft($2.val, $2.typ, $<y_word>0);}
  76. | REG
  77. {$$ = $1<<8|0x10;}
  78. ;
  79. address : expr
  80. {success = 0; $$ = $1.val;}
  81. | '[' REG ']'
  82. {success = 1; $$ = 0x01000000|$2<<16;}
  83. | '[' REG ',' offset ']' optexc
  84. {success = 1; $$ = $2<<16|$4|$6|0x01000000;}
  85. | '[' REG ']' ',' offset
  86. {success = 1; $$ = $2<<16|$5;}
  87. ;
  88. offset : '#' expr
  89. {$$ = calcoffset($2.val);}
  90. | optsign REG aoptshift
  91. {$$ = 0x02000000|$1|$2|$3;}
  92. ;
  93. optsign : {$$ = 0x00800000;}
  94. | '+'
  95. {$$ = 0x00800000;}
  96. | '-'
  97. {$$ = 0x0;}
  98. ;
  99. reglist : '{' rlist '}'
  100. {$$ = $2;}
  101. ;
  102. rlist : REG
  103. {$$ = 1<<$1;}
  104. | rlist ',' REG
  105. {$$ = $1|1<<$3;}
  106. | REG '-' REG
  107. {
  108. for ($$ = 0; $1 <= $3; $1++)
  109. $$ |= (1<<$1);
  110. }
  111. ;