EM_table 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. #define PUSH_POP_OPT TRUE
  2. /******************************************************************************/
  3. /* */
  4. /* Group 1 : load instructions */
  5. /* */
  6. /******************************************************************************/
  7. C_loc ==> "mov ax, $1";
  8. "push ax".
  9. C_ldc ==> C_loc( $1>>16);
  10. C_loc( $1).
  11. C_lol ==> "push $1(bp)".
  12. C_loe.. ==> "push ($1+$2)".
  13. C_lil ==> "mov bx, $1(bp)";
  14. "push (bx)".
  15. C_lof ==> "pop bx";
  16. "push $1(bx)".
  17. C_lal ==> "lea ax, $1(bp)";
  18. "push ax".
  19. C_lae.. ==> "mov ax, $1+$2";
  20. "push ax".
  21. C_lxl
  22. $1 == 0 ==> "push bp".
  23. $1 == 1 ==> "push 4(bp)".
  24. default ==> "mov cx, $1-1";
  25. "mov bx, 4(bp)";
  26. "1: mov bx, 4(bx)";
  27. "loop 1b";
  28. "push bx".
  29. C_lxa
  30. $1 == 0 ==> "lea ax, 4(bp)";
  31. "push ax".
  32. $1 == 1 ==> "mov ax, 4(bp)";
  33. "add ax, 4";
  34. "push ax".
  35. default ==> "mov cx, $1-1";
  36. "mov bx, 4(bp)";
  37. "1: mov bx, 4(bx)";
  38. "loop 1b";
  39. "add bx, 4";
  40. "push bx".
  41. C_loi
  42. $1 == 1 ==> "pop bx";
  43. "xor ax, ax";
  44. "movb al, (bx)";
  45. "push ax".
  46. $1 == 2 ==> "pop bx";
  47. "push (bx)".
  48. $1 == 4 ==> "pop bx";
  49. "push 2(bx)";
  50. "push (bx)".
  51. default ==> "pop bx";
  52. "mov cx, $1";
  53. "call .loi".
  54. C_los
  55. $1 == 2 ==> "pop cx";
  56. "pop bx";
  57. "call .los".
  58. default ==> arg_error( "C_los", $1).
  59. C_los_narg ==> "pop ax";
  60. "cmp ax, 2";
  61. "jne .unknown";
  62. "pop cx";
  63. "pop bx";
  64. "call .loi".
  65. C_ldl ==> "push $1+2(bp)";
  66. "push $1(bp)".
  67. C_lde.. ==> "push ($1+$2+2)";
  68. "push ($1+$2)".
  69. C_ldf ==> "pop bx";
  70. "push $1+2(bx)";
  71. "push $1(bx)".
  72. C_lpi ==> "mov ax, $1";
  73. "push ax".
  74. /******************************************************************************/
  75. /* */
  76. /* Group 2 : store instructions */
  77. /* */
  78. /******************************************************************************/
  79. C_stl ==> "pop $1(bp)".
  80. C_ste.. ==> "pop ($1+$2)".
  81. C_sil ==> "mov bx, $1(bp)";
  82. "pop (bx)".
  83. C_stf ==> "pop bx";
  84. "pop $1(bx)".
  85. C_sti
  86. $1 == 1 ==> "pop bx";
  87. "pop ax";
  88. "movb (bx), al".
  89. $1 == 2 ==> "pop bx";
  90. "pop (bx)".
  91. $1 == 4 ==> "pop bx";
  92. "pop (bx)";
  93. "pop 2(bx)".
  94. default ==> "pop bx";
  95. "mov cx, $1";
  96. "call .sti".
  97. C_sts
  98. $1 == 2 ==> "pop cx";
  99. "pop bx";
  100. "call .sts".
  101. default ==> arg_error( "C_sts", $1).
  102. C_sts_narg ==> "pop ax";
  103. "cmp ax, 2";
  104. "jne .unknown";
  105. "pop cx";
  106. "pop bx";
  107. "call .sti".
  108. C_sdl ==> "pop $1(bp)";
  109. "pop $1+2(bp)".
  110. C_sde.. ==> "pop ($1+$2)";
  111. "pop ($1+$2+2)".
  112. C_sdf ==> "pop bx";
  113. "pop $1(bx)";
  114. "pop $1+2(bx)".
  115. /******************************************************************************/
  116. /* */
  117. /* Group 3 : integer arithmetic */
  118. /* */
  119. /******************************************************************************/
  120. C_adi
  121. $1 == 2 ==> "pop ax";
  122. "pop bx";
  123. "add ax, bx";
  124. "push ax".
  125. $1 == 4 ==> "pop ax";
  126. "pop bx";
  127. "pop cx";
  128. "pop dx";
  129. "add ax, cx";
  130. "adc bx, dx";
  131. "push bx";
  132. "push ax".
  133. default ==> "pop ax";
  134. "mov cx, $1";
  135. "call .adi";
  136. "push ax".
  137. C_adi_narg ==> "pop cx";
  138. "pop ax";
  139. "call .adi";
  140. "push ax".
  141. C_sbi
  142. $1 == 2 ==> "pop bx";
  143. "pop ax";
  144. "sub ax, bx";
  145. "push ax".
  146. $1 == 4 ==> "pop ax";
  147. "pop bx";
  148. "pop cx";
  149. "pop dx";
  150. "sub cx, ax";
  151. "sbb dx, bx";
  152. "push dx";
  153. "push cx".
  154. default ==> "pop ax";
  155. "mov cx, $1";
  156. "call .sbi";
  157. "push ax".
  158. C_sbi_narg ==> "pop cx";
  159. "pop ax";
  160. "call .sbi";
  161. "push ax".
  162. C_mli
  163. $1 == 2 ==> "pop ax";
  164. "pop bx";
  165. "mul bx";
  166. "push ax".
  167. $1 == 4 ==> "pop ax";
  168. "pop dx";
  169. "call .mli4";
  170. "push dx";
  171. "push ax".
  172. default ==> arg_error( "C_mli", $1).
  173. C_mli_narg ==> "pop ax";
  174. "call .mli".
  175. C_dvi
  176. $1 == 2 ==> "pop bx";
  177. "pop ax";
  178. "cwd";
  179. "idiv bx";
  180. "push ax".
  181. $1 == 4 ==> "call .dvi4";
  182. "push dx";
  183. "push ax".
  184. default ==> arg_error( "C_dvi", $1).
  185. C_dvi_narg ==> "pop ax";
  186. "call .dvi".
  187. C_rmi
  188. $1 == 2 ==> "pop bx";
  189. "pop ax";
  190. "cwd";
  191. "idiv bx";
  192. "push dx".
  193. $1 == 4 ==> "call .rmi4";
  194. "push dx";
  195. "push ax".
  196. default ==> arg_error( "C_rmi", $1).
  197. C_rmi_narg ==> "pop ax";
  198. "call .rmi".
  199. C_ngi
  200. $1 == 2 ==> "pop ax";
  201. "neg ax";
  202. "push ax".
  203. $1 == 4 ==> "pop bx";
  204. "pop ax";
  205. "neg ax";
  206. "neg bx";
  207. "sbb ax, 0";
  208. "push ax";
  209. "push bx".
  210. default ==> "mov ax, $1";
  211. "call .ngi".
  212. C_ngi_narg ==> "pop ax";
  213. "call .ngi".
  214. C_sli
  215. $1 == 2 ==> "pop cx";
  216. "pop ax";
  217. "sal ax, cl";
  218. "push ax".
  219. default ==> "mov ax, $1";
  220. "call .sli".
  221. C_sli_narg ==> "pop ax";
  222. "call .sli".
  223. C_sri
  224. $1 == 2 ==> "pop cx";
  225. "pop ax";
  226. "sar ax, cl";
  227. "push ax".
  228. default ==> "mov ax, $1";
  229. "call .sri".
  230. C_sri_narg ==> "pop ax";
  231. "call .sri".
  232. /******************************************************************************/
  233. /* */
  234. /* Group 4 : Unsigned arithmetic */
  235. /* */
  236. /******************************************************************************/
  237. C_adu ==> C_adi( $1).
  238. C_adu_narg ==> C_adi_narg().
  239. C_sbu ==> C_sbi( $1).
  240. C_sbu_narg ==> C_sbi_narg().
  241. C_mlu ==> C_mli( $1).
  242. C_mlu_narg ==> C_mli_narg().
  243. C_dvu
  244. $1 == 2 ==> "pop bx";
  245. "pop ax";
  246. "xor dx, dx";
  247. "div bx";
  248. "push ax".
  249. $1 == 4 ==> "call .dvu4";
  250. "push dx";
  251. "push ax".
  252. default ==> "mov ax, $1";
  253. "call .dvu".
  254. C_dvu_narg ==> "pop ax";
  255. "call .dvu".
  256. C_rmu
  257. $1 == 2 ==> "pop bx";
  258. "pop ax";
  259. "xor dx, dx";
  260. "div bx";
  261. "push dx".
  262. $1 == 4 ==> "call .dvu4";
  263. "push dx";
  264. "push ax".
  265. default ==> "mov ax, $1";
  266. "call .rmu".
  267. C_rmu_narg ==> "pop ax";
  268. "call .rmu".
  269. C_slu ==> C_sli( $1).
  270. C_slu_narg ==> C_sli_narg().
  271. C_sru
  272. $1 == 2 ==> "pop cx";
  273. "pop ax";
  274. "shr ax, cl";
  275. "push ax".
  276. $1 == 4 ==> "pop cx";
  277. "pop bx";
  278. "pop ax";
  279. "1 : shr ax, 1";
  280. "rcr bx, 1";
  281. "loop 1b";
  282. "push ax";
  283. "push bx".
  284. default ==> arg_error( "C_sru", $1).
  285. /******************************************************************************/
  286. /* */
  287. /* Group 5 : Floating point arithmetic */
  288. /* */
  289. /******************************************************************************/
  290. C_adf
  291. $1 == 4 ==> "call .adf4";
  292. "pop bx";
  293. "pop bx".
  294. $1 == 8 ==> "call .adf8";
  295. "add sp,8".
  296. default ==> arg_error("C_adf", $1).
  297. C_sbf
  298. $1 == 4 ==> "call .sbf4";
  299. "pop bx";
  300. "pop bx".
  301. $1 == 8 ==> "call .sbf8";
  302. "add sp,8".
  303. default ==> arg_error("C_sbf", $1).
  304. C_mlf
  305. $1 == 4 ==> "call .mlf4";
  306. "pop bx";
  307. "pop bx".
  308. $1 == 8 ==> "call .mlf8";
  309. "add sp,8".
  310. default ==> arg_error("C_mlf", $1).
  311. C_dvf
  312. $1 == 4 ==> "call .dvf4";
  313. "pop bx";
  314. "pop bx".
  315. $1 == 8 ==> "call .dvf8";
  316. "add sp,8".
  317. default ==> arg_error("C_dvf", $1).
  318. C_ngf
  319. $1 == 4 ==> "call .ngf4".
  320. $1 == 8 ==> "call .ngf8".
  321. default ==> arg_error("C_ngf", $1).
  322. C_fif
  323. $1 == 4 ==> C_lor((arith)1);
  324. "call .fif4";
  325. "pop bx".
  326. $1 == 8 ==> C_lor((arith)1);
  327. "call .fif8";
  328. "pop bx".
  329. default ==> arg_error("C_fif", $1).
  330. C_fef
  331. $1 == 4 ==> "mov ax,sp";
  332. "sub ax,2";
  333. "push ax";
  334. "call .fef4".
  335. $1 == 8 ==> "mov ax,sp";
  336. "sub ax,2";
  337. "push ax";
  338. "call .fef8".
  339. default ==> arg_error("C_fef", $1).
  340. /******************************************************************************/
  341. /* */
  342. /* Group 6 : Pointer arithmetic */
  343. /* */
  344. /******************************************************************************/
  345. C_adp
  346. #ifndef PEEPHOLE_OPT
  347. $1 == 0 ==> .
  348. #endif
  349. $1 == 1 ==> "pop ax";
  350. "inc ax";
  351. "push ax".
  352. $1 == -1 ==> "pop ax";
  353. "dec ax";
  354. "push ax".
  355. default ==> "pop ax";
  356. "add ax, $1";
  357. "push ax".
  358. C_ads
  359. $1 == 2 ==> "pop ax";
  360. "pop bx";
  361. "add ax, bx";
  362. "push ax".
  363. default ==> arg_error( "C_ads", $1).
  364. C_ads_narg ==> "pop ax";
  365. "cmp ax, 2";
  366. "jne .unknown";
  367. "pop ax";
  368. "pop bx";
  369. "add ax, bx";
  370. "push ax".
  371. C_sbs
  372. $1 == 2 ==> "pop bx";
  373. "pop ax";
  374. "sub ax, bx";
  375. "push ax".
  376. default ==> arg_error( "C_sbs", $1).
  377. C_sbs_narg ==> "pop ax";
  378. "cmp ax, 2";
  379. "jne .unknown";
  380. "pop bx";
  381. "pop ax";
  382. "sub ax, bx";
  383. "push ax".
  384. /******************************************************************************/
  385. /* */
  386. /* Group 7 : Increment/decrement/zero */
  387. /* */
  388. /******************************************************************************/
  389. C_inc ==> "pop ax";
  390. "inc ax";
  391. "push ax".
  392. C_inl ==> "inc $1(bp)".
  393. C_ine.. ==> "inc ($1+$2)".
  394. C_dec ==> "pop ax";
  395. "dec ax";
  396. "push ax".
  397. C_del ==> "dec $1(bp)".
  398. C_dee.. ==> "dec ($1+$2)".
  399. C_zrl ==> "mov $1(bp), 0".
  400. C_zre.. ==> "mov ($1+$2), 0".
  401. C_zer
  402. $1 == 2 ==> "xor ax, ax";
  403. "push ax".
  404. $1 == 4 ==> "xor ax, ax";
  405. "push ax";
  406. "push ax".
  407. $1 == 6 ==> "xor ax, ax";
  408. "push ax";
  409. "push ax";
  410. "push ax".
  411. $1 == 8 ==> "xor ax, ax";
  412. "push ax";
  413. "push ax";
  414. "push ax";
  415. "push ax".
  416. $1 % 2 == 0 ==> "mov cx, $1/2";
  417. "xor ax, ax";
  418. "1: push ax";
  419. "loop 1b".
  420. default ==> arg_error( "C_zer", $1).
  421. C_zrf ==> C_zer($1).
  422. C_zer_narg ==> "pop cx";
  423. "sar cx, 1";
  424. "xor ax, ax";
  425. "1: push ax";
  426. "loop 1b".
  427. /******************************************************************************/
  428. /* */
  429. /* Group 8 : Convert */
  430. /* */
  431. /******************************************************************************/
  432. C_cii ==> "pop cx";
  433. "pop dx";
  434. "pop ax";
  435. "call .cii";
  436. "push ax".
  437. C_cui ==> C_cuu().
  438. C_ciu ==> C_cuu().
  439. C_cuu ==> "pop cx";
  440. "pop dx";
  441. "pop ax";
  442. "call .cuu";
  443. "push ax".
  444. C_cif ==> "call .cif".
  445. C_cuf ==> "call .cuf".
  446. C_cfi ==> "call .cfi";
  447. "pop bx";
  448. "pop cx";
  449. "cmp bx,4";
  450. "je 1f";
  451. "add sp,cx";
  452. "push ax";
  453. "jmp 2f";
  454. "1:add cx,4";
  455. "add sp,cx";
  456. "2:".
  457. C_cfu ==> "call .cfu";
  458. "pop bx";
  459. "pop cx";
  460. "cmp bx,4";
  461. "je 1f";
  462. "add sp,cx";
  463. "push ax";
  464. "jmp 2f";
  465. "1:add cx,4";
  466. "add sp,cx";
  467. "2:".
  468. C_cff ==> "pop ax";
  469. "pop bx";
  470. "cmp ax,bx";
  471. "je 1f";
  472. "cmp ax,4";
  473. "je 2f";
  474. "pop cx";
  475. "pop bx";
  476. "xor ax,ax";
  477. "push ax";
  478. "push ax";
  479. "push bx";
  480. "push cx";
  481. "call .cff8";
  482. "jmp 1f";
  483. "2: call .cff4";
  484. "pop bx";
  485. "pop bx";
  486. "1:".
  487. /******************************************************************************/
  488. /* */
  489. /* Group 9 : Logical */
  490. /* */
  491. /******************************************************************************/
  492. C_and
  493. $1 == 2 ==> "pop ax";
  494. "pop bx";
  495. "and ax, bx";
  496. "push ax".
  497. $1 == 4 ==> "pop ax";
  498. "pop bx";
  499. "pop cx";
  500. "pop dx";
  501. "and ax, cx";
  502. "and bx, dx";
  503. "push bx";
  504. "push ax".
  505. default ==> "mov cx, $1";
  506. "call .and".
  507. C_and_narg ==> "pop cx";
  508. "call .and".
  509. C_ior
  510. $1 == 2 ==> "pop ax";
  511. "pop bx";
  512. "or ax, bx";
  513. "push ax".
  514. $1 == 4 ==> "pop ax";
  515. "pop bx";
  516. "pop cx";
  517. "pop dx";
  518. "or ax, cx";
  519. "or bx, dx";
  520. "push bx";
  521. "push ax".
  522. default ==> "mov cx, $1";
  523. "call .ior".
  524. C_ior_narg ==> "pop cx";
  525. "call .ior".
  526. C_xor
  527. $1 == 2 ==> "pop ax";
  528. "pop bx";
  529. "xor ax, bx";
  530. "push ax".
  531. $1 == 4 ==> "pop ax";
  532. "pop bx";
  533. "pop cx";
  534. "pop dx";
  535. "xor ax, cx";
  536. "xor bx, dx";
  537. "push bx";
  538. "push ax".
  539. default ==> "mov cx, $1";
  540. "call .xor".
  541. C_xor_narg ==> "pop cx";
  542. "call .xor".
  543. C_com
  544. $1 == 2 ==> "pop ax";
  545. "not ax";
  546. "push ax".
  547. $1 == 4 ==> "pop ax";
  548. "pop bx";
  549. "not ax";
  550. "not bx";
  551. "push bx";
  552. "push ax".
  553. default ==> "mov cx, $1";
  554. "call .com".
  555. C_com_narg ==> "pop cx";
  556. "call .com".
  557. C_rol
  558. $1 == 2 ==> "pop cx";
  559. "pop ax";
  560. "rol ax, cl";
  561. "push ax".
  562. default ==> "mov cx, $1";
  563. "call .rol".
  564. C_rol_narg ==> "pop cx";
  565. "call .rol".
  566. C_ror
  567. $1 == 2 ==> "pop cx";
  568. "pop ax";
  569. "ror ax, cl";
  570. "push ax".
  571. default ==> "mov cx, $1";
  572. "call .ror".
  573. C_ror_narg ==> "pop cx";
  574. "call .ror".
  575. /******************************************************************************/
  576. /* */
  577. /* Group 10 : Sets */
  578. /* */
  579. /******************************************************************************/
  580. C_inn
  581. $1 == 2 ==> "pop cx";
  582. "pop ax";
  583. "shr ax, cl";
  584. "and ax, 1";
  585. "push ax".
  586. default ==> "pop ax";
  587. "mov cx, $1";
  588. "call .inn";
  589. "push ax".
  590. C_inn_narg ==> "pop cx";
  591. "pop ax";
  592. "call .inn";
  593. "push ax".
  594. C_set
  595. $1 == 2 ==> "pop cx";
  596. "mov ax, 1";
  597. "shl ax, cl";
  598. "push ax".
  599. default ==> "pop ax";
  600. "mov cx, $1";
  601. "call .set".
  602. C_set_narg ==> "pop cx";
  603. "pop ax";
  604. "call .set".
  605. /******************************************************************************/
  606. /* */
  607. /* Group 11 : Array */
  608. /* */
  609. /******************************************************************************/
  610. C_lar
  611. $1 == 2 ==> "pop bx";
  612. "pop ax";
  613. "call .lar2".
  614. default ==> arg_error( "C_lar", $1).
  615. C_lar_narg ==> "call .ilar".
  616. C_sar
  617. $1 == 2 ==> "pop bx";
  618. "pop ax";
  619. "call .sar2".
  620. default ==> arg_error( "C_sar", $1).
  621. C_sar_narg ==> "call .isar".
  622. C_aar
  623. $1 == 2 ==> "pop bx";
  624. "pop ax";
  625. "pop cx";
  626. "sub ax, (bx)";
  627. "mul 4(bx)";
  628. "add ax, cx";
  629. "push ax".
  630. default ==> arg_error( "C_aar", $1).
  631. C_aar_narg ==> "call .iaar";
  632. "push bx".
  633. /******************************************************************************/
  634. /* */
  635. /* Group 12 : Compare */
  636. /* */
  637. /******************************************************************************/
  638. C_cmi
  639. $1 == 2 ==> /* bug : C_sbi( (arith) 2). */
  640. "pop bx";
  641. "pop cx";
  642. "xor ax, ax";
  643. "cmp cx, bx";
  644. "je 2f";
  645. "jl 1f";
  646. "inc ax";
  647. "jmp 2f";
  648. "1: dec ax";
  649. "2: push ax".
  650. $1 == 4 ==> "call .cmi4";
  651. "push ax".
  652. default ==> arg_error( "C_cmi", $1).
  653. C_cmu
  654. $1 == 2 ==> C_cmp().
  655. $1 == 4 ==> "call .cmu4";
  656. "push ax".
  657. default ==> arg_error( "C_cmu", $1).
  658. C_cms
  659. $1 == 2 ==> C_sbi( (arith) 2).
  660. $1 == 4 ==> "pop ax";
  661. "pop bx";
  662. "pop cx";
  663. "pop dx";
  664. "sub cx, ax";
  665. "sbb dx, bx";
  666. "jne 1f";
  667. "or dx, cx";
  668. "1: push dx".
  669. default ==> "mov cx, $1";
  670. "call .cms";
  671. "push cx".
  672. C_cms_narg ==> "pop cx";
  673. "call .cms";
  674. "push cx".
  675. C_cmp ==> "pop bx";
  676. "pop cx";
  677. "xor ax, ax";
  678. "cmp cx, bx";
  679. "je 2f";
  680. "jb 1f";
  681. "inc ax";
  682. "jmp 2f";
  683. "1: dec ax";
  684. "2: push ax".
  685. C_cmf
  686. $1 == 4 ==> "call .cmf4";
  687. "add sp,8";
  688. "push ax".
  689. $1 == 8 ==> "call .cmf8";
  690. "add sp,16";
  691. "push ax".
  692. default ==> arg_error("C_cmf", $1).
  693. C_tlt ==> "pop ax";
  694. "xor bx, bx";
  695. "test ax, ax";
  696. "jge 1f";
  697. "inc bx";
  698. "1: push bx".
  699. C_tle ==> "pop ax";
  700. "xor bx, bx";
  701. "test ax, ax";
  702. "jg 1f";
  703. "inc bx";
  704. "1: push bx".
  705. C_teq ==> "pop ax";
  706. "xor bx, bx";
  707. "test ax, ax";
  708. "jne 1f";
  709. "inc bx";
  710. "1: push bx".
  711. C_tne ==> "pop ax";
  712. "xor bx, bx";
  713. "test ax, ax";
  714. "je 1f";
  715. "inc bx";
  716. "1: push bx".
  717. C_tge ==> "pop ax";
  718. "xor bx, bx";
  719. "test ax, ax";
  720. "jl 1f";
  721. "inc bx";
  722. "1: push bx".
  723. C_tgt ==> "pop ax";
  724. "xor bx, bx";
  725. "test ax, ax";
  726. "jle 1f";
  727. "inc bx";
  728. "1: push bx".
  729. /******************************************************************************/
  730. /* */
  731. /* Group 13 : Branch */
  732. /* */
  733. /******************************************************************************/
  734. C_bra ==> "jmp $1".
  735. C_blt ==> "pop ax";
  736. "pop bx";
  737. "cmp bx, ax";
  738. "jl $1".
  739. C_ble ==> "pop ax";
  740. "pop bx";
  741. "cmp bx, ax";
  742. "jle $1".
  743. C_beq ==> "pop ax";
  744. "pop bx";
  745. "cmp bx, ax";
  746. "je $1".
  747. C_bne ==> "pop ax";
  748. "pop bx";
  749. "cmp bx, ax";
  750. "jne $1".
  751. C_bge ==> "pop ax";
  752. "pop bx";
  753. "cmp bx, ax";
  754. "jge $1".
  755. C_bgt ==> "pop ax";
  756. "pop bx";
  757. "cmp bx, ax";
  758. "jg $1".
  759. C_zlt ==> "pop ax";
  760. "test ax, ax";
  761. "jl $1".
  762. C_zle ==> "pop ax";
  763. "test ax, ax";
  764. "jle $1".
  765. C_zeq ==> "pop ax";
  766. "test ax, ax";
  767. "je $1".
  768. C_zne ==> "pop ax";
  769. "test ax, ax";
  770. "jne $1".
  771. C_zge ==> "pop ax";
  772. "test ax, ax";
  773. "jge $1".
  774. C_zgt ==> "pop ax";
  775. "test ax, ax";
  776. "jg $1".
  777. /******************************************************************************/
  778. /* */
  779. /* Group 14 : Procedure call instructions */
  780. /* */
  781. /******************************************************************************/
  782. C_cai ==> "pop bx";
  783. "call bx".
  784. C_cal ==> "call $1".
  785. C_lfr
  786. $1 == 2 ==> "push ax".
  787. $1 == 4 ==> "push dx";
  788. "push ax".
  789. $1 == 6 ==> "call .lfr6".
  790. $1 == 8 ==> "call .lfr8".
  791. default ==> arg_error( "C_lfr", $1).
  792. C_ret
  793. $1 == 0 ==> "mov sp, bp";
  794. "pop bp";
  795. "ret".
  796. $1 == 2 ==> "pop ax";
  797. "mov sp, bp";
  798. "pop bp";
  799. "ret".
  800. $1 == 4 ==> "pop ax";
  801. "pop dx";
  802. "mov sp, bp";
  803. "pop bp";
  804. "ret".
  805. $1 == 6 ==> "call .ret6";
  806. "mov sp, bp";
  807. "pop bp";
  808. "ret".
  809. $1 == 8 ==> "call .ret8";
  810. "mov sp, bp";
  811. "pop bp";
  812. "ret".
  813. default ==> arg_error( "C_ret", $1).
  814. /******************************************************************************/
  815. /* */
  816. /* Group 15 : Miscellaneous instructions */
  817. /* */
  818. /******************************************************************************/
  819. C_asp
  820. $1 == 2 ==> "pop bx".
  821. $1 == 4 ==> "pop bx";
  822. "pop bx".
  823. $1 == -2 ==> "push ax".
  824. default ==> "add sp, $1".
  825. C_ass
  826. $1 == 2 ==> "pop ax";
  827. "add sp, ax".
  828. default ==> arg_error( "C_ass", $1).
  829. C_ass_narg ==> "pop ax";
  830. "cmp ax, 2";
  831. "jne .unknown";
  832. "pop ax";
  833. "add sp, ax".
  834. C_blm
  835. $1 % 2 == 0 ==> "mov cx, $1/2";
  836. "call .blm".
  837. default ==> arg_error( "C_blm", $1).
  838. C_bls
  839. $1 == 2 ==> "pop cx";
  840. "sar cx,1";
  841. "call .blm".
  842. default ==> arg_error( "C_bls", $1).
  843. C_bls_narg ==> "pop ax";
  844. "cmp ax, 2";
  845. "jne .unknown";
  846. "pop cx";
  847. "sar cx, 1";
  848. "call .blm".
  849. C_csa
  850. $1 == 2 ==> "pop bx";
  851. "pop ax";
  852. "jmp .csa2".
  853. default ==> arg_error( "C_csa", $1).
  854. C_csa_narg ==> "pop ax";
  855. "cmp ax, 2";
  856. "jne .unknown";
  857. "pop bx";
  858. "pop ax";
  859. "jmp .csa2".
  860. C_csb
  861. $1 == 2 ==> "pop bx";
  862. "pop ax";
  863. "jmp .csb2".
  864. default ==> arg_error( "C_csb", $1).
  865. C_csb_narg ==> "pop ax";
  866. "cmp ax, 2";
  867. "jne .unknown";
  868. "pop bx";
  869. "pop ax";
  870. "jmp .csb2".
  871. C_dch ==> "mov bp, (bp)".
  872. C_dup
  873. $1 == 2 ==> "pop ax";
  874. "push ax";
  875. "push ax".
  876. $1 == 4 ==> "pop ax";
  877. "pop bx";
  878. "push bx";
  879. "push ax";
  880. "push bx";
  881. "push ax".
  882. default ==> "mov cx, $1";
  883. "call .dup".
  884. C_dus
  885. $1 == 2 ==> "pop cx";
  886. "call .dup".
  887. default ==> arg_error( "C_dus", $1).
  888. C_dus_narg ==> "pop ax";
  889. "cmp ax, 2";
  890. "jne .unknown";
  891. "pop cx";
  892. "call .dup".
  893. C_exg ==> "mov cx, $1";
  894. "call .exg".
  895. C_exg_narg ==> "pop cx";
  896. "call .exg".
  897. C_fil.. ==> "mov (hol0+4), $1+$2".
  898. C_gto.. ==> "mov bx, $1+$2";
  899. "call .gto".
  900. C_lim ==> "push (.ignmask)".
  901. C_lin ==> "mov (hol0), $1".
  902. C_lni ==> "inc (hol0)".
  903. C_lor
  904. $1 == 0 ==> "push bp".
  905. $1 == 1 ==> "mov ax, sp";
  906. "push ax".
  907. $1 == 2 ==> "push (.reghp)".
  908. default ==> arg_error( "C_lor", $1).
  909. C_lpb ==> "pop ax";
  910. "add ax,4";
  911. "push ax".
  912. C_mon ==> "pop ax";
  913. "call .mon".
  914. C_nop ==> .
  915. C_rck
  916. $1 == 2 ==> "pop bx";
  917. "pop ax";
  918. "call .rck";
  919. "push ax".
  920. default ==> arg_error( "C_rck", $1).
  921. C_rck_narg ==> "pop ax";
  922. "cmp ax, 2";
  923. "jne .unknown";
  924. "pop bx";
  925. "pop ax";
  926. "call .rck";
  927. "push ax".
  928. C_rtt ==> C_ret( (arith) 0).
  929. C_sig ==> "pop ax";
  930. "xchg (.trppc), ax";
  931. "push ax".
  932. C_sim ==> "pop (.ignmask)".
  933. C_str
  934. $1 == 0 ==> "pop bp".
  935. $1 == 1 ==> "pop sp".
  936. $1 == 2 ==> "pop (.reghp)".
  937. default ==> arg_error( "C_str", $1).
  938. C_trp ==> "pop ax";
  939. "call .trp".
  940. /******************************************************************************/
  941. /* */
  942. /* Storage-routines */
  943. /* */
  944. /******************************************************************************/
  945. ..icon
  946. $2 == 1 ==> gen1( (ONE_BYTE) atoi( $1)).
  947. $2 == 2 ==> gen2( (TWO_BYTES) atoi( $1)).
  948. $2 == 4 ==> gen4( (FOUR_BYTES) atol( $1)).
  949. default ==> arg_error( "..icon", $1).
  950. ..ucon
  951. $2 == 1 ==> gen1( (ONE_BYTE) atoi( $1)).
  952. $2 == 2 ==> gen2( (TWO_BYTES) atoi( $1)).
  953. $2 == 4 ==> gen4( (FOUR_BYTES) atol( $1)).
  954. default ==> arg_error( "..ucon", $1).
  955. ..fcon ==> con_float($1, $2).
  956. /******************************************************************************/
  957. /* */
  958. /* Extra-routines */
  959. /* */
  960. /******************************************************************************/
  961. #ifdef PUSH_POP_OPT
  962. C_df_ilb ==> clean_push_buf();
  963. symbol_definition( $1);
  964. set_local_visible( $1).
  965. #endif
  966. C_jump ==> "jmp $1".
  967. C_prolog ==> "push bp";
  968. "mov bp, sp".
  969. C_locals
  970. $1 == 0 ==> .
  971. $1 == 2 ==> "push ax".
  972. $1 == 4 ==> "push ax";
  973. "push ax".
  974. default ==> "sub sp, $1".