COMPUT
* /--- FILE TYPE = E
* /--- BLOCK COMPUT 00 000 79/12/03 22.46
IDENT PLAT2$
LCC OVERLAY(PLATO,1,0)
END
IDENT COMPUT
TITLE EXECUTION OF COMPUTE COMMAND
*
*
CST
*
*
COMPUT$ OVFILE
*
*
*
EXT PROCESS,PROCESX
EXT NGETVAR
EXT FGETVAR
EXT ECSPRTY HANDLE ECS PARITY ERRORS
EXT CSPREAD CHECKS STRING BOUNDS AND SPREADS CHARS
EXT POSTOR
* INTO TAG FOR COMPILE.
EXT COMPCOM SPECIAL ENTRY TO -COMPILE-.
*COMPCOM GENERATES CODE EVEN FOR SIMPLE REFERENCES.
EXT QCMPCOM ENTRY TO -COMPILE- FOR 3 TAGS
* QCMPCOM GENERATES THE SIMPLEST POSSIBLE GETVAR CODE
*
*********************************************************
*
*COMPUTE RESULT,START,COUNT,POINTER (OPTIONAL) (EXECUTION)
*
*CHECK GETVAR CODE FOR POINTER. IF 0, THEN THERE IS NO
*POINTER AND THE COMPILED CODE WILL NOT BE SAVED. OTHERWISE,
*CHECK POINTER TO SEE WHETHER THIS -INTERPRETIVE- CALC
*IS ALREADY COMPILED IN ECS. IF NOT, COMPILE AND ADD
*CODE TO ECS BUFFER -COMPBUF- FOR LATER REUSE.
*
*RESULT GETS THE RESULT OF EXECUTING THE CALC,
*START IS LOCATION OF CHAR STRING,
*COUNT IS CHAR COUNT OF STRING,
*AND POINTER CONTAINS NOT ONLY POINTER TO MACHINE CODE
*IN ECS, BUT SECURITY FIELDS TO MAKE SURE IT
*IS APPROPRIATE AND SAFE TO JUMP INTO THAT CODE.
*WHEN CODE IS READ FROM ECS, THE FIRST WORD IS CHECKED
*FOR EQUALITY WITH POINTER.
*
*POINTER DATA FORMAT---
* 6/46B,12/STATION,19/CLOCK,
* 1/I-F BIT,4/CALC ADDR,7/ECS WORD COUNT,11/ECS ADDRESS
*
*INITIAL 46B (PASS CODE) INSURES NO CONFUSION BETWEEN
*HEADER WORD AND CALC CODE, SINCE TUTOR MACHINE CODE
*NEVER STARTS WITH A PASS. NEVERTHELESS IT IS
*THEORETICALLY POSSIBLE FOR A POINTER TO AGREE WITH AN
*INTEGER LITERAL PLANTED AT THE BEGINNING OF THE CODE.
*SUCH A LITERAL IS SEARCHED FOR WHEN THE INITIAL
*COMPILATION IS DONE, AND IF PRESENT CAUSES THE MACHINE
*CODE NOT TO BE SAVED.
*
*I-F BIT TELLS WHETHER CALC RESULT IS INTEGER-FLOATING.
*MACHINE CODE STARTS WITH LITERALS--CALC ADDRESS POINTS
*TO BEGINNING OF CALC PROPER.
*ECS ADDRESS IS RELATIVE TO BEGINNING OF COMPBUF BUFFER.
*
**********************************************************
* /--- BLOCK START 00 000 79/12/02 05.23
COMPTOV OVRLAY
SX7 -1 FLAG -STORE- CODE NOT PRESENT
SA7 JJSTORE
SA7 TFORMOK CALC OK IF CERROR IS -1
AX5 XCMNDL RIGHT-ADJUST EXTRA-STORAGE POINTER
MX0 2*XCODEL+XCMNDL
BX5 -X0*X5
SA1 B5+X5 PICK UP LAST TWO ARGUMENTS
BX7 X1 SAVE THIS
SA7 SAVCOD
BX5 X1
LX5 XCODEL 4TH ARGUMENT---POINTER
MX2 XCODEL TOP 20 BITS
BX2 X2*X5
ZR X2,ONLY3 IF -GETVAR- CODE=0 (NO 4TH ARG)
NGETVAR 4
SX7 A1 GET POINTER ADDRESS
SA7 POINTER AND SAVE IT
SA2 STATION NOW BUILD 46B--STATION
MX0 48 TO CHECK FOR POSSIBLE CORRECT POINTER
BX2 -X0*X2 4096 STATIONS MAXIMUM
SX3 46B PASS CODE HEADER
LX3 12
BX7 X2+X3 MERGE 46B WITH STATION
LX7 42
SA7 SAVID SAVE THIS IDENTIFICATION
BX3 X7-X1 COMPARE WITH POINTER
MX7 18 12 BITS OF STATION, 6 BITS OF 46B PASS CODE
BX7 X7*X3
NZ X7,NOTREDY JUMP IF CALC NOT ALREADY COMPILED
*
BX7 X1 THIS STRING HAS ALREADY BEEN COMPILED
LX7 37 SHIFT I/F BIT TO SIGN POSITION
SA7 IFFLAG SAVE FOR END CHECK ON NEED FOR ROUNDING
MX0 49
BX0 -X0*X1 11-BIT ECS ADDRESS RELATIVE TO COMPBUF
SA2 COMPBFA
IX0 X0+X2 ABSOLUTE ECS ADDRESS
MX2 42
BX2 -X2*X1
AX2 11 ECS WORD COUNT (INCLUDES HEADER WORD)
SB1 X2 ECS COUNT IN B1
SA0 INFO-1 CM ADDRESS TO READ INTO
+ RE B1 READ THE BLOCK IN
- RJ ECSPRTY
SA2 A0 EXAMINE HEADER WORD
BX7 X1-X2 MUST MATCH POINTER WORD
NZ X7,NOTREDY JUMP IF MACHINE CODE HAS BEEN OVERWRITTEN
NG X7,NOTREDY BY LATER COMPILATIONS.
AX1 18 GET CALC STARTING LOCATION
MX0 56 4 BITS
BX0 -X0*X1
SB1 X0 START OF CALC RELATIVE TO INFO
SETUP RJ SETUP1
JP INFO+B1 EXECUTE THE CALC
*
* /--- BLOCK SETUP 00 000 79/12/03 22.46
*
SETUP1 EQ * MUST PRESERVE X5,X6
SX7 -1 SET CALC ERROR TO -OK-
SA7 TFORMOK
SB3 A5
SX7 B5-B3 SAVE COMMAND BIAS
SA7 OLDB5
SB3 READYR RETURN TO READYR
SB5 INFO BIAS FOR LITERAL IN CALC
EQ SETUP1
*
*
READYR BX6 X1 RESULT RETURNED IN X1
* MOVED TO X6 FOR PUTVAR MACRO
SA1 OLDB5 MUST RESTORE B5
MX7 59 -1
SA7 A1 CLEAR OLDB5
SB5 X1
SB5 A5+B5
SA5 A5 RESTORE X5
SA2 IFFLAG
PL X2,IRESULT JUMP IF INTEGER RESULT
*
FPUTVAR 1 STORE FLOATING RESULT
EQ PROCESX
*
IRESULT NPUTVAR 1 STORE INTEGER RESULT
EQ PROCESX
*
*
ONLY3 RJ EVAL PREPARE FOR COMPILATION
RJ QCMPCOM COMPILE
BX5 X1 FOR GETVAR
LX5 2*XCODEL -GETVAR- CODE IN UPPER 20 BITS
BX6 X1
LX6 60-XCODEAL-4 MOVE I/F BIT TO SIGN BIT
SA6 IFFLAG STORE IT
RJ SETUP1 SET THINGS UP
PL X6,INT X6 NOT TOUCHED BY SETUP1
FGETVAR 2
EQ READYR DONE
INT NGETVAR 2
EQ READYR DONE
*
*
* /--- BLOCK READY 00 000 79/07/15 16.01
*
*
NOTREDY RJ EVAL NOT COMPILED YET
RJ COMPCOM COMPILE MACHINE CODE
BX7 X1 PICK OUT I/F BIT
LX7 60-XCODEAL-4
SA7 IFFLAG I/F BIT IN SIGN BIT
MX0 60-XCODEAL
BX7 -X0*X1 SAVE CALC LOCATION
SB1 X7 SAVE CALC LOCATION
AX7 4 SHOULD BE <16 LITERALS IN FRONT OF CALC
NZ X7,NOSAVE JUMP IF MACHINE CODE WILL NOT BE SAVED
AX1 XCODEAL+3 GET I/F BIT
LX1 4
SX7 X1+B1 MERGE CALC BIAS AND I/F BIT
SA1 COMPPNT POINTER TO NEXT AVAILABLE LOCATION
*IN ECS BUFFER COMPBUF.
SA3 INX NUMBER OF WORDS OF MACHINE CODE
SX6 46B CHECK THAT THERE ARE NO LITERALS
LX6 54 STARTING WITH 46B
SA6 X3+INFO PLANT SUCH A LITERAL FOR A SEARCH
MX0 6
SB2 1
SA2 INFO-1
CLOOP SA2 A2+B2 PICK UP NEXT LITERAL OR INSTRUCTION
BX2 X2-X6 X6 CONTAINS 46B AT LEFT
BX2 X0*X2 MASK FIRST 6 BITS
NZ X2,CLOOP LOOP UNTIL PLANTED WORD FOUND
SB2 A2 A2 SHOULD EQUAL A6
SB2 A6-B2
NZ B2,NOSAVE JUMP IF CANNOT SAVE CODE DUE TO 46B PRESENT
SX2 X3+1 PLUS HEADER WORD
BX3 X2
AX3 7
NZ X3,NOSAVE JUMP IF MORE THAN 126 WORDS IN CALC
IX6 X1+X2 NEW COMPPNT
SX0 X6-COMPBFL SUBTRACT COMPBUF LENGTH
NG X0,ISROOM JUMP IF THERE IS ROOM FOR THIS CALC
SX1 B0 ELSE RESET POINTER (CIRCULAR BUFFER)
BX6 X2
ISROOM SA6 A1 UPDATE COMPPNT
LX7 7
BX7 X2+X7 MERGE ECS WORD COUNT
LX7 11
BX7 X1+X7 MERGE ECS ADDRESS
SA3 SAVID RETRIEVE 46-STATION CODE
BX7 X7+X3 MERGE TO MAKE 60-BIT POINTER
SA3 SYSCLOK SYSTEM TIME (INT NUM OF MS)
AX3 8 KEEP TO NEAREST 0.25 SEC
MX0 -19 KEEP 19 BITS (2**17 SEC IS ABOUT 1.5 DAYS)
* /--- BLOCK IRESULT 00 000 79/07/15 16.01
BX3 -X0*X3
LX3 23 POSITION FOR MERGE
BX7 X3+X7 MERGE IN TIME
SA7 INFO-1 PLACE HEADER IN FRONT OF CALC
SA0 A7 A0 IS CM ADDRESS FOR EC WRITE
SA3 POINTER GET ADDRESS OF POINTER
SA7 X3 UPDATE POINTER
SB2 X2 WORD COUNT INCLUDES HEADER
SA3 COMPBFA COMPBFA CONTAINS BUFFER INITIAL ADDRESS
IX0 X1+X3
+ WE B2 SEND HEADER AND CALC TO ECS
- RJ ECSPRTY
EQ SETUP GO EXECUTE THE CALC
*
*
*
EVAL EQ *
SA5 A5 CALC NOT ALREADY COMPILED
LX5 XCODEL SO NEED STRING ADDRESS AND CHAR COUNT
NGETVAR 2
SX7 A1 SAVE STRING ADDRESS
SA7 IFFLAG AVAILABLE TEMP
SA1 SAVCOD EXTRA STORAGE ARGUMENTS
BX5 X1
NGETVAR INC GET CHAR COUNT
SX7 6 BAD FORM
ZR X1,BADFORM
NG X1,BADFORM
SX2 101 ALLOW 100 CHARS
IX2 X1-X2 CHECK FOR POSSIBLE SHOW BUFFER OVERFLOW
NG X2,EVAL2
SX7 16 TOO COMPLICATED TO COMPILE
BADFORM SA7 TFORMOK
EQ PROCESX
EVAL2 SA2 IFFLAG RESTORE ADDRESS
SA0 X2
RJ CSPREAD SPREAD PACKED STRING FOR COMPILE
MX7 0
SA7 INX COMPILE INTO INFO BUFFER
EQ EVAL
*
*
NOSAVE SX7 B0 CLEAR POINTER IF MACHINE CODE NOT SAVED
SA2 POINTER
SA7 X2
EQ SETUP EXECUTE THE CALC
*
*
POINTER BSS 1 POINTS TO MACHINE CODE
IFFLAG BSS 1 SIGN BIT ON IF MACHINE CODE FLOATING POINT
SAVID BSS 1 SAVE 46B-STATION BITS
SAVCOD BSS 1 SAVE CODE FIELDS
*
ENDOV
OVTABLE
END COMPUT$