x86.M1 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. ### GNU Mes --- Maxwell Equations of Software
  2. ### Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  3. ###
  4. ### This file is part of GNU Mes.
  5. ###
  6. ### Mes is free software# you can redistribute it and/or modify it
  7. ### under the terms of the GNU General Public License as published by
  8. ### the Free Software Foundation# either version 3 of the License, or (at
  9. ### your option) any later version.
  10. ###
  11. ### GNU Mes is distributed in the hope that it will be useful, but
  12. ### WITHOUT ANY WARRANTY# without even the implied warranty of
  13. ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ### GNU General Public License for more details.
  15. ###
  16. ### You should have received a copy of the GNU General Public License
  17. ### along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  18. # reduced instruction set: eax, ebx (some ecx for shift, edx for mul, div)
  19. # 193 instructions
  20. DEFINE add____$i32,%eax 05
  21. DEFINE add____$i32,%ebx 81c3
  22. DEFINE add____$i32,(%eax) 8100
  23. DEFINE add____$i32,(%ebx) 8103
  24. DEFINE add____$i32,0x32(%eax) 8180
  25. DEFINE add____$i32,0x32(%ebp) 8185
  26. DEFINE add____$i8,%eax 83c0
  27. DEFINE add____$i8,%ebx 83c3
  28. DEFINE add____$i8,%esp 83c4
  29. DEFINE add____$i8,(%eax) 8300
  30. DEFINE add____$i8,(%ebx) 8303
  31. DEFINE add____$i8,0x32 8305
  32. DEFINE add____$i8,0x32(%eax) 8380
  33. DEFINE add____$i8,0x32(%ebp) 8385
  34. DEFINE add____$i8,0x8(%eax) 8340
  35. DEFINE add____$i8,0x8(%ebp) 8345
  36. DEFINE add____%eax,%eax 01c0
  37. DEFINE add____%ebp,%eax 01e8
  38. DEFINE add____%ebx,%eax 01d8
  39. DEFINE add____%ebx,%ebx 01db
  40. DEFINE addb___$i8,(%eax) 8000
  41. DEFINE addb___$i8,(%ebx) 8003
  42. DEFINE addw___$i8,(%eax) 668100
  43. DEFINE addw___$i8,(%ebx) 668103
  44. DEFINE and____$i32,%eax 25
  45. DEFINE and____$i32,%ebx 81e3
  46. DEFINE and____%ebx,%eax 21d8
  47. DEFINE call32 e8
  48. DEFINE call___*%eax ffd0
  49. DEFINE call___*%ebx ffd3
  50. DEFINE cltd 99
  51. DEFINE cmp____$0x32,%eax 3d
  52. DEFINE cmp____$i32,%eax 3d
  53. DEFINE cmp____$i8,%eax 83f8
  54. DEFINE cmp____$i8,%ebx 81fb
  55. DEFINE div___%ebx f7f3
  56. DEFINE hlt f4
  57. DEFINE idiv___%ebx f7fb
  58. DEFINE int cd
  59. DEFINE int____$0x80 cd80
  60. DEFINE ja32 0f87
  61. DEFINE jae32 0f83
  62. DEFINE jb32 0f82
  63. DEFINE jbe32 0f86
  64. DEFINE je32 0f84
  65. DEFINE je8 74
  66. DEFINE jg32 0f8f
  67. DEFINE jge32 0f8d
  68. DEFINE jl32 0f8c
  69. DEFINE jle32 0f8e
  70. DEFINE jmp32 e9
  71. DEFINE jmp____*%ebx ffe3
  72. DEFINE jne32 0f85
  73. DEFINE lahf 9f
  74. DEFINE lea____0x32(%ebp),%eax 8d85
  75. DEFINE lea____0x8(%ebp),%eax 8d45
  76. DEFINE leave c9
  77. DEFINE mov____$i32,%eax b8
  78. DEFINE mov____$i32,%ebx bb
  79. DEFINE mov____$i32,(%eax) c700
  80. DEFINE mov____$i32,0x32 c705
  81. DEFINE mov____$i32,0x8(%eax) c740
  82. DEFINE mov____$i32,0x8(%ebp) c745
  83. DEFINE mov____$i8,%al b0
  84. DEFINE mov____$i8,%eax b0
  85. DEFINE mov____%al,(%ebx) 8803
  86. DEFINE mov____%al,0x8(%ebp) 8845
  87. DEFINE mov____%ax,(%ebx) 668903
  88. DEFINE mov____%ax,0x8(%ebp) 668945
  89. DEFINE mov____%bx,%bx 6689db
  90. DEFINE mov____%cl,(%ebx) 8a08
  91. DEFINE mov____%cx,(%ebx) 668b08
  92. DEFINE mov____%dl,(%eax) 8810
  93. DEFINE mov____%dl,0x8(%eax) 8850
  94. DEFINE mov____%eax,%ebx 89c3
  95. DEFINE mov____%eax,%ecx 89c1
  96. DEFINE mov____%eax,(%ebx) 8903
  97. DEFINE mov____%eax,0x32 a3
  98. DEFINE mov____%eax,0x32(%ebp) 8985
  99. DEFINE mov____%eax,0x8(%ebp) 8945
  100. DEFINE mov____%ebp,%eax 89e8
  101. DEFINE mov____%ebp,%ebx 89eb
  102. DEFINE mov____%ebx,%eax 89d8
  103. DEFINE mov____%ebx,%ecx 89d9
  104. DEFINE mov____%ebx,0x32 891d
  105. DEFINE mov____%ebx,0x32(%ebp) 899d
  106. DEFINE mov____%ebx,0x8(%ebp) 895d
  107. DEFINE mov____%ecx,(%ebx) 890b
  108. DEFINE mov____%edi,%ebp 89fd
  109. DEFINE mov____%edx,%eax 89d0
  110. DEFINE mov____%edx,%ebx 89d3
  111. DEFINE mov____%esp,%ebp 89e5
  112. DEFINE mov____%esp,%edi 89e7
  113. DEFINE mov____(%eax),%cl 8a08
  114. DEFINE mov____(%eax),%cx 668b08
  115. DEFINE mov____(%eax),%eax 8b00
  116. DEFINE mov____(%eax),%ecx 8b08
  117. DEFINE mov____(%ebx),%ebx 8b1b
  118. DEFINE mov____0x32(%eax),%eax 8b80
  119. DEFINE mov____0x32(%eax),%ebx 8b98
  120. DEFINE mov____0x32(%ebp),%eax 8b85
  121. DEFINE mov____0x32(%ebp),%ebx 8b9d
  122. DEFINE mov____0x32,%eax a1
  123. DEFINE mov____0x32,%ebx 8b1d
  124. DEFINE mov____0x8(%eax),%eax 8b40
  125. DEFINE mov____0x8(%eax),%ebx 8b58
  126. DEFINE mov____0x8(%ebp),%eax 8b45
  127. DEFINE mov____0x8(%ebp),%ebp 8b6d
  128. DEFINE mov____0x8(%ebp),%ebx 8b5d
  129. DEFINE mov____0x8(%ebp),%ecx 8b4d
  130. DEFINE mov____0x8(%ebp),%edi 8b7d
  131. DEFINE mov____0x8(%ebp),%edx 8b55
  132. DEFINE mov____0x8(%ebp),%esi 8b75
  133. DEFINE mov____0x8(%ebp),%esp 8b65
  134. DEFINE movb___%al,0x32 a2
  135. DEFINE movb___%bl,0x32 881d
  136. DEFINE movsbl_%al,%eax 0fbec0
  137. DEFINE movsbl_%bl,%ebx 0fbedb
  138. DEFINE movswl_%ax,%eax 0fbfc0
  139. DEFINE movswl_%bx,%ebx 0fbfdb
  140. DEFINE movw___%ax,0x32 66a3
  141. DEFINE movw___%bx,0x32 66891d
  142. DEFINE movzbl_%al,%eax 0fb6c0
  143. DEFINE movzbl_%bl,%ebx 0fb6db
  144. DEFINE movzbl_(%eax),%eax 0fb600
  145. DEFINE movzbl_(%ebx),%ebx 0fb61b
  146. DEFINE movzbl_0x32(%eax),%eax 0fb680
  147. DEFINE movzbl_0x8(%eax),%eax 0fb640
  148. DEFINE movzbl_0x8(%ebp),%eax 0fb645
  149. DEFINE movzwl_%ax,%eax 0fb7c0
  150. DEFINE movzwl_%bx,%ebx 0fb7db
  151. DEFINE movzwl_(%eax),%eax 0fb700
  152. DEFINE movzwl_(%ebx),%ebx 0fb71b
  153. DEFINE movzwl_0x32(%eax),%eax 0fb780
  154. DEFINE movzwl_0x32(%ebp),%eax 0fb785
  155. DEFINE movzwl_0x8(%eax),%eax 0fb740
  156. DEFINE mul____%ebx f7e3
  157. DEFINE mul_____%ebx f7e3
  158. DEFINE nop 90
  159. DEFINE not____%eax f7d0
  160. DEFINE not____%ebx f7d3
  161. DEFINE or_____%ebx,%eax 09d8
  162. DEFINE pop____%eax 58
  163. DEFINE pop____%ebx 5b
  164. DEFINE pop____%edx 5a
  165. DEFINE push___$i32 68
  166. DEFINE push___%eax 50
  167. DEFINE push___%ebp 55
  168. DEFINE push___%ebx 53
  169. DEFINE push___%edx 52
  170. DEFINE push___(%eax) ff30
  171. DEFINE push___0x32(%ebp) ffb5
  172. DEFINE push___0x8(%ebp) ff75
  173. DEFINE ret c3
  174. DEFINE sahf 9e
  175. DEFINE seta___%al 0f97c0
  176. DEFINE seta___%bl 0f97c3
  177. DEFINE setae__%al 0f93c0
  178. DEFINE setae__%bl 0f93c3
  179. DEFINE setb___%al 0f92c0
  180. DEFINE setb___%bl 0f92c3
  181. DEFINE setbe__%al 0f96c0
  182. DEFINE setbe__%bl 0f96c3
  183. DEFINE sete___%al 0f94c0
  184. DEFINE sete___%bl 0f94c3
  185. DEFINE setg___%al 0f9fc0
  186. DEFINE setg___%bl 0f9fc3
  187. DEFINE setge__%al 0f9dc0
  188. DEFINE setge__%bl 0f9dc3
  189. DEFINE setl___%al 0f9cc0
  190. DEFINE setl___%bl 0f9cc3
  191. DEFINE setle__%al 0f9ec0
  192. DEFINE setle__%bl 0f9ec3
  193. DEFINE setne__%al 0f95c0
  194. DEFINE setne__%bl 0f95c3
  195. DEFINE shl____$i8,%eax c1e0
  196. DEFINE shl____$i8,%ebx c1e3
  197. DEFINE shl____%cl,%eax d3e0
  198. DEFINE shl____%cl,%ebx d3e3
  199. DEFINE shr____%cl,%eax d3e8
  200. DEFINE sub____$8,%esp 83ec
  201. DEFINE sub____$i32,%esp 81ec
  202. DEFINE sub____%al,%dl 28d0
  203. DEFINE sub____%dl,%al 28c2
  204. DEFINE sub____%ebx,%eax 29d8
  205. DEFINE test___%al,%al 84c0
  206. DEFINE test___%eax,%eax 85c0
  207. DEFINE test___%ebx,%ebx 85db
  208. DEFINE xchg___%eax,%ebx 93
  209. DEFINE xchg___%eax,(%esp) 870424
  210. DEFINE xchg___%ebx,(%esp) 871c24
  211. DEFINE xor____$i32,%eax 35
  212. DEFINE xor____$i8,%ah 80f4
  213. DEFINE xor____%eax,%eax 31c0
  214. DEFINE xor____%ebx,%eax 31d8
  215. DEFINE xor____%ebx,%ebx 31db
  216. DEFINE xor____%edx,%edx 31d2
  217. # Enough for all of Mes + Mes C Libray when using all registers, i.e.,
  218. # non-reduced instruction set
  219. #DEFINE add____$i32,%ecx 81c1
  220. #DEFINE add____$i32,%edx 81c2
  221. #DEFINE add____$i32,%esi 81c6
  222. #DEFINE add____$i8,%ecx 83c1
  223. #DEFINE add____$i8,%edx 83c2
  224. #DEFINE add____$i8,%esi 83c6
  225. #DEFINE add____$i8,(%ecx) 8301
  226. #DEFINE add____$i8,(%edx) 8302
  227. #DEFINE add____%ecx,%ebx 01cb
  228. #DEFINE add____%ecx,%ecx 01c9
  229. #DEFINE add____%edx,%eax 01d0
  230. #DEFINE add____%edx,%ecx 01d1
  231. #DEFINE add____%edx,%edx 01d2
  232. #DEFINE add____%esi,%edx 01f2
  233. #DEFINE and____$i32,%ecx 81e1
  234. #DEFINE and____$i32,%edx 81e2
  235. #DEFINE and____%edx,%eax 21d0
  236. #DEFINE and____(%edx),%eax 2302
  237. #DEFINE cmp____%edx,%eax 39d0
  238. #DEFINE idiv___%ecx f7f9
  239. #DEFINE lea____0x32(%ebp),%edx 8d95
  240. #DEFINE lea____0x8(%ebp),%edx 8d55
  241. #DEFINE mov____$i32,%ecx b9
  242. #DEFINE mov____$i32,%edx ba
  243. #DEFINE mov____$i32,%esi be
  244. #DEFINE mov____%al,(%edx) 8802
  245. #DEFINE mov____%al,0x8(%edx) 8842
  246. #DEFINE mov____%ax,(%edx) 668902
  247. #DEFINE mov____%ax,0x32(%edx) 668982
  248. #DEFINE mov____%ax,0x8(%edx) 668942
  249. #DEFINE mov____%bl,(%ecx) 8819
  250. #DEFINE mov____%eax,%edx 89c2
  251. #DEFINE mov____%eax,%esi 89c6
  252. #DEFINE mov____%eax,(%ecx) 8901
  253. #DEFINE mov____%eax,(%edx) 8902
  254. #DEFINE mov____%eax,0x32(%edx) 8982
  255. #DEFINE mov____%eax,0x8(%edx) 8942
  256. #DEFINE mov____%ebp,%ecx 89e9
  257. #DEFINE mov____%ebp,%edx 89ea
  258. #DEFINE mov____%ebp,%esi 89ee
  259. #DEFINE mov____%ebx,(%ecx) 8919
  260. #DEFINE mov____%ebx,0x8(%edx) 895a
  261. #DEFINE mov____%ecx,%eax 89c8
  262. #DEFINE mov____%ecx,%ecx 89c9
  263. #DEFINE mov____%ecx,%edx 89ca
  264. #DEFINE mov____%ecx,(%eax) 8908
  265. #DEFINE mov____%ecx,(%edx) 890a
  266. #DEFINE mov____%ecx,0x32(%ebp) 898d
  267. #DEFINE mov____%ecx,0x8(%ebp) 894d
  268. #DEFINE mov____%edi,%ebx 89fb
  269. #DEFINE mov____%edx,%ecx 89d1
  270. #DEFINE mov____%edx,(%eax) 8910
  271. #DEFINE mov____%edx,0x32(%ebp) 8995
  272. #DEFINE mov____%edx,0x8(%ebp) 8955
  273. #DEFINE mov____%esi,%eax 89f0
  274. #DEFINE mov____%esi,%ebx 89f3
  275. #DEFINE mov____(%ecx),%ecx 8b09
  276. #DEFINE mov____(%edx),%eax 8b02
  277. #DEFINE mov____(%edx),%ecx 8b0a
  278. #DEFINE mov____(%edx),%edx 8b12
  279. #DEFINE mov____0x32(%eax),%ecx 8b88
  280. #DEFINE mov____0x32(%ebp),%ecx 8b8d
  281. #DEFINE mov____0x32(%ebp),%edx 8b95
  282. #DEFINE mov____0x32,%ecx 8b0d
  283. #DEFINE mov____0x32,%edx 8b15
  284. #DEFINE mov____0x8(%eax),%ecx 8b48
  285. #DEFINE movsbl_%cl,%ecx 0fbec9
  286. #DEFINE movsbl_%dl,%edx 0fbed2
  287. #DEFINE movswl_%cx,%ecx 0fbfc9
  288. #DEFINE movzbl_%cl,%ecx 0fb6c9
  289. #DEFINE movzbl_%dl,%edx 0fb6d2
  290. #DEFINE movzbl_(%eax),%edx 0fb610
  291. #DEFINE movzbl_(%ecx),%ecx 0fb609
  292. #DEFINE movzbl_(%edx),%edx 0fb612
  293. #DEFINE movzwl_(%ecx),%ecx 0fb709
  294. #DEFINE mul____%ecx f7e1
  295. #DEFINE mul____%edi f7e7
  296. #DEFINE mul____%edx f7e2
  297. #DEFINE mul____%esi f7e6
  298. #DEFINE or_____%ecx,%ebx 09cb
  299. #DEFINE or_____%edx,%eax 09d0
  300. #DEFINE or_____(%edx),%eax 0b02
  301. #DEFINE pop____%ecx 59
  302. #DEFINE pop____%edi 5f
  303. #DEFINE push___%ecx 51
  304. #DEFINE push___%edi 57
  305. #DEFINE push___%esi 56
  306. #DEFINE shl____$i8,%ecx c1e1
  307. #DEFINE shl____$i8,%edx c1e2
  308. #DEFINE shl____%cl,%ecx d3e1
  309. #DEFINE sub____%eax,%edx 29c2
  310. #DEFINE sub____%ecx,%ebx 29cb
  311. #DEFINE sub____%edx,%eax 29d0
  312. #DEFINE sub____%edx,%ecx 29d1
  313. #DEFINE xchg___%ebx,%ecx 87d9
  314. #DEFINE xchg___%ecx,%edx 87ca
  315. #DEFINE xor____%ecx,%ecx 31c9
  316. #DEFINE xor____%edx,%eax 31d0
  317. # deprecated, remove after 0.18
  318. DEFINE sub____%esp,$i32 81ec
  319. DEFINE sub____%esp,$i8 83ec
  320. DEFINE SYS_exit 01000000
  321. DEFINE SYS_fork 02000000
  322. DEFINE SYS_read 03000000
  323. DEFINE SYS_rmdir 28000000
  324. DEFINE SYS_write 04000000
  325. DEFINE SYS_open 05000000
  326. DEFINE SYS_close 06000000
  327. DEFINE SYS_waitpid 07000000
  328. DEFINE SYS_unlink 0a000000
  329. DEFINE SYS_execve 0b000000
  330. DEFINE SYS_chmod 0f000000
  331. DEFINE SYS_lseek 13000000
  332. DEFINE SYS_access 21000000
  333. DEFINE SYS_brk 2d000000
  334. DEFINE SYS_ioctl 36000000
  335. DEFINE SYS_stat 6a000000
  336. DEFINE SYS_fsync 76000000
  337. DEFINE SYS_getcwd b7000000