exam.e 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. mes 2,2,2 ; wordsize 2, pointersize 2
  2. .1
  3. rom 't.p\000' ; the name of the source file
  4. hol 552,-32768,0 ; externals and buf occupy 552 bytes
  5. exp $sum ; sum can be called from other modules
  6. pro $sum,2 ; procedure sum; 2 bytes local storage
  7. lin 8 ; code from source line 8
  8. ldl 0 ; load two locals ( a and b )
  9. adi 2 ; add them
  10. ret 2 ; return the result
  11. end 2 ; end of procedure ( still two bytes local storage )
  12. .2
  13. rom 1,99,2 ; descriptor of array a[]
  14. exp $test ; the compiler exports all level 0 procedures
  15. pro $test,226 ; procedure test, 226 bytes local storage
  16. .3
  17. rom 4.8F8 ; assemble Floating point 4.8 (8 bytes) in
  18. .4 ; global storage
  19. rom 0.5F8 ; same for 0.5
  20. mes 3,-226,2,2 ; compiler temporary not referenced indirect
  21. mes 3,-24,2,0 ; the same is true for i, j, b and c in test
  22. mes 3,-22,2,0
  23. mes 3,-4,2,0
  24. mes 3,-2,2,0
  25. mes 3,-20,8,0 ; and for x and y
  26. mes 3,-12,8,0
  27. lin 20 ; maintain source line number
  28. loc 1
  29. stl -4 ; j := 1
  30. lni ; was lin 21 prior to optimization
  31. lol -4
  32. loc 3
  33. mli 2
  34. loc 6
  35. adi 2
  36. stl -2 ; i := 3 * j + 6
  37. lni ; was lin 22 prior to optimization
  38. lae .3
  39. loi 8
  40. lal -12
  41. sti 8 ; x := 4.8
  42. lni ; was lin 23 prior to optimization
  43. lal -12
  44. loi 8
  45. lae .4
  46. loi 8
  47. dvf 8
  48. lal -20
  49. sti 8 ; y := x / 0.5
  50. lni ; was lin 24 prior to optimization
  51. loc 1
  52. stl -22 ; b := true
  53. lni ; was lin 25 prior to optimization
  54. loc 122
  55. stl -24 ; c := 'z'
  56. lni ; was lin 26 prior to optimization
  57. loc 1
  58. stl -2 ; for i:= 1
  59. 2
  60. lol -2
  61. dup 2
  62. mli 2 ; i*i
  63. lal -224
  64. lol -2
  65. lae .2
  66. sar 2 ; a[i] :=
  67. lol -2
  68. loc 100
  69. beq *3 ; to 100 do
  70. inl -2 ; increment i and loop
  71. bra *2
  72. 3
  73. lin 27
  74. lol -4
  75. loc 27
  76. adi 2 ; j + 27
  77. sil 0 ; r.r1 :=
  78. lni ; was lin 28 prior to optimization
  79. lol -22 ; b
  80. lol 0
  81. stf 10 ; r.r3 :=
  82. lni ; was lin 29 prior to optimization
  83. lal -20
  84. loi 16
  85. adf 8 ; x + y
  86. lol 0
  87. adp 2
  88. sti 8 ; r.r2 :=
  89. lni ; was lin 30 prior to optimization
  90. lal -224
  91. lol -4
  92. lae .2
  93. lar 2 ; a[j]
  94. lil 0 ; r.r1
  95. cal $sum ; call now
  96. asp 4 ; remove parameters from stack
  97. lfr 2 ; get function result
  98. stl -2 ; i :=
  99. 4
  100. lin 31
  101. lol -2
  102. zle *5 ; while i > 0 do
  103. lol -4
  104. lil 0
  105. adi 2
  106. stl -4 ; j := j + r.r1
  107. del -2 ; i := i - 1
  108. bra *4 ; loop
  109. 5
  110. lin 32
  111. lol 0
  112. stl -226 ; make copy of address of r
  113. lol -22
  114. lol -226
  115. stf 10 ; r3 := b
  116. lal -20
  117. loi 16
  118. adf 8
  119. lol -226
  120. adp 2
  121. sti 8 ; r2 := x + y
  122. loc 0
  123. sil -226 ; r1 := 0
  124. lin 34 ; note the absence of the unnecessary jump
  125. lae 22 ; address of output structure
  126. lol -4
  127. cal $_wri ; write integer with default width
  128. asp 4 ; pop parameters
  129. lae 22
  130. lol -2
  131. loc 6
  132. cal $_wsi ; write integer width 6
  133. asp 6
  134. lae 22
  135. lal -12
  136. loi 8
  137. loc 9
  138. loc 3
  139. cal $_wrf ; write fixed format real, width 9, precision 3
  140. asp 14
  141. lae 22
  142. lol -22
  143. cal $_wrb ; write boolean, default width
  144. asp 4
  145. lae 22
  146. cal $_wln ; writeln
  147. asp 2
  148. ret 0 ; return, no result
  149. end 226
  150. exp $_main
  151. pro $_main,0 ; main program
  152. .6
  153. con 2,-1,22 ; description of external files
  154. .5
  155. rom 15.96F8
  156. fil .1 ; maintain source file name
  157. lae .6 ; description of external files
  158. lae 0 ; base of hol area to relocate buffer addresses
  159. cal $_ini ; initialize files, etc...
  160. asp 4
  161. lin 37
  162. lae .5
  163. loi 8
  164. lae 2
  165. sti 8 ; x := 15.9
  166. lni ; was lin 38 prior to optimization
  167. loc 99
  168. ste 0 ; mi := 99
  169. lni ; was lin 39 prior to optimization
  170. lae 10 ; address of r
  171. cal $test
  172. asp 2
  173. loc 0 ; normal exit
  174. cal $_hlt ; cleanup and finish
  175. asp 2
  176. end 0
  177. mes 4,40 ; length of source file is 40 lines
  178. mes 5 ; reals were used