int._old_ 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. .insrt clusys;alpha >
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;;;; the integer (int) cluster ;;;;
  4. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5. cluster int,ttype(tint),0,[]
  6. edesc e$1,overflow
  7. edesc e$2,zero_divide
  8. proc i.add,[x,y]
  9. tcheck x(er),tint
  10. tcheck y(er),tint
  11. hrre n0,x(er)
  12. hrre n1,y(er)
  13. add n0,n1
  14. hrre n1,n0
  15. $if camn n0,n1
  16. $then signal e$1
  17. $fi
  18. stypi rr,(tint)
  19. hrr rr,n0
  20. $rtn rr
  21. corp int$add,[x,y]
  22. proc i.sub,[x,y]
  23. tcheck x(er),tint
  24. tcheck y(er),tint
  25. hrre n0,x(er)
  26. hrre n1,y(er)
  27. sub n0,n1
  28. hrre n1,n0
  29. $if camn n0,n1
  30. $then signal e$1
  31. $fi
  32. stypi rr,(tint)
  33. hrr rr,n0
  34. $rtn rr
  35. corp int$sub,[x,y]
  36. proc i.mul,[x,y]
  37. tcheck x(er),tint
  38. tcheck y(er),tint
  39. hrre n0,x(er)
  40. hrre n1,y(er)
  41. mul n0,n1
  42. hrre n0,n1
  43. $if camn n0,n1
  44. $then signal e$1
  45. $fi
  46. stypi rr,(tint)
  47. hrr rr,n0
  48. $rtn rr
  49. corp int$mul,[x,y]
  50. proc i.div,[x,y]
  51. tcheck x(er),tint
  52. tcheck y(er),tint
  53. hrre n0,x(er)
  54. hrre n1,y(er)
  55. $if skipe n1
  56. $then signal e$2,1,[x(er)]
  57. $fi
  58. idiv n0,n1
  59. hrre n1,n0
  60. $if camn n0,n1
  61. $then signal e$1
  62. $fi
  63. stypi rr,(tint)
  64. hrr rr,n0
  65. $rtn rr
  66. corp int$div,[x,y]
  67. proc i.mod,[x,y]
  68. tcheck x(er),tint
  69. tcheck y(er),tint
  70. hrre n0,x(er)
  71. hrre n2,y(er)
  72. $if skipe n2
  73. $then signal e$2,1,[x(er)]
  74. $fi
  75. idiv n0,n2
  76. hrre n0,n1
  77. $if camn n0,n1
  78. $then signal e$1
  79. $fi
  80. stypi rr,(tint)
  81. hrr rr,n0
  82. $rtn rr
  83. corp int$mod,[x,y]
  84. proc i.neg,[x]
  85. tcheck x(er),tint
  86. hrre n0,x(er)
  87. movn n0,n0
  88. hrre n1,n0
  89. $if camn n1,n0
  90. $then signal e$1
  91. $fi
  92. stypi n1,(tint)
  93. $rtn n1
  94. corp int$neg,[x]
  95. proc i.abs,[x]
  96. tcheck x(er),tint
  97. hrre n0,x(er)
  98. $if skipge n0
  99. $then movn n0,n0
  100. $if skipl n0
  101. $then signal e$1
  102. $fi
  103. $fi
  104. stypi n0,(tint)
  105. $rtn n0
  106. corp int$abs,[x]
  107. proc i.eq,[x,y]
  108. tcheck x(er),tint
  109. tcheck y(er),tint
  110. move n0,x(er)
  111. $if came n0,y(er)
  112. $then $rtnc $true
  113. $fi
  114. $rtnc $false
  115. corp int$equal,[x,y]
  116. proc i.gt,[x,y]
  117. tcheck x(er),tint
  118. tcheck y(er),tint
  119. hrre n0,x(er)
  120. hrre n1,y(er)
  121. $if camg n0,n1
  122. $then $rtnc $true
  123. $else $rtnc $false
  124. $fi
  125. corp int$gt,[x,y]
  126. proc i.lt,[x,y]
  127. tcheck x(er),tint
  128. tcheck y(er),tint
  129. hrre n0,x(er)
  130. hrre n1,y(er)
  131. $if caml n0,n1
  132. $then $rtnc $true
  133. $else $rtnc $false
  134. $fi
  135. corp int$lt,[x,y]
  136. proc i.i2s,[i]
  137. cshift==chsize
  138. tcheck i(er),tint
  139. hrre n0,i(er)
  140. $if skipl n0
  141. cail n0,10. ; for single character
  142. $then stypi n0,(tstr) ; a quick return is possible
  143. addi n0,60
  144. $rtn n0
  145. $fi
  146. movm n0,n0 ; otherwise get the magnitude of the number
  147. movei n2,0 ; clear the char accumulators
  148. movei n3,0
  149. movei r0,0 ; and the counter
  150. i2s1==.-proc$
  151. idivi n0,10. ; get a low order
  152. addi n3,60(n1) ; char into n3
  153. rotc n2,-cshift ; and shift it around in <n2,n3>
  154. aos r0 ; bump the count
  155. jumpn n0,i2s1(pr) ; and loop until number is done
  156. hrre n0,i(er)
  157. jumpge n0,i2s2(pr) ; if we need a - sign
  158. addi n3,"- ; then shift that in
  159. rotc n2,-cshift
  160. aos r0 ; and maintain the count
  161. i2s2==.-proc$
  162. hrli r0,(tsrep) ; get the code to fill with in r0
  163. movei n1,2 ; default is 2 words
  164. skipe n3
  165. aos n1 ; but we may need 3
  166. alloc (n1),r0 ; allocate the mem, filling with the code
  167. movem n2,1(rr) ; fill the string, too
  168. skipe n3
  169. movem n3,2(rr)
  170. stypi rr,(tstr) ; show the type
  171. $rtn rr ; and return the string
  172. corp int$i2s,[i]
  173. proc i.sim,[x,y]
  174. move n1,x(er)
  175. $crtnb came n1,y(er)
  176. corp int$similar,[x,y]
  177. proc i.cop,[x]
  178. $rtn x(er)
  179. corp int$copy,[x]
  180. retsulc int
  181. .insrt clusys;omega >