PageRenderTime 65ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/test-016.asm

https://bitbucket.org/jadudm/eocs-assembler-test-generator
Assembly | 1193 lines | 1193 code | 0 blank | 0 comment | 17 complexity | ce3fa2f8795cba1e3d23ffa085ea5b4e MD5 | raw file
  1. // Test 016
  2. // Source:
  3. //
  4. // (if (> (if (< (* 0 7) 9) (if (> (if (< (* (let ((x67 5)) (- x67 x67)) 0) (+ (+ 6 6) (- 3 2))) (let ((x68 5)) 9) 8) (let ((x69 4)) (+ (let ((x70 7)) (* 3 (if (> 8 3) 4 x69))) x69))) (- 9 (- (if (< 8 3) 1 1) (if (< 7 7) 5 4))) 9) (let ((x71 2)) x71)) (- (if (> 6 1) (+ 4 (- 2 0)) 9) (let ((x72 6)) (let ((x73 8)) (if (< (if (> x72 (+ 4 (+ 5 7))) (+ x73 (let ((x74 0)) x74)) (let ((x75 2)) (let ((x76 1)) (let ((x77 4)) 3)))) (+ (* (let ((x78 0)) (let ((x79 4)) x73)) (+ 1 x73)) (* (if (> x72 3) x73 7) 6))) x73 (let ((x80 0)) x73)))))) 8 6)
  5. //
  6. // Result (in RAM0): 8
  7. // Generated on 20130309 at 19:54.
  8. // -----------------------------------//
  9. // Do test, leave result in D
  10. // Leave LHS in D; ends at bool-done949.
  11. // Do test, leave result in D
  12. // Leave LHS in D; ends at bool-done957.
  13. @0
  14. D=A
  15. @mullhs960
  16. M=D
  17. @7
  18. D=A
  19. @mulrhs961
  20. M=D
  21. // Set multctr958.
  22. @mulrhs961
  23. D=M
  24. @multctr958
  25. M=D
  26. // Set mulsum959.
  27. @0
  28. D=A
  29. @mulsum959
  30. M=D
  31. // Top of whiletop962
  32. (whiletop962)
  33. // Test; jump to whileend963 if zero.
  34. // Leave LHS in D; ends at bool-done968.
  35. @multctr958
  36. D=M
  37. // Move to lhs964
  38. @lhs964
  39. M=D
  40. // Leave RHS in D.
  41. @0
  42. D=A
  43. @rhs965
  44. M=D
  45. // Subtract LHS from RHS
  46. @lhs964
  47. D=M
  48. @rhs965
  49. // These instructions are prescient ... 20130308
  50. A=M
  51. D=A-D
  52. @one967
  53. // Jump and leave 1 in D if true.
  54. D;JLT
  55. @0
  56. D=A
  57. @bool-done968
  58. 0;JMP
  59. (one967)
  60. @1
  61. D=A
  62. // Done with boolean op.
  63. (bool-done968)
  64. @whileend963
  65. D;JEQ
  66. // Run body of whiletop962.
  67. // Set mulsum959.
  68. @mulsum959
  69. D=M
  70. @lhs969
  71. M=D
  72. @mullhs960
  73. D=M
  74. @rhs970
  75. M=D
  76. // Stick LHS result lhs969 in D
  77. @lhs969
  78. D=M
  79. // Stick RHS result rhs970 in A
  80. @rhs970
  81. A=M
  82. D=D+A
  83. @mulsum959
  84. M=D
  85. // Set multctr958.
  86. @multctr958
  87. D=M
  88. @lhs971
  89. M=D
  90. @1
  91. D=A
  92. @rhs972
  93. M=D
  94. // Stick LHS result lhs971 in D
  95. @lhs971
  96. D=M
  97. // Stick RHS result rhs972 in A
  98. @rhs972
  99. A=M
  100. D=D-A
  101. @multctr958
  102. M=D
  103. // Go to top of loop.
  104. @whiletop962
  105. 0;JMP
  106. // End of whiletop962.
  107. (whileend963)
  108. @mulsum959
  109. D=M
  110. // Move to lhs953
  111. @lhs953
  112. M=D
  113. // Leave RHS in D.
  114. @9
  115. D=A
  116. @rhs954
  117. M=D
  118. // Subtract LHS from RHS
  119. @lhs953
  120. D=M
  121. @rhs954
  122. // These instructions are prescient ... 20130308
  123. A=M
  124. D=A-D
  125. @one956
  126. // Jump and leave 1 in D if true.
  127. D;JGT
  128. @0
  129. D=A
  130. @bool-done957
  131. 0;JMP
  132. (one956)
  133. @1
  134. D=A
  135. // Done with boolean op.
  136. (bool-done957)
  137. // If the result was zero, we jump to iffalse951
  138. @iffalse951
  139. D;JEQ
  140. // Do test, leave result in D
  141. // Leave LHS in D; ends at bool-done980.
  142. // Do test, leave result in D
  143. // Leave LHS in D; ends at bool-done988.
  144. @5
  145. D=A
  146. @x67
  147. M=D
  148. @x67
  149. D=M
  150. @lhs993
  151. M=D
  152. @x67
  153. D=M
  154. @rhs994
  155. M=D
  156. // Stick LHS result lhs993 in D
  157. @lhs993
  158. D=M
  159. // Stick RHS result rhs994 in A
  160. @rhs994
  161. A=M
  162. D=D-A
  163. @mullhs991
  164. M=D
  165. @0
  166. D=A
  167. @mulrhs992
  168. M=D
  169. // Set multctr989.
  170. @mulrhs992
  171. D=M
  172. @multctr989
  173. M=D
  174. // Set mulsum990.
  175. @0
  176. D=A
  177. @mulsum990
  178. M=D
  179. // Top of whiletop995
  180. (whiletop995)
  181. // Test; jump to whileend996 if zero.
  182. // Leave LHS in D; ends at bool-done1001.
  183. @multctr989
  184. D=M
  185. // Move to lhs997
  186. @lhs997
  187. M=D
  188. // Leave RHS in D.
  189. @0
  190. D=A
  191. @rhs998
  192. M=D
  193. // Subtract LHS from RHS
  194. @lhs997
  195. D=M
  196. @rhs998
  197. // These instructions are prescient ... 20130308
  198. A=M
  199. D=A-D
  200. @one1000
  201. // Jump and leave 1 in D if true.
  202. D;JLT
  203. @0
  204. D=A
  205. @bool-done1001
  206. 0;JMP
  207. (one1000)
  208. @1
  209. D=A
  210. // Done with boolean op.
  211. (bool-done1001)
  212. @whileend996
  213. D;JEQ
  214. // Run body of whiletop995.
  215. // Set mulsum990.
  216. @mulsum990
  217. D=M
  218. @lhs1002
  219. M=D
  220. @mullhs991
  221. D=M
  222. @rhs1003
  223. M=D
  224. // Stick LHS result lhs1002 in D
  225. @lhs1002
  226. D=M
  227. // Stick RHS result rhs1003 in A
  228. @rhs1003
  229. A=M
  230. D=D+A
  231. @mulsum990
  232. M=D
  233. // Set multctr989.
  234. @multctr989
  235. D=M
  236. @lhs1004
  237. M=D
  238. @1
  239. D=A
  240. @rhs1005
  241. M=D
  242. // Stick LHS result lhs1004 in D
  243. @lhs1004
  244. D=M
  245. // Stick RHS result rhs1005 in A
  246. @rhs1005
  247. A=M
  248. D=D-A
  249. @multctr989
  250. M=D
  251. // Go to top of loop.
  252. @whiletop995
  253. 0;JMP
  254. // End of whiletop995.
  255. (whileend996)
  256. @mulsum990
  257. D=M
  258. // Move to lhs984
  259. @lhs984
  260. M=D
  261. // Leave RHS in D.
  262. @6
  263. D=A
  264. @lhs1008
  265. M=D
  266. @6
  267. D=A
  268. @rhs1009
  269. M=D
  270. // Stick LHS result lhs1008 in D
  271. @lhs1008
  272. D=M
  273. // Stick RHS result rhs1009 in A
  274. @rhs1009
  275. A=M
  276. D=D+A
  277. @lhs1006
  278. M=D
  279. @3
  280. D=A
  281. @lhs1010
  282. M=D
  283. @2
  284. D=A
  285. @rhs1011
  286. M=D
  287. // Stick LHS result lhs1010 in D
  288. @lhs1010
  289. D=M
  290. // Stick RHS result rhs1011 in A
  291. @rhs1011
  292. A=M
  293. D=D-A
  294. @rhs1007
  295. M=D
  296. // Stick LHS result lhs1006 in D
  297. @lhs1006
  298. D=M
  299. // Stick RHS result rhs1007 in A
  300. @rhs1007
  301. A=M
  302. D=D+A
  303. @rhs985
  304. M=D
  305. // Subtract LHS from RHS
  306. @lhs984
  307. D=M
  308. @rhs985
  309. // These instructions are prescient ... 20130308
  310. A=M
  311. D=A-D
  312. @one987
  313. // Jump and leave 1 in D if true.
  314. D;JGT
  315. @0
  316. D=A
  317. @bool-done988
  318. 0;JMP
  319. (one987)
  320. @1
  321. D=A
  322. // Done with boolean op.
  323. (bool-done988)
  324. // If the result was zero, we jump to iffalse982
  325. @iffalse982
  326. D;JEQ
  327. @5
  328. D=A
  329. @x68
  330. M=D
  331. @9
  332. D=A
  333. // Jump to the ifend983 when done with the true case.
  334. @ifend983
  335. 0;JMP
  336. (iffalse982)
  337. @8
  338. D=A
  339. (ifend983)
  340. // Move to lhs976
  341. @lhs976
  342. M=D
  343. // Leave RHS in D.
  344. @4
  345. D=A
  346. @x69
  347. M=D
  348. @7
  349. D=A
  350. @x70
  351. M=D
  352. @3
  353. D=A
  354. @mullhs1016
  355. M=D
  356. // Do test, leave result in D
  357. // Leave LHS in D; ends at bool-done1025.
  358. @8
  359. D=A
  360. // Move to lhs1021
  361. @lhs1021
  362. M=D
  363. // Leave RHS in D.
  364. @3
  365. D=A
  366. @rhs1022
  367. M=D
  368. // Subtract LHS from RHS
  369. @lhs1021
  370. D=M
  371. @rhs1022
  372. // These instructions are prescient ... 20130308
  373. A=M
  374. D=A-D
  375. @one1024
  376. // Jump and leave 1 in D if true.
  377. D;JLT
  378. @0
  379. D=A
  380. @bool-done1025
  381. 0;JMP
  382. (one1024)
  383. @1
  384. D=A
  385. // Done with boolean op.
  386. (bool-done1025)
  387. // If the result was zero, we jump to iffalse1019
  388. @iffalse1019
  389. D;JEQ
  390. @4
  391. D=A
  392. // Jump to the ifend1020 when done with the true case.
  393. @ifend1020
  394. 0;JMP
  395. (iffalse1019)
  396. @x69
  397. D=M
  398. (ifend1020)
  399. @mulrhs1017
  400. M=D
  401. // Set multctr1014.
  402. @mulrhs1017
  403. D=M
  404. @multctr1014
  405. M=D
  406. // Set mulsum1015.
  407. @0
  408. D=A
  409. @mulsum1015
  410. M=D
  411. // Top of whiletop1026
  412. (whiletop1026)
  413. // Test; jump to whileend1027 if zero.
  414. // Leave LHS in D; ends at bool-done1032.
  415. @multctr1014
  416. D=M
  417. // Move to lhs1028
  418. @lhs1028
  419. M=D
  420. // Leave RHS in D.
  421. @0
  422. D=A
  423. @rhs1029
  424. M=D
  425. // Subtract LHS from RHS
  426. @lhs1028
  427. D=M
  428. @rhs1029
  429. // These instructions are prescient ... 20130308
  430. A=M
  431. D=A-D
  432. @one1031
  433. // Jump and leave 1 in D if true.
  434. D;JLT
  435. @0
  436. D=A
  437. @bool-done1032
  438. 0;JMP
  439. (one1031)
  440. @1
  441. D=A
  442. // Done with boolean op.
  443. (bool-done1032)
  444. @whileend1027
  445. D;JEQ
  446. // Run body of whiletop1026.
  447. // Set mulsum1015.
  448. @mulsum1015
  449. D=M
  450. @lhs1033
  451. M=D
  452. @mullhs1016
  453. D=M
  454. @rhs1034
  455. M=D
  456. // Stick LHS result lhs1033 in D
  457. @lhs1033
  458. D=M
  459. // Stick RHS result rhs1034 in A
  460. @rhs1034
  461. A=M
  462. D=D+A
  463. @mulsum1015
  464. M=D
  465. // Set multctr1014.
  466. @multctr1014
  467. D=M
  468. @lhs1035
  469. M=D
  470. @1
  471. D=A
  472. @rhs1036
  473. M=D
  474. // Stick LHS result lhs1035 in D
  475. @lhs1035
  476. D=M
  477. // Stick RHS result rhs1036 in A
  478. @rhs1036
  479. A=M
  480. D=D-A
  481. @multctr1014
  482. M=D
  483. // Go to top of loop.
  484. @whiletop1026
  485. 0;JMP
  486. // End of whiletop1026.
  487. (whileend1027)
  488. @mulsum1015
  489. D=M
  490. @lhs1012
  491. M=D
  492. @x69
  493. D=M
  494. @rhs1013
  495. M=D
  496. // Stick LHS result lhs1012 in D
  497. @lhs1012
  498. D=M
  499. // Stick RHS result rhs1013 in A
  500. @rhs1013
  501. A=M
  502. D=D+A
  503. @rhs977
  504. M=D
  505. // Subtract LHS from RHS
  506. @lhs976
  507. D=M
  508. @rhs977
  509. // These instructions are prescient ... 20130308
  510. A=M
  511. D=A-D
  512. @one979
  513. // Jump and leave 1 in D if true.
  514. D;JLT
  515. @0
  516. D=A
  517. @bool-done980
  518. 0;JMP
  519. (one979)
  520. @1
  521. D=A
  522. // Done with boolean op.
  523. (bool-done980)
  524. // If the result was zero, we jump to iffalse974
  525. @iffalse974
  526. D;JEQ
  527. @9
  528. D=A
  529. @lhs1037
  530. M=D
  531. // Do test, leave result in D
  532. // Leave LHS in D; ends at bool-done1048.
  533. @8
  534. D=A
  535. // Move to lhs1044
  536. @lhs1044
  537. M=D
  538. // Leave RHS in D.
  539. @3
  540. D=A
  541. @rhs1045
  542. M=D
  543. // Subtract LHS from RHS
  544. @lhs1044
  545. D=M
  546. @rhs1045
  547. // These instructions are prescient ... 20130308
  548. A=M
  549. D=A-D
  550. @one1047
  551. // Jump and leave 1 in D if true.
  552. D;JGT
  553. @0
  554. D=A
  555. @bool-done1048
  556. 0;JMP
  557. (one1047)
  558. @1
  559. D=A
  560. // Done with boolean op.
  561. (bool-done1048)
  562. // If the result was zero, we jump to iffalse1042
  563. @iffalse1042
  564. D;JEQ
  565. @1
  566. D=A
  567. // Jump to the ifend1043 when done with the true case.
  568. @ifend1043
  569. 0;JMP
  570. (iffalse1042)
  571. @1
  572. D=A
  573. (ifend1043)
  574. @lhs1039
  575. M=D
  576. // Do test, leave result in D
  577. // Leave LHS in D; ends at bool-done1056.
  578. @7
  579. D=A
  580. // Move to lhs1052
  581. @lhs1052
  582. M=D
  583. // Leave RHS in D.
  584. @7
  585. D=A
  586. @rhs1053
  587. M=D
  588. // Subtract LHS from RHS
  589. @lhs1052
  590. D=M
  591. @rhs1053
  592. // These instructions are prescient ... 20130308
  593. A=M
  594. D=A-D
  595. @one1055
  596. // Jump and leave 1 in D if true.
  597. D;JGT
  598. @0
  599. D=A
  600. @bool-done1056
  601. 0;JMP
  602. (one1055)
  603. @1
  604. D=A
  605. // Done with boolean op.
  606. (bool-done1056)
  607. // If the result was zero, we jump to iffalse1050
  608. @iffalse1050
  609. D;JEQ
  610. @5
  611. D=A
  612. // Jump to the ifend1051 when done with the true case.
  613. @ifend1051
  614. 0;JMP
  615. (iffalse1050)
  616. @4
  617. D=A
  618. (ifend1051)
  619. @rhs1040
  620. M=D
  621. // Stick LHS result lhs1039 in D
  622. @lhs1039
  623. D=M
  624. // Stick RHS result rhs1040 in A
  625. @rhs1040
  626. A=M
  627. D=D-A
  628. @rhs1038
  629. M=D
  630. // Stick LHS result lhs1037 in D
  631. @lhs1037
  632. D=M
  633. // Stick RHS result rhs1038 in A
  634. @rhs1038
  635. A=M
  636. D=D-A
  637. // Jump to the ifend975 when done with the true case.
  638. @ifend975
  639. 0;JMP
  640. (iffalse974)
  641. @9
  642. D=A
  643. (ifend975)
  644. // Jump to the ifend952 when done with the true case.
  645. @ifend952
  646. 0;JMP
  647. (iffalse951)
  648. @2
  649. D=A
  650. @x71
  651. M=D
  652. @x71
  653. D=M
  654. (ifend952)
  655. // Move to lhs945
  656. @lhs945
  657. M=D
  658. // Leave RHS in D.
  659. // Do test, leave result in D
  660. // Leave LHS in D; ends at bool-done1066.
  661. @6
  662. D=A
  663. // Move to lhs1062
  664. @lhs1062
  665. M=D
  666. // Leave RHS in D.
  667. @1
  668. D=A
  669. @rhs1063
  670. M=D
  671. // Subtract LHS from RHS
  672. @lhs1062
  673. D=M
  674. @rhs1063
  675. // These instructions are prescient ... 20130308
  676. A=M
  677. D=A-D
  678. @one1065
  679. // Jump and leave 1 in D if true.
  680. D;JLT
  681. @0
  682. D=A
  683. @bool-done1066
  684. 0;JMP
  685. (one1065)
  686. @1
  687. D=A
  688. // Done with boolean op.
  689. (bool-done1066)
  690. // If the result was zero, we jump to iffalse1060
  691. @iffalse1060
  692. D;JEQ
  693. @4
  694. D=A
  695. @lhs1067
  696. M=D
  697. @2
  698. D=A
  699. @lhs1069
  700. M=D
  701. @0
  702. D=A
  703. @rhs1070
  704. M=D
  705. // Stick LHS result lhs1069 in D
  706. @lhs1069
  707. D=M
  708. // Stick RHS result rhs1070 in A
  709. @rhs1070
  710. A=M
  711. D=D-A
  712. @rhs1068
  713. M=D
  714. // Stick LHS result lhs1067 in D
  715. @lhs1067
  716. D=M
  717. // Stick RHS result rhs1068 in A
  718. @rhs1068
  719. A=M
  720. D=D+A
  721. // Jump to the ifend1061 when done with the true case.
  722. @ifend1061
  723. 0;JMP
  724. (iffalse1060)
  725. @9
  726. D=A
  727. (ifend1061)
  728. @lhs1057
  729. M=D
  730. @6
  731. D=A
  732. @x72
  733. M=D
  734. @8
  735. D=A
  736. @x73
  737. M=D
  738. // Do test, leave result in D
  739. // Leave LHS in D; ends at bool-done1078.
  740. // Do test, leave result in D
  741. // Leave LHS in D; ends at bool-done1086.
  742. @x72
  743. D=M
  744. // Move to lhs1082
  745. @lhs1082
  746. M=D
  747. // Leave RHS in D.
  748. @4
  749. D=A
  750. @lhs1087
  751. M=D
  752. @5
  753. D=A
  754. @lhs1089
  755. M=D
  756. @7
  757. D=A
  758. @rhs1090
  759. M=D
  760. // Stick LHS result lhs1089 in D
  761. @lhs1089
  762. D=M
  763. // Stick RHS result rhs1090 in A
  764. @rhs1090
  765. A=M
  766. D=D+A
  767. @rhs1088
  768. M=D
  769. // Stick LHS result lhs1087 in D
  770. @lhs1087
  771. D=M
  772. // Stick RHS result rhs1088 in A
  773. @rhs1088
  774. A=M
  775. D=D+A
  776. @rhs1083
  777. M=D
  778. // Subtract LHS from RHS
  779. @lhs1082
  780. D=M
  781. @rhs1083
  782. // These instructions are prescient ... 20130308
  783. A=M
  784. D=A-D
  785. @one1085
  786. // Jump and leave 1 in D if true.
  787. D;JLT
  788. @0
  789. D=A
  790. @bool-done1086
  791. 0;JMP
  792. (one1085)
  793. @1
  794. D=A
  795. // Done with boolean op.
  796. (bool-done1086)
  797. // If the result was zero, we jump to iffalse1080
  798. @iffalse1080
  799. D;JEQ
  800. @x73
  801. D=M
  802. @lhs1091
  803. M=D
  804. @0
  805. D=A
  806. @x74
  807. M=D
  808. @x74
  809. D=M
  810. @rhs1092
  811. M=D
  812. // Stick LHS result lhs1091 in D
  813. @lhs1091
  814. D=M
  815. // Stick RHS result rhs1092 in A
  816. @rhs1092
  817. A=M
  818. D=D+A
  819. // Jump to the ifend1081 when done with the true case.
  820. @ifend1081
  821. 0;JMP
  822. (iffalse1080)
  823. @2
  824. D=A
  825. @x75
  826. M=D
  827. @1
  828. D=A
  829. @x76
  830. M=D
  831. @4
  832. D=A
  833. @x77
  834. M=D
  835. @3
  836. D=A
  837. (ifend1081)
  838. // Move to lhs1074
  839. @lhs1074
  840. M=D
  841. // Leave RHS in D.
  842. @0
  843. D=A
  844. @x78
  845. M=D
  846. @4
  847. D=A
  848. @x79
  849. M=D
  850. @x73
  851. D=M
  852. @mullhs1097
  853. M=D
  854. @1
  855. D=A
  856. @lhs1099
  857. M=D
  858. @x73
  859. D=M
  860. @rhs1100
  861. M=D
  862. // Stick LHS result lhs1099 in D
  863. @lhs1099
  864. D=M
  865. // Stick RHS result rhs1100 in A
  866. @rhs1100
  867. A=M
  868. D=D+A
  869. @mulrhs1098
  870. M=D
  871. // Set multctr1095.
  872. @mulrhs1098
  873. D=M
  874. @multctr1095
  875. M=D
  876. // Set mulsum1096.
  877. @0
  878. D=A
  879. @mulsum1096
  880. M=D
  881. // Top of whiletop1101
  882. (whiletop1101)
  883. // Test; jump to whileend1102 if zero.
  884. // Leave LHS in D; ends at bool-done1107.
  885. @multctr1095
  886. D=M
  887. // Move to lhs1103
  888. @lhs1103
  889. M=D
  890. // Leave RHS in D.
  891. @0
  892. D=A
  893. @rhs1104
  894. M=D
  895. // Subtract LHS from RHS
  896. @lhs1103
  897. D=M
  898. @rhs1104
  899. // These instructions are prescient ... 20130308
  900. A=M
  901. D=A-D
  902. @one1106
  903. // Jump and leave 1 in D if true.
  904. D;JLT
  905. @0
  906. D=A
  907. @bool-done1107
  908. 0;JMP
  909. (one1106)
  910. @1
  911. D=A
  912. // Done with boolean op.
  913. (bool-done1107)
  914. @whileend1102
  915. D;JEQ
  916. // Run body of whiletop1101.
  917. // Set mulsum1096.
  918. @mulsum1096
  919. D=M
  920. @lhs1108
  921. M=D
  922. @mullhs1097
  923. D=M
  924. @rhs1109
  925. M=D
  926. // Stick LHS result lhs1108 in D
  927. @lhs1108
  928. D=M
  929. // Stick RHS result rhs1109 in A
  930. @rhs1109
  931. A=M
  932. D=D+A
  933. @mulsum1096
  934. M=D
  935. // Set multctr1095.
  936. @multctr1095
  937. D=M
  938. @lhs1110
  939. M=D
  940. @1
  941. D=A
  942. @rhs1111
  943. M=D
  944. // Stick LHS result lhs1110 in D
  945. @lhs1110
  946. D=M
  947. // Stick RHS result rhs1111 in A
  948. @rhs1111
  949. A=M
  950. D=D-A
  951. @multctr1095
  952. M=D
  953. // Go to top of loop.
  954. @whiletop1101
  955. 0;JMP
  956. // End of whiletop1101.
  957. (whileend1102)
  958. @mulsum1096
  959. D=M
  960. @lhs1093
  961. M=D
  962. // Do test, leave result in D
  963. // Leave LHS in D; ends at bool-done1123.
  964. @x72
  965. D=M
  966. // Move to lhs1119
  967. @lhs1119
  968. M=D
  969. // Leave RHS in D.
  970. @3
  971. D=A
  972. @rhs1120
  973. M=D
  974. // Subtract LHS from RHS
  975. @lhs1119
  976. D=M
  977. @rhs1120
  978. // These instructions are prescient ... 20130308
  979. A=M
  980. D=A-D
  981. @one1122
  982. // Jump and leave 1 in D if true.
  983. D;JLT
  984. @0
  985. D=A
  986. @bool-done1123
  987. 0;JMP
  988. (one1122)
  989. @1
  990. D=A
  991. // Done with boolean op.
  992. (bool-done1123)
  993. // If the result was zero, we jump to iffalse1117
  994. @iffalse1117
  995. D;JEQ
  996. @x73
  997. D=M
  998. // Jump to the ifend1118 when done with the true case.
  999. @ifend1118
  1000. 0;JMP
  1001. (iffalse1117)
  1002. @7
  1003. D=A
  1004. (ifend1118)
  1005. @mullhs1114
  1006. M=D
  1007. @6
  1008. D=A
  1009. @mulrhs1115
  1010. M=D
  1011. // Set multctr1112.
  1012. @mulrhs1115
  1013. D=M
  1014. @multctr1112
  1015. M=D
  1016. // Set mulsum1113.
  1017. @0
  1018. D=A
  1019. @mulsum1113
  1020. M=D
  1021. // Top of whiletop1124
  1022. (whiletop1124)
  1023. // Test; jump to whileend1125 if zero.
  1024. // Leave LHS in D; ends at bool-done1130.
  1025. @multctr1112
  1026. D=M
  1027. // Move to lhs1126
  1028. @lhs1126
  1029. M=D
  1030. // Leave RHS in D.
  1031. @0
  1032. D=A
  1033. @rhs1127
  1034. M=D
  1035. // Subtract LHS from RHS
  1036. @lhs1126
  1037. D=M
  1038. @rhs1127
  1039. // These instructions are prescient ... 20130308
  1040. A=M
  1041. D=A-D
  1042. @one1129
  1043. // Jump and leave 1 in D if true.
  1044. D;JLT
  1045. @0
  1046. D=A
  1047. @bool-done1130
  1048. 0;JMP
  1049. (one1129)
  1050. @1
  1051. D=A
  1052. // Done with boolean op.
  1053. (bool-done1130)
  1054. @whileend1125
  1055. D;JEQ
  1056. // Run body of whiletop1124.
  1057. // Set mulsum1113.
  1058. @mulsum1113
  1059. D=M
  1060. @lhs1131
  1061. M=D
  1062. @mullhs1114
  1063. D=M
  1064. @rhs1132
  1065. M=D
  1066. // Stick LHS result lhs1131 in D
  1067. @lhs1131
  1068. D=M
  1069. // Stick RHS result rhs1132 in A
  1070. @rhs1132
  1071. A=M
  1072. D=D+A
  1073. @mulsum1113
  1074. M=D
  1075. // Set multctr1112.
  1076. @multctr1112
  1077. D=M
  1078. @lhs1133
  1079. M=D
  1080. @1
  1081. D=A
  1082. @rhs1134
  1083. M=D
  1084. // Stick LHS result lhs1133 in D
  1085. @lhs1133
  1086. D=M
  1087. // Stick RHS result rhs1134 in A
  1088. @rhs1134
  1089. A=M
  1090. D=D-A
  1091. @multctr1112
  1092. M=D
  1093. // Go to top of loop.
  1094. @whiletop1124
  1095. 0;JMP
  1096. // End of whiletop1124.
  1097. (whileend1125)
  1098. @mulsum1113
  1099. D=M
  1100. @rhs1094
  1101. M=D
  1102. // Stick LHS result lhs1093 in D
  1103. @lhs1093
  1104. D=M
  1105. // Stick RHS result rhs1094 in A
  1106. @rhs1094
  1107. A=M
  1108. D=D+A
  1109. @rhs1075
  1110. M=D
  1111. // Subtract LHS from RHS
  1112. @lhs1074
  1113. D=M
  1114. @rhs1075
  1115. // These instructions are prescient ... 20130308
  1116. A=M
  1117. D=A-D
  1118. @one1077
  1119. // Jump and leave 1 in D if true.
  1120. D;JGT
  1121. @0
  1122. D=A
  1123. @bool-done1078
  1124. 0;JMP
  1125. (one1077)
  1126. @1
  1127. D=A
  1128. // Done with boolean op.
  1129. (bool-done1078)
  1130. // If the result was zero, we jump to iffalse1072
  1131. @iffalse1072
  1132. D;JEQ
  1133. @x73
  1134. D=M
  1135. // Jump to the ifend1073 when done with the true case.
  1136. @ifend1073
  1137. 0;JMP
  1138. (iffalse1072)
  1139. @0
  1140. D=A
  1141. @x80
  1142. M=D
  1143. @x73
  1144. D=M
  1145. (ifend1073)
  1146. @rhs1058
  1147. M=D
  1148. // Stick LHS result lhs1057 in D
  1149. @lhs1057
  1150. D=M
  1151. // Stick RHS result rhs1058 in A
  1152. @rhs1058
  1153. A=M
  1154. D=D-A
  1155. @rhs946
  1156. M=D
  1157. // Subtract LHS from RHS
  1158. @lhs945
  1159. D=M
  1160. @rhs946
  1161. // These instructions are prescient ... 20130308
  1162. A=M
  1163. D=A-D
  1164. @one948
  1165. // Jump and leave 1 in D if true.
  1166. D;JLT
  1167. @0
  1168. D=A
  1169. @bool-done949
  1170. 0;JMP
  1171. (one948)
  1172. @1
  1173. D=A
  1174. // Done with boolean op.
  1175. (bool-done949)
  1176. // If the result was zero, we jump to iffalse943
  1177. @iffalse943
  1178. D;JEQ
  1179. @8
  1180. D=A
  1181. // Jump to the ifend944 when done with the true case.
  1182. @ifend944
  1183. 0;JMP
  1184. (iffalse943)
  1185. @6
  1186. D=A
  1187. (ifend944)
  1188. // Move D register to RAM[0] for final result.
  1189. @0
  1190. M=D
  1191. (ENDOFLINE)
  1192. @ENDOFLINE
  1193. 0;JMP