TITLE Calculator compiler main program, by Doug Jones ;------------------------------- ; See the calculator procedure for details of the input syntax. ; the main program exits when a blank line is entered. ;------------------------------- USE "/group/22c018/hawk.macs" S START ; put the procedure call stack in unused memory EXT UNUSED PSTACK: W UNUSED ; linkage for external procedures in the monitor EXT DSPINI,DSPAT,DSPCH,KBGETS PDSPINI:W DSPINI PDSPAT: W DSPAT PDSPCH: W DSPCH PKBGETS:W KBGETS ; linkage for external procedures in this program EXT COMPIL PCOMPIL:W COMPIL ; the line buffer COMMON LINE,80 PLINE: W LINE ; the main program START: LOAD R2,PSTACK ; set up calling stack LOAD R1,PDSPINI JSRS R1,R1 ; initialize display LOOP: LIS R3,10 LIS R4,2 LOAD R1,PDSPAT JSRS R1,R1 ; at (10,2) LIS R3,'>' LOAD R1,PDSPCH JSRS R1,R1 ; output prompt LOAD R3,PLINE LOAD R1,PKBGETS JSRS R1,R1 ; get line LOAD R3,PLINE LOADS R4,R3 EXTB R4,R4,R3 ; get first char of input line BZS QUIT ; quit if null LIS R3,10 LIS R4,3 LOAD R1,PDSPAT JSRS R1,R1 ; at (10,3) JSR R1,CLEAR ; erase old output, if any LIS R3,10 LIS R4,3 LOAD R1,PDSPAT JSRS R1,R1 ; at (10,3) LOAD R3,PLINE LOAD R1,PCOMPIL JSRS R1,R1 ; compile the line TESTR R3 ; see if line compiled BZS NOCOMP JSRS R1,R3 ; call compiled code if it compiled NOCOMP: LIS R3,10 LIS R4,2 LOAD R1,PDSPAT JSRS R1,R1 ; at (10,2) JSR R1,CLEAR ; erase old input, if any BR LOOP ; and then get next line QUIT: CLR R1 ; quit! JUMPS R1 ;------------------------------- CLEAR: ; routine to clear 70 characters ; may wipe out R3-8 ; does not use R2 MOVE R8,R1 ; set aside return address LIL R7,70 CLEARL: LIS R3," " LOAD R1,PDSPCH JSRS R1,R1 ; output blank ADDSI R7,-1 ; count it BGT CLEARL; ; iterate if more blanks JUMPS R8 ; return END