Guest User

Untitled

a guest
Mar 17th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.01 KB | None | 0 0
  1. .globl mod
  2. mod: pushl %ebp # Start function mod
  3. movl %esp,%ebp
  4. movl 8(%ebp),%eax # x
  5. pushl %eax
  6. movl 8(%ebp),%eax # x
  7. pushl %eax
  8. movl 12(%ebp),%eax # y
  9. movl %eax,%ecx
  10. popl %eax
  11. cdq
  12. idivl %ecx # Compute /
  13. pushl %eax
  14. movl 12(%ebp),%eax # y
  15. movl %eax,%ecx
  16. popl %eax
  17. imull %ecx,%eax # Compute *
  18. movl %eax,%ecx
  19. popl %eax
  20. subl %ecx,%eax # Compute -
  21. jmp .exit$mod # return-statement
  22. .exit$mod:
  23. popl %ebp
  24. ret # End function mod
  25. .globl easter
  26. easter: pushl %ebp # Start function easter
  27. movl %esp,%ebp
  28. subl $80,%esp # Get 80 bytes local data space
  29. movl $19,%eax # 19
  30. pushl %eax # Push parameter #2
  31. movl 8(%ebp),%eax # y
  32. pushl %eax # Push parameter #1
  33. call mod # Call mod
  34. popl %ecx # Pop parameter #1
  35. popl %ecx # Pop parameter #2
  36. movl %eax,-4(%ebp) # a =
  37. movl 8(%ebp),%eax # y
  38. pushl %eax
  39. movl $100,%eax # 100
  40. movl %eax,%ecx
  41. popl %eax
  42. cdq
  43. idivl %ecx # Compute /
  44. movl %eax,-8(%ebp) # b =
  45. movl $100,%eax # 100
  46. pushl %eax # Push parameter #2
  47. movl 8(%ebp),%eax # y
  48. pushl %eax # Push parameter #1
  49. call mod # Call mod
  50. popl %ecx # Pop parameter #1
  51. popl %ecx # Pop parameter #2
  52. movl %eax,-12(%ebp) # c =
  53. movl -8(%ebp),%eax # b
  54. pushl %eax
  55. movl $4,%eax # 4
  56. movl %eax,%ecx
  57. popl %eax
  58. cdq
  59. idivl %ecx # Compute /
  60. movl %eax,-16(%ebp) # d =
  61. movl $4,%eax # 4
  62. pushl %eax # Push parameter #2
  63. movl -8(%ebp),%eax # b
  64. pushl %eax # Push parameter #1
  65. call mod # Call mod
  66. popl %ecx # Pop parameter #1
  67. popl %ecx # Pop parameter #2
  68. movl %eax,-20(%ebp) # e =
  69. movl -8(%ebp),%eax # b
  70. pushl %eax
  71. movl $8,%eax # 8
  72. movl %eax,%ecx
  73. popl %eax
  74. addl %ecx,%eax # Compute +
  75. pushl %eax
  76. movl $25,%eax # 25
  77. movl %eax,%ecx
  78. popl %eax
  79. cdq
  80. idivl %ecx # Compute /
  81. movl %eax,-24(%ebp) # f =
  82. movl -8(%ebp),%eax # b
  83. pushl %eax
  84. movl -24(%ebp),%eax # f
  85. movl %eax,%ecx
  86. popl %eax
  87. subl %ecx,%eax # Compute -
  88. pushl %eax
  89. movl $1,%eax # 1
  90. movl %eax,%ecx
  91. popl %eax
  92. addl %ecx,%eax # Compute +
  93. pushl %eax
  94. movl $3,%eax # 3
  95. movl %eax,%ecx
  96. popl %eax
  97. cdq
  98. idivl %ecx # Compute /
  99. movl %eax,-28(%ebp) # g =
  100. movl $30,%eax # 30
  101. pushl %eax # Push parameter #2
  102. movl $19,%eax # 19
  103. pushl %eax
  104. movl -4(%ebp),%eax # a
  105. movl %eax,%ecx
  106. popl %eax
  107. imull %ecx,%eax # Compute *
  108. pushl %eax
  109. movl -8(%ebp),%eax # b
  110. movl %eax,%ecx
  111. popl %eax
  112. addl %ecx,%eax # Compute +
  113. pushl %eax
  114. movl -16(%ebp),%eax # d
  115. movl %eax,%ecx
  116. popl %eax
  117. subl %ecx,%eax # Compute -
  118. pushl %eax
  119. movl -28(%ebp),%eax # g
  120. movl %eax,%ecx
  121. popl %eax
  122. subl %ecx,%eax # Compute -
  123. pushl %eax
  124. movl $15,%eax # 15
  125. movl %eax,%ecx
  126. popl %eax
  127. addl %ecx,%eax # Compute +
  128. pushl %eax # Push parameter #1
  129. call mod # Call mod
  130. popl %ecx # Pop parameter #1
  131. popl %ecx # Pop parameter #2
  132. movl %eax,-32(%ebp) # h =
  133. movl -12(%ebp),%eax # c
  134. pushl %eax
  135. movl $4,%eax # 4
  136. movl %eax,%ecx
  137. popl %eax
  138. cdq
  139. idivl %ecx # Compute /
  140. movl %eax,-36(%ebp) # i =
  141. movl $4,%eax # 4
  142. pushl %eax # Push parameter #2
  143. movl -12(%ebp),%eax # c
  144. pushl %eax # Push parameter #1
  145. call mod # Call mod
  146. popl %ecx # Pop parameter #1
  147. popl %ecx # Pop parameter #2
  148. movl %eax,-40(%ebp) # k =
  149. movl $7,%eax # 7
  150. pushl %eax # Push parameter #2
  151. movl $32,%eax # 32
  152. pushl %eax
  153. movl $2,%eax # 2
  154. pushl %eax
  155. movl -20(%ebp),%eax # e
  156. movl %eax,%ecx
  157. popl %eax
  158. imull %ecx,%eax # Compute *
  159. movl %eax,%ecx
  160. popl %eax
  161. addl %ecx,%eax # Compute +
  162. pushl %eax
  163. movl $2,%eax # 2
  164. pushl %eax
  165. movl -36(%ebp),%eax # i
  166. movl %eax,%ecx
  167. popl %eax
  168. imull %ecx,%eax # Compute *
  169. movl %eax,%ecx
  170. popl %eax
  171. addl %ecx,%eax # Compute +
  172. pushl %eax
  173. movl -32(%ebp),%eax # h
  174. movl %eax,%ecx
  175. popl %eax
  176. subl %ecx,%eax # Compute -
  177. pushl %eax
  178. movl -40(%ebp),%eax # k
  179. movl %eax,%ecx
  180. popl %eax
  181. subl %ecx,%eax # Compute -
  182. pushl %eax # Push parameter #1
  183. call mod # Call mod
  184. popl %ecx # Pop parameter #1
  185. popl %ecx # Pop parameter #2
  186. movl %eax,-44(%ebp) # l =
  187. movl -4(%ebp),%eax # a
  188. pushl %eax
  189. movl $11,%eax # 11
  190. pushl %eax
  191. movl -32(%ebp),%eax # h
  192. movl %eax,%ecx
  193. popl %eax
  194. imull %ecx,%eax # Compute *
  195. movl %eax,%ecx
  196. popl %eax
  197. addl %ecx,%eax # Compute +
  198. pushl %eax
  199. movl $22,%eax # 22
  200. pushl %eax
  201. movl -44(%ebp),%eax # l
  202. movl %eax,%ecx
  203. popl %eax
  204. imull %ecx,%eax # Compute *
  205. movl %eax,%ecx
  206. popl %eax
  207. addl %ecx,%eax # Compute +
  208. pushl %eax
  209. movl $451,%eax # 451
  210. movl %eax,%ecx
  211. popl %eax
  212. cdq
  213. idivl %ecx # Compute /
  214. movl %eax,-48(%ebp) # m =
  215. movl -32(%ebp),%eax # h
  216. pushl %eax
  217. movl -44(%ebp),%eax # l
  218. movl %eax,%ecx
  219. popl %eax
  220. addl %ecx,%eax # Compute +
  221. pushl %eax
  222. movl $7,%eax # 7
  223. pushl %eax
  224. movl -48(%ebp),%eax # m
  225. movl %eax,%ecx
  226. popl %eax
  227. imull %ecx,%eax # Compute *
  228. movl %eax,%ecx
  229. popl %eax
  230. subl %ecx,%eax # Compute -
  231. pushl %eax
  232. movl $114,%eax # 114
  233. movl %eax,%ecx
  234. popl %eax
  235. addl %ecx,%eax # Compute +
  236. pushl %eax
  237. movl $31,%eax # 31
  238. movl %eax,%ecx
  239. popl %eax
  240. cdq
  241. idivl %ecx # Compute /
  242. movl %eax,-52(%ebp) # month =
  243. movl $31,%eax # 31
  244. pushl %eax # Push parameter #2
  245. movl -32(%ebp),%eax # h
  246. pushl %eax
  247. movl -44(%ebp),%eax # l
  248. movl %eax,%ecx
  249. popl %eax
  250. addl %ecx,%eax # Compute +
  251. pushl %eax
  252. movl $7,%eax # 7
  253. pushl %eax
  254. movl -48(%ebp),%eax # m
  255. movl %eax,%ecx
  256. popl %eax
  257. imull %ecx,%eax # Compute *
  258. movl %eax,%ecx
  259. popl %eax
  260. subl %ecx,%eax # Compute -
  261. pushl %eax
  262. movl $114,%eax # 114
  263. movl %eax,%ecx
  264. popl %eax
  265. addl %ecx,%eax # Compute +
  266. pushl %eax # Push parameter #1
  267. call mod # Call mod
  268. popl %ecx # Pop parameter #1
  269. popl %ecx # Pop parameter #2
  270. pushl %eax
  271. movl $1,%eax # 1
  272. movl %eax,%ecx
  273. popl %eax
  274. addl %ecx,%eax # Compute +
  275. movl %eax,-76(%ebp) # day =
  276. # Start if-statement
  277. movl -52(%ebp),%eax # month
  278. pushl %eax
  279. movl $3,%eax # 3
  280. popl %ecx
  281. cmpl %eax,%ecx
  282. sete %al # Test ==
  283. movzbl %al,%eax
  284. cmpl $0,%eax
  285. je .L0002
  286. movl $0,%eax # 0
  287. pushl %eax
  288. movl $77,%eax # 77
  289. leal -72(%ebp),%edx # m_name[...] =
  290. popl %ecx
  291. movl %eax,(%edx,%ecx,4)
  292. movl $1,%eax # 1
  293. pushl %eax
  294. movl $97,%eax # 97
  295. leal -72(%ebp),%edx # m_name[...] =
  296. popl %ecx
  297. movl %eax,(%edx,%ecx,4)
  298. movl $2,%eax # 2
  299. pushl %eax
  300. movl $114,%eax # 114
  301. leal -72(%ebp),%edx # m_name[...] =
  302. popl %ecx
  303. movl %eax,(%edx,%ecx,4)
  304. movl $3,%eax # 3
  305. pushl %eax
  306. movl $99,%eax # 99
  307. leal -72(%ebp),%edx # m_name[...] =
  308. popl %ecx
  309. movl %eax,(%edx,%ecx,4)
  310. movl $4,%eax # 4
  311. pushl %eax
  312. movl $104,%eax # 104
  313. leal -72(%ebp),%edx # m_name[...] =
  314. popl %ecx
  315. movl %eax,(%edx,%ecx,4)
  316. jmp .L0001
  317. .L0002: # else-part
  318. movl $0,%eax # 0
  319. pushl %eax
  320. movl $65,%eax # 65
  321. leal -72(%ebp),%edx # m_name[...] =
  322. popl %ecx
  323. movl %eax,(%edx,%ecx,4)
  324. movl $1,%eax # 1
  325. pushl %eax
  326. movl $112,%eax # 112
  327. leal -72(%ebp),%edx # m_name[...] =
  328. popl %ecx
  329. movl %eax,(%edx,%ecx,4)
  330. movl $2,%eax # 2
  331. pushl %eax
  332. movl $114,%eax # 114
  333. leal -72(%ebp),%edx # m_name[...] =
  334. popl %ecx
  335. movl %eax,(%edx,%ecx,4)
  336. movl $3,%eax # 3
  337. pushl %eax
  338. movl $105,%eax # 105
  339. leal -72(%ebp),%edx # m_name[...] =
  340. popl %ecx
  341. movl %eax,(%edx,%ecx,4)
  342. movl $4,%eax # 4
  343. pushl %eax
  344. movl $108,%eax # 108
  345. leal -72(%ebp),%edx # m_name[...] =
  346. popl %ecx
  347. movl %eax,(%edx,%ecx,4)
  348. .L0001: # End if-statement
  349. movl -76(%ebp),%eax # day
  350. pushl %eax # Push parameter #1
  351. call putint # Call putint
  352. popl %ecx # Pop parameter #1
  353. movl $32,%eax # 32
  354. pushl %eax # Push parameter #1
  355. call putchar # Call putchar
  356. popl %ecx # Pop parameter #1
  357. movl $0,%eax # 0
  358. movl %eax,-80(%ebp) # ix =
  359. .L0003: # Start for-statement
  360. movl -80(%ebp),%eax # ix
  361. pushl %eax
  362. movl $5,%eax # 5
  363. popl %ecx
  364. cmpl %eax,%ecx
  365. setl %al # Test <
  366. movzbl %al,%eax
  367. cmpl $0,%eax
  368. je .L0004
  369. movl -80(%ebp),%eax # ix
  370. leal -72(%ebp),%edx # m_name[...]
  371. movl (%edx,%eax,4),%eax
  372. pushl %eax # Push parameter #1
  373. call putchar # Call putchar
  374. popl %ecx # Pop parameter #1
  375. movl -80(%ebp),%eax # ix
  376. pushl %eax
  377. movl $1,%eax # 1
  378. movl %eax,%ecx
  379. popl %eax
  380. addl %ecx,%eax # Compute +
  381. movl %eax,-80(%ebp) # ix =
  382. jmp .L0003
  383. .L0004: # End for-statement
  384. .exit$easter:
  385. addl $80,%esp # Release local data space
  386. popl %ebp
  387. ret # End function easter
  388. .globl main
  389. main: pushl %ebp # Start function main
  390. movl %esp,%ebp
  391. subl $4,%esp # Get 4 bytes local data space
  392. movl $2010,%eax # 2010
  393. movl %eax,-4(%ebp) # y =
  394. .L0005: # Start for-statement
  395. movl -4(%ebp),%eax # y
  396. pushl %eax
  397. movl $2020,%eax # 2020
  398. popl %ecx
  399. cmpl %eax,%ecx
  400. setle %al # Test <=
  401. movzbl %al,%eax
  402. cmpl $0,%eax
  403. je .L0006
  404. movl -4(%ebp),%eax # y
  405. pushl %eax # Push parameter #1
  406. call easter # Call easter
  407. popl %ecx # Pop parameter #1
  408. movl $32,%eax # 32
  409. pushl %eax # Push parameter #1
  410. call putchar # Call putchar
  411. popl %ecx # Pop parameter #1
  412. movl -4(%ebp),%eax # y
  413. pushl %eax # Push parameter #1
  414. call putint # Call putint
  415. popl %ecx # Pop parameter #1
  416. movl $10,%eax # 10
  417. pushl %eax # Push parameter #1
  418. call putchar # Call putchar
  419. popl %ecx # Pop parameter #1
  420. movl -4(%ebp),%eax # y
  421. pushl %eax
  422. movl $1,%eax # 1
  423. movl %eax,%ecx
  424. popl %eax
  425. addl %ecx,%eax # Compute +
  426. movl %eax,-4(%ebp) # y =
  427. jmp .L0005
  428. .L0006: # End for-statement
  429. .exit$main:
  430. addl $4,%esp # Release local data space
  431. popl %ebp
  432. ret # End function main
Add Comment
Please, Sign In to add comment