Table of Contents

COMPUT

Table Of Contents

  • [00008] EXECUTION OF COMPUTE COMMAND

Source Code

COMPUT.txt
  1. COMPUT
  2. * /--- FILE TYPE = E
  3. * /--- BLOCK COMPUT 00 000 79/12/03 22.46
  4. IDENT PLAT2$
  5. LCC OVERLAY(PLATO,1,0)
  6. END
  7. IDENT COMPUT
  8. TITLE EXECUTION OF COMPUTE COMMAND
  9. *
  10. *
  11. CST
  12. *
  13. *
  14. COMPUT$ OVFILE
  15. *
  16. *
  17. *
  18. EXT PROCESS,PROCESX
  19. EXT NGETVAR
  20. EXT FGETVAR
  21. EXT ECSPRTY HANDLE ECS PARITY ERRORS
  22. EXT CSPREAD CHECKS STRING BOUNDS AND SPREADS CHARS
  23. EXT POSTOR
  24. * INTO TAG FOR COMPILE.
  25. EXT COMPCOM SPECIAL ENTRY TO -COMPILE-.
  26. *COMPCOM GENERATES CODE EVEN FOR SIMPLE REFERENCES.
  27. EXT QCMPCOM ENTRY TO -COMPILE- FOR 3 TAGS
  28. * QCMPCOM GENERATES THE SIMPLEST POSSIBLE GETVAR CODE
  29. *
  30. *********************************************************
  31. *
  32. *COMPUTE RESULT,START,COUNT,POINTER (OPTIONAL) (EXECUTION)
  33. *
  34. *CHECK GETVAR CODE FOR POINTER. IF 0, THEN THERE IS NO
  35. *POINTER AND THE COMPILED CODE WILL NOT BE SAVED. OTHERWISE,
  36. *CHECK POINTER TO SEE WHETHER THIS -INTERPRETIVE- CALC
  37. *IS ALREADY COMPILED IN ECS. IF NOT, COMPILE AND ADD
  38. *CODE TO ECS BUFFER -COMPBUF- FOR LATER REUSE.
  39. *
  40. *RESULT GETS THE RESULT OF EXECUTING THE CALC,
  41. *START IS LOCATION OF CHAR STRING,
  42. *COUNT IS CHAR COUNT OF STRING,
  43. *AND POINTER CONTAINS NOT ONLY POINTER TO MACHINE CODE
  44. *IN ECS, BUT SECURITY FIELDS TO MAKE SURE IT
  45. *IS APPROPRIATE AND SAFE TO JUMP INTO THAT CODE.
  46. *WHEN CODE IS READ FROM ECS, THE FIRST WORD IS CHECKED
  47. *FOR EQUALITY WITH POINTER.
  48. *
  49. *POINTER DATA FORMAT---
  50. * 6/46B,12/STATION,19/CLOCK,
  51. * 1/I-F BIT,4/CALC ADDR,7/ECS WORD COUNT,11/ECS ADDRESS
  52. *
  53. *INITIAL 46B (PASS CODE) INSURES NO CONFUSION BETWEEN
  54. *HEADER WORD AND CALC CODE, SINCE TUTOR MACHINE CODE
  55. *NEVER STARTS WITH A PASS. NEVERTHELESS IT IS
  56. *THEORETICALLY POSSIBLE FOR A POINTER TO AGREE WITH AN
  57. *INTEGER LITERAL PLANTED AT THE BEGINNING OF THE CODE.
  58. *SUCH A LITERAL IS SEARCHED FOR WHEN THE INITIAL
  59. *COMPILATION IS DONE, AND IF PRESENT CAUSES THE MACHINE
  60. *CODE NOT TO BE SAVED.
  61. *
  62. *I-F BIT TELLS WHETHER CALC RESULT IS INTEGER-FLOATING.
  63. *MACHINE CODE STARTS WITH LITERALS--CALC ADDRESS POINTS
  64. *TO BEGINNING OF CALC PROPER.
  65. *ECS ADDRESS IS RELATIVE TO BEGINNING OF COMPBUF BUFFER.
  66. *
  67. **********************************************************
  68. * /--- BLOCK START 00 000 79/12/02 05.23
  69. COMPTOV OVRLAY
  70. SX7 -1 FLAG -STORE- CODE NOT PRESENT
  71. SA7 JJSTORE
  72. SA7 TFORMOK CALC OK IF CERROR IS -1
  73. AX5 XCMNDL RIGHT-ADJUST EXTRA-STORAGE POINTER
  74. MX0 2*XCODEL+XCMNDL
  75. BX5 -X0*X5
  76. SA1 B5+X5 PICK UP LAST TWO ARGUMENTS
  77. BX7 X1 SAVE THIS
  78. SA7 SAVCOD
  79. BX5 X1
  80. LX5 XCODEL 4TH ARGUMENT---POINTER
  81. MX2 XCODEL TOP 20 BITS
  82. BX2 X2*X5
  83. ZR X2,ONLY3 IF -GETVAR- CODE=0 (NO 4TH ARG)
  84. NGETVAR 4
  85. SX7 A1 GET POINTER ADDRESS
  86. SA7 POINTER AND SAVE IT
  87. SA2 STATION NOW BUILD 46B--STATION
  88. MX0 48 TO CHECK FOR POSSIBLE CORRECT POINTER
  89. BX2 -X0*X2 4096 STATIONS MAXIMUM
  90. SX3 46B PASS CODE HEADER
  91. LX3 12
  92. BX7 X2+X3 MERGE 46B WITH STATION
  93. LX7 42
  94. SA7 SAVID SAVE THIS IDENTIFICATION
  95. BX3 X7-X1 COMPARE WITH POINTER
  96. MX7 18 12 BITS OF STATION, 6 BITS OF 46B PASS CODE
  97. BX7 X7*X3
  98. NZ X7,NOTREDY JUMP IF CALC NOT ALREADY COMPILED
  99. *
  100. BX7 X1 THIS STRING HAS ALREADY BEEN COMPILED
  101. LX7 37 SHIFT I/F BIT TO SIGN POSITION
  102. SA7 IFFLAG SAVE FOR END CHECK ON NEED FOR ROUNDING
  103. MX0 49
  104. BX0 -X0*X1 11-BIT ECS ADDRESS RELATIVE TO COMPBUF
  105. SA2 COMPBFA
  106. IX0 X0+X2 ABSOLUTE ECS ADDRESS
  107. MX2 42
  108. BX2 -X2*X1
  109. AX2 11 ECS WORD COUNT (INCLUDES HEADER WORD)
  110. SB1 X2 ECS COUNT IN B1
  111. SA0 INFO-1 CM ADDRESS TO READ INTO
  112. + RE B1 READ THE BLOCK IN
  113. - RJ ECSPRTY
  114. SA2 A0 EXAMINE HEADER WORD
  115. BX7 X1-X2 MUST MATCH POINTER WORD
  116. NZ X7,NOTREDY JUMP IF MACHINE CODE HAS BEEN OVERWRITTEN
  117. NG X7,NOTREDY BY LATER COMPILATIONS.
  118. AX1 18 GET CALC STARTING LOCATION
  119. MX0 56 4 BITS
  120. BX0 -X0*X1
  121. SB1 X0 START OF CALC RELATIVE TO INFO
  122. SETUP RJ SETUP1
  123. JP INFO+B1 EXECUTE THE CALC
  124. *
  125. * /--- BLOCK SETUP 00 000 79/12/03 22.46
  126. *
  127. SETUP1 EQ * MUST PRESERVE X5,X6
  128. SX7 -1 SET CALC ERROR TO -OK-
  129. SA7 TFORMOK
  130. SB3 A5
  131. SX7 B5-B3 SAVE COMMAND BIAS
  132. SA7 OLDB5
  133. SB3 READYR RETURN TO READYR
  134. SB5 INFO BIAS FOR LITERAL IN CALC
  135. EQ SETUP1
  136. *
  137. *
  138. READYR BX6 X1 RESULT RETURNED IN X1
  139. * MOVED TO X6 FOR PUTVAR MACRO
  140. SA1 OLDB5 MUST RESTORE B5
  141. MX7 59 -1
  142. SA7 A1 CLEAR OLDB5
  143. SB5 X1
  144. SB5 A5+B5
  145. SA5 A5 RESTORE X5
  146. SA2 IFFLAG
  147. PL X2,IRESULT JUMP IF INTEGER RESULT
  148. *
  149. FPUTVAR 1 STORE FLOATING RESULT
  150. EQ PROCESX
  151. *
  152. IRESULT NPUTVAR 1 STORE INTEGER RESULT
  153. EQ PROCESX
  154. *
  155. *
  156. ONLY3 RJ EVAL PREPARE FOR COMPILATION
  157. RJ QCMPCOM COMPILE
  158. BX5 X1 FOR GETVAR
  159. LX5 2*XCODEL -GETVAR- CODE IN UPPER 20 BITS
  160. BX6 X1
  161. LX6 60-XCODEAL-4 MOVE I/F BIT TO SIGN BIT
  162. SA6 IFFLAG STORE IT
  163. RJ SETUP1 SET THINGS UP
  164. PL X6,INT X6 NOT TOUCHED BY SETUP1
  165. FGETVAR 2
  166. EQ READYR DONE
  167. INT NGETVAR 2
  168. EQ READYR DONE
  169. *
  170. *
  171. * /--- BLOCK READY 00 000 79/07/15 16.01
  172. *
  173. *
  174. NOTREDY RJ EVAL NOT COMPILED YET
  175. RJ COMPCOM COMPILE MACHINE CODE
  176. BX7 X1 PICK OUT I/F BIT
  177. LX7 60-XCODEAL-4
  178. SA7 IFFLAG I/F BIT IN SIGN BIT
  179. MX0 60-XCODEAL
  180. BX7 -X0*X1 SAVE CALC LOCATION
  181. SB1 X7 SAVE CALC LOCATION
  182. AX7 4 SHOULD BE <16 LITERALS IN FRONT OF CALC
  183. NZ X7,NOSAVE JUMP IF MACHINE CODE WILL NOT BE SAVED
  184. AX1 XCODEAL+3 GET I/F BIT
  185. LX1 4
  186. SX7 X1+B1 MERGE CALC BIAS AND I/F BIT
  187. SA1 COMPPNT POINTER TO NEXT AVAILABLE LOCATION
  188. *IN ECS BUFFER COMPBUF.
  189. SA3 INX NUMBER OF WORDS OF MACHINE CODE
  190. SX6 46B CHECK THAT THERE ARE NO LITERALS
  191. LX6 54 STARTING WITH 46B
  192. SA6 X3+INFO PLANT SUCH A LITERAL FOR A SEARCH
  193. MX0 6
  194. SB2 1
  195. SA2 INFO-1
  196. CLOOP SA2 A2+B2 PICK UP NEXT LITERAL OR INSTRUCTION
  197. BX2 X2-X6 X6 CONTAINS 46B AT LEFT
  198. BX2 X0*X2 MASK FIRST 6 BITS
  199. NZ X2,CLOOP LOOP UNTIL PLANTED WORD FOUND
  200. SB2 A2 A2 SHOULD EQUAL A6
  201. SB2 A6-B2
  202. NZ B2,NOSAVE JUMP IF CANNOT SAVE CODE DUE TO 46B PRESENT
  203. SX2 X3+1 PLUS HEADER WORD
  204. BX3 X2
  205. AX3 7
  206. NZ X3,NOSAVE JUMP IF MORE THAN 126 WORDS IN CALC
  207. IX6 X1+X2 NEW COMPPNT
  208. SX0 X6-COMPBFL SUBTRACT COMPBUF LENGTH
  209. NG X0,ISROOM JUMP IF THERE IS ROOM FOR THIS CALC
  210. SX1 B0 ELSE RESET POINTER (CIRCULAR BUFFER)
  211. BX6 X2
  212. ISROOM SA6 A1 UPDATE COMPPNT
  213. LX7 7
  214. BX7 X2+X7 MERGE ECS WORD COUNT
  215. LX7 11
  216. BX7 X1+X7 MERGE ECS ADDRESS
  217. SA3 SAVID RETRIEVE 46-STATION CODE
  218. BX7 X7+X3 MERGE TO MAKE 60-BIT POINTER
  219. SA3 SYSCLOK SYSTEM TIME (INT NUM OF MS)
  220. AX3 8 KEEP TO NEAREST 0.25 SEC
  221. MX0 -19 KEEP 19 BITS (2**17 SEC IS ABOUT 1.5 DAYS)
  222. * /--- BLOCK IRESULT 00 000 79/07/15 16.01
  223. BX3 -X0*X3
  224. LX3 23 POSITION FOR MERGE
  225. BX7 X3+X7 MERGE IN TIME
  226. SA7 INFO-1 PLACE HEADER IN FRONT OF CALC
  227. SA0 A7 A0 IS CM ADDRESS FOR EC WRITE
  228. SA3 POINTER GET ADDRESS OF POINTER
  229. SA7 X3 UPDATE POINTER
  230. SB2 X2 WORD COUNT INCLUDES HEADER
  231. SA3 COMPBFA COMPBFA CONTAINS BUFFER INITIAL ADDRESS
  232. IX0 X1+X3
  233. + WE B2 SEND HEADER AND CALC TO ECS
  234. - RJ ECSPRTY
  235. EQ SETUP GO EXECUTE THE CALC
  236. *
  237. *
  238. *
  239. EVAL EQ *
  240. SA5 A5 CALC NOT ALREADY COMPILED
  241. LX5 XCODEL SO NEED STRING ADDRESS AND CHAR COUNT
  242. NGETVAR 2
  243. SX7 A1 SAVE STRING ADDRESS
  244. SA7 IFFLAG AVAILABLE TEMP
  245. SA1 SAVCOD EXTRA STORAGE ARGUMENTS
  246. BX5 X1
  247. NGETVAR INC GET CHAR COUNT
  248. SX7 6 BAD FORM
  249. ZR X1,BADFORM
  250. NG X1,BADFORM
  251. SX2 101 ALLOW 100 CHARS
  252. IX2 X1-X2 CHECK FOR POSSIBLE SHOW BUFFER OVERFLOW
  253. NG X2,EVAL2
  254. SX7 16 TOO COMPLICATED TO COMPILE
  255. BADFORM SA7 TFORMOK
  256. EQ PROCESX
  257. EVAL2 SA2 IFFLAG RESTORE ADDRESS
  258. SA0 X2
  259. RJ CSPREAD SPREAD PACKED STRING FOR COMPILE
  260. MX7 0
  261. SA7 INX COMPILE INTO INFO BUFFER
  262. EQ EVAL
  263. *
  264. *
  265. NOSAVE SX7 B0 CLEAR POINTER IF MACHINE CODE NOT SAVED
  266. SA2 POINTER
  267. SA7 X2
  268. EQ SETUP EXECUTE THE CALC
  269. *
  270. *
  271. POINTER BSS 1 POINTS TO MACHINE CODE
  272. IFFLAG BSS 1 SIGN BIT ON IF MACHINE CODE FLOATING POINT
  273. SAVID BSS 1 SAVE 46B-STATION BITS
  274. SAVCOD BSS 1 SAVE CODE FIELDS
  275. *
  276. ENDOV
  277.  
  278. OVTABLE
  279.  
  280. END COMPUT$