Trailing-Edge
-
PDP-10 Archives
-
red405a2
-
uetp/mic/mic.mac
There are 19 other files named mic.mac in the archive. Click here to see a list.
TITLE MIC - MACRO INTERPRETED COMMANDS
SUBTTL F.D. BROWN 10-NOV-78
SEARCH MONSYM,MACSYM,MICPRM
SALL
;AC DEFINITIONS
F=0 ;FLAGS
A=1 ;RESERVED FOR JSYS'S
B=2
C=3
D=4
E=5 ;LAST JSYS AC
T1=6 ;TEMPORARY ACS
T2=7
X=10 ;POINTS TO CURRENT PROCESS
CH=11 ;HOLDS A CHAR
BP=12 ;HOLDS A BYTE POINTER
WD=13 ;HOLDS A SIXBIT WORD
P1=14 ;PRESERVED ACS
P2=15
P3=16
P=17 ;PUSHDOWN POINTER
;FLAG DEFINITIONS
F.MON==1B0
F.COL1==1B1
F.CR==1B2
F.SPCR==1B3 ;SUPRESS CRLF AT END OF THIS LINE
F.BRK==1B4 ;WE ARE IN BREAK MODE
F.CMNT==1B5 ;SET IF HANDLING A COMMENT
F.ABT==1B6 ;AN ABORT (CONTROL-A) WAS TYPED
SUBTTL INITIALISATION
MIC: MOVEM 0,MICPAG# ;WHERE THE PARAMETERS ARE
SETZ X, ;ZERO X FIRST TIME THROUGH
RESET ;RESET THE WORLD
MOVE P,[IOWD PDL,PDP] ;SETUP PUSHDOWN POINTER
MOVEI A,.FHSLF ;OUR FORK
MOVE B,[LEVTAB,,CHNTAB] ;PSI TABLES
SIR ;DEFINE THEM TO THE MONITOR
MOVX B,1B0!1B1!1B2!1B3 ;ACTIVATE CHANNELS 0,1,2 AND 3
AIC ;DO IT
MOVE A,[.TICCA,,1] ;CHANNEL 1 IS FOR CONTROL-A
ATI ;ENABLE THAT CHAR
MOVE A,[.TICCB,,2] ;CHANNEL 2 IS FOR CONTROL-B
ATI ;ENABLE THAT CHAR
MOVE A,[.TICCP,,3] ;CHANNEL 3 IS FOR CONTROL-P
ATI ;ENABLE THAT CHAR
MOVEI A,.FHSLF ;OUR FORK
EIR ;ENABLE THE INTERRUPT SYSTEM FOR OURSELVES
ERCAL BDJSYS ;ERROR
MIC1: MOVE T1,MICPAG ;GET PAGE NUMBER EXEC GAVE US
LSH T1,^D9 ;MAKE INTO ADDRESS
CALL SETPRC ;SETUP THE PDB
SETZ F, ;CLEAR FLAG WORD
TXO F,F.MON!F.COL1 ;ASSUME WE ARE IN MONITOR MODE AND COLUMN-1
SUBTTL MAIN LOOP
WAIT: SETZM WAITTM ;CLEAR THEE WAIT INTERVAL
MOVE P,[IOWD PDL,PDP] ;RESET THE STACK IN CASE WE FORGOT WHERE WE WERE
MOVEI A,.PRIIN ;PRIMARY INPUT
DIBE ;DISMISS UNTIL INPUT BUFFER EMPTY
MOVEI A,.PRIOU ;PRIMARY OUTPUT
DOBE ;WAIT TILL OUTPUT BUFFER IS EMPTY
TXNE F,F.BRK ;ARE WE IN A BREAK?
JRST WAIT1 ;YES - DON'T CHECK FOR INPUT WAIT
WAIT3: MOVEI A,.PRIIN ;CHECK PRIMARY INPUT
MOVEI B,.MOPIH ;CHECK INPUT READY FLAG
MTOPR ;GET FLAG
JUMPN B,WAIT2 ;IT IS READY
WAIT1: MOVE A,WAITTM ;GET THE WAIT TIME
CAIL A,^D1000 ;IS IT LESS THAN 1 SEC?
JRST DOWAIT ;NO ..DO NOT INCREMENT
ADDI A,^D100 ;INCRREMENT
MOVEM A,WAITTM
DOWAIT: DISMS ;SLEEP TIGHT
JRST WAIT ;LOOK AGAIN
WAIT2: CALL GETLIN ;READ NEXT LINE IN
JRST EOF ;END OF FILE
CALL PUTLIN ;AND PRINT IT
JRST WAIT3 ;BACK ROUND FOR THE NEXT LINE
SUBTTL TYPE CHARACTERS FOR USER
;GETLIN - READS A COMPLETE LINE AND ASSEMBLES IT IN LINBUF
GETLIN: TXZ F,F.CMNT ;ASSUME THIS LINE IS NOT A COMMENT
MOVE BP,[POINT 7,LINBUF(X)] ;SET UP WHERE TO PUT A LINE
GETLN1: CALL NXTCHR ;GET THE NEXT CHARACTER
RET ;AND OF FILE - NON-SKIP RETURN
JUMPE CH,.POPJ1 ;JUST RETURN IF A NULL CHARACTER
IDPB CH,BP ;SAVE THE CHARACTER AWAY
CALL ISBRK ;IS THIS A BREAK CHARACTER
JRST GETLN1 ;NO - READ THE NEXT ONE
JRST .POPJ1 ;YES - GIVE THE SKIP RETURN
NXTCHR: TXNE F,F.CMNT ;ARE WE HANDLING A COMMENT?
JRST GETCMN ;YES - GO HANDLE THIS SPECIAL CASE
CALL GETCHR ;GO GET A CHAR
RET ;EOF - GIVE NON-SKIP RETURN
TXNE F,F.COL1 ;ARE WE IN COLUMN 1?
JRST COL1 ;YES SPECIAL CHECKING
COL2: CAIN B,"^" ;CONTROL-CHAR?
JRST CNTRL ;YES - CHECK IT
CAIN B,15 ;CR?
JRST CRET ;YES - SEE IF WE SHOULD TYPE IT
CAIN B,12 ;LF?
JRST LNFEED ;YES - SEE IF WE SHOULD IGNORE IT
TXZ F,F.COL1 ;NO LONGER IN COLUMN 1
TYPCHR: MOVEI CH,(B) ;MOVE THE CHAR WHERE GETLIN EXPECTS IT
JRST .POPJ1 ;AND GIVE SKIP RETURN
CRET: TXO F,F.CR!F.COL1 ;SET SUPPRESS LF AND COLUMN-1 FLAGS
TXNN F,F.SPCR ;DO WANT THIS CR SUPPRESSED?
JRST TYPCHR ;NO - GO TYPE THE CHAR
SETZ CH, ;YES - DUMMY UP A NULL BYTE
JRST .POPJ1 ;AND GIVE SKIP RETURN - WE ARE DONE
LNFEED: TXZN F,F.CR!F.SPCR ;DID WE JUST TYPE A CR, OR DO WE WANT THIS LF SUPPRESSED?
JRST TYPCHR ;NO - GO TYPE THE CHAR
SETZ CH, ;YES - DUMMY UP A NULL BYTE
JRST .POPJ1 ;AND GIVE SKIP RETURN
CNTRL: CALL GETCHR ;GET A CHARACTER
RET ;END OF FILE
CAIN B,"^" ;2ND ^?
JRST TYPCHR ;YES - HE MUST HAVE MEANT ONE - GO TYPE IT
CALL LOWUP ;CONVERT TO UPPER-CASE
JFCL ;IGNORE ERRORS (FOR NOW)
SUBI B,100 ;MAKE CONTROL-CHAR
JRST TYPCHR ;AND GO TYPE THAT
COL1: ;COME HERE TO SEE IF WE HAVE A SPECIAL CHAR
CAIN B,"@" ;MONITOR MODE?
JRST MONMOD ;YES - CHECK FOR 2ND ONE
CAIN B,"*" ;USER MODE?
JRST USRMOD ;YES - CHECK FOR 2ND ONE
CAIN B,"=" ;SUPRESS CR/LF?
JRST EQUALS ;YES - CHECK FOR 2ND ONE
CAIN B,"!" ;COMMENT
JRST EXCLAM ;YES
CAIN B,";" ;DIFFERENT COMMENT?
JRST SEMI ;YES
JRST COL2 ;NO - HANDLE AS FOR NORMAL CHAR
SUBTTL HANDLE SPECIAL CHARACTERS
MONMOD: CALL GETCHR ;GET NEXT CHAR
RET ;END OF FILE
CAIN B,"@" ;A SECOND @?
JRST TYPCHR ;YES - GO TYPE IT
PUSH P,B ;SAVE THE CHAR
CALL CHKMON ;NO - ARE WE IN MONITOR MODE?
JRST [POP P,B ;YES - RESTORE THE CHAR
JRST COL2] ; AND TYPE IT
POP P,B ;NO - RESTORE THE CHAR
MOVEM B,SAVCHR(X) ;AND SAVE THIS CHAR
MOVEI B,3 ;SEND CONTROL-C
MOVEI A,.PRIIN ;PRIMARY INPUT
STI ;FORCE IT OUT
MOVEI T1,^D20 ;MAXIMUM NO. OF SECS TO WAIT
MONMD2: CALL CHKMON ;ARE WE THERE YET?
JRST RETNUL ;YES - WE ARE DONE - RETURN A NUL
MOVEI A,^D1000 ;NO - AND WAIT A SEC
DISMS ;..
SOJG T1,MONMD2 ;AND GO WAIT
RETNUL: SETZ CH, ;RETURN A NULL BYTE
JRST .POPJ1 ;AND GIVE SKIP RETURN
USRMOD: CALL GETCHR ;GET NEXT CHAR
RET ;END OF FILE
CAIN B,"*" ;A SECOND STAR?
JRST TYPCHR ;YES - GO TYPE IT
;NO - WE SHOULD CHECK USER MODE HERE
JRST COL2 ;BUT FOR NOW WE WILL JUST TYPE THE CHAR
EQUALS: CALL GETCHR ;GET NEXT CHAR
RET ;END OF FILE
CAIN B,"=" ;A SECOND EQUALS?
JRST TYPCHR ;YES - GO TYPE IT
TXO F,F.SPCR ;NO - SAY WE SHOULD SUPPRESS THE CRLF
JRST COL2 ;AND GO LOOK AT THIS CHAR
SUBTTL HANDLE COMMENTS
EXCLAM: CALL GETCHR ;GET NEXT CHAR
RET ;END OF FILE
CAIN B,"!" ;2ND EXCLAMATION?
JRST TYPCHR ;YES - GO TYPE IT
CAIN B,15 ;CARRIAGE RETURN?
ADDI B,1000 ;YES - MAKE IT FAIL THE ISBRK TEST
MOVEM B,SAVCHR(X) ;NO - SAVE THE CHAR
TXO F,F.CMNT ;LIGHT THE COMMENT FLAG
MOVEI CH,"!" ;GIVE THE EXCLAM BACK
JRST .POPJ1 ;TO THE CALLER
SEMI: CALL GETCHR ;GET NEXT CHAR
RET ;END OF FILE
CAIN B,";" ;2ND EXCLAMATION?
JRST TYPCHR ;YES - GO TYPE IT
MOVEM B,SAVCHR(X) ;NO - SAVE THE CHAR
TXO F,F.CMNT ;LIGHT THE COMMENT FLAG
MOVEI CH,";" ;GIVE THE SEMICOLON BACK
JRST .POPJ1 ;TO THE CALLER
GETCMN: CALL GETCHR ;GET NEXT CHAR
RET ;END OF FILE
CAIN B,15 ;CARRIAGE RETURN?
ADDI B,1000 ;YES - MAKE IT FAIL THE ISBRK TEST
JRST TYPCHR ;RETURN TO OUR CALLER
;PUTLIN - PUTS THE LINE IN LINBUF OUT EITHER USING STI (FOR INPUT)
; OR PSOUT (FOR OUTPUT)
PUTLIN: SETZ CH, ;FIRST OF ALL MAKE LINE ASCIZ
IDPB CH,BP ;DONE!!
TXZE F,F.CMNT ;A COMMENT (TO BE OUTPUT)?
JRST PUTCMN ;YES - OUTPUT THAT
MOVE BP,[POINT 7,LINBUF(X)] ;NO - SET UP BYTE POINTER
PUTLN0: MOVEI A,.PRIIN ;SET UP FOR STI JSYS
PUTLN1: ILDB B,BP ;LOAD NEXT BYTE
JUMPE B,.POPJ ;ALL DONE ON NULL BYTE
STI ;TYPE THE CHAR
CAIE B,2 ;IS THIS A CONTROL-B?
JRST PUTLN1 ;NO - GO GET NEXT CHAR
MOVEI A,^D2000 ;YES - SLEEP FOR A WHILE
DISMS ; SO WE CAN BE INTERRUPTED
JRST PUTLN0 ;AND BACK FOR MORE
PUTCMN: HRROI A,LINBUF(X) ;GET ADDRESS OF THE LINE TO BE TYPED
PSOUT ;TYPE IT
RET ;AND RETURN
SUBTTL END OF FILE PROCESSING
EOF: SKIPE LSTPDB(X) ;DO WE HAVE A PREVIOUS PDB?
JRST EOF2 ;YES - DON'T SAY EOF
HRROI A,[ASCIZ/
[MICEMF - End of MIC File: /]
PSOUT ;PRINT MESSAGE
MOVEI A,.PRIOU ;WHERE TO PRINT MESSAGE
MOVE B,MICJFN(X) ;THE FILE NAME
SETZ C, ;DEFAULT STRING
JFNS ;PRINT STRING
HRROI A,[ASCIZ/ ]
/] ;GIVE HIM A NEW-LINE
EOF1: PSOUT
EOF2: MOVE A,MICJFN(X) ;GET THE JFN OF THE FILE
CLOSF ;AND CLOSE IT
ERCAL BDJSYS ;ERROR - TELL THE WORLD
MOVE T1,LSTPDB(X) ;GET LAST PDB ADDRESS
MOVE B,X ;GET OUR CURRENT PDB
LSH B,-^D9 ;MAKE IT INTO PAGE
HRLI B,.FHSLF ;OUR FORK
SETO A, ;SET TO UNMAP PAGE
SETZ C, ;NO SPECIAL FLAGS
PMAP ;UNMAP IT
ERCAL BDJSYS ;FAILED - REPORT IT
SKIPN X,T1 ;GET PREVIOUS PDB INTO X
JRST EOF3 ;NONE THERE - WE ARE DONE
MOVE F,FSAV(X) ;GET PREVIOUS CONTENTS OF F
SOS MICPAG ;WE ARE NOW BACK ONE PAGE
JRST WAIT ;AND GO BACK TO WAITING
EOF3: RESET ;RESET THE WORLD BEFORE WE EXIT
CALL CHKMON ;ARE WE IN MONITOR MODE
JRST KILL ;YES - KILL OURSELVES
HALTF ;NO - WE ARE DONE
JRST .-1 ;IN CASE OF CONTINUE
KILL: MOVEI A,.PRIIN ;PRIMARY INPUT
MOVEI B,15 ;FORCE AN @ OR $
STI
MOVEI B,"K" ;SET TO KILL OURSELVES
STI
MOVEI B,"m"
STI
MOVEI B,"i"
STI
MOVEI B,"c"
STI
MOVEI B,15
STI
HALTF
JRST .-1 ;WE ARE DEAD
SUBTTL SUBROUTINES
CHKMON: SETO A, ;-1 MEANS OUR JOB
HRROI B,GJIBLK ;BLOCK TO STORE THE REQUIRED INFO
MOVEI C,.JISNM ;ONLY WANT SUB-SYSTEM NAME
GETJI ;GET IT
ERCAL BDJSYS ;WE BLEW IT!!
MOVE A,GJIBLK ;GET THE NAME
CAME A,[SIXBIT/EXEC/] ;IS IT EXEC?
AOS (P) ;NO - WE ARE NOT IN MONITOR MODE
RET ;YES - WE ARE - GIVE NON-SKIP RETURN
GETCHR: CALL GETCH ;GET A BASIC CHAR
RET ;END OF FILE
CAIE B,"'" ;PARAMETER?
JRST .POPJ1 ;NO - GIVE CALLER THE CHAR
CALL GETCH ;YES - GET NEXT CHAR
RET ;END OF FILE
CAIN B,"'" ;A SECOND PRIME?
JRST .POPJ1 ;YES - GIVE USER THE PRIME
CALL LOWUP ;CONVERT TO UPPER-CASE
JRST [MOVEM B,SAVCHR(X) ;WASN'T LETTER SAVE THIS CHAR
MOVEI B,"'" ;RESTORE THE PRIME
JRST .POPJ1] ;AND RETURN TO OUR CALLER
MOVE T1,STKPTR(X) ;NO - GET PARAMETER STACK POINTER
AOBJP T1,TOOMNY ;CHECK FOR RECURSION
MOVE T2,PARPTR(X) ;GET CURRENT PARAMETER POINTER
MOVEM T2,0(T1) ;AND SAVE IT AWAY
MOVEM T1,STKPTR(X) ;SAVE THE STACK POINTER
ADDI B,PARAM(X) ;POINT TO PARAMETER AREA
MOVE T1,-"A"(B) ;GET NEW PARAMETER POINTER
MOVEM T1,PARPTR(X) ;AND SAVE IT AWAY
JRST GETCHR ;GET NEXT CHAR (USING NEW PARAMETER)
GETCH: SKIPE B,SAVCHR(X) ;IS THERE A SAVED CHAR?
JRST [SETZM SAVCHR(X) ;YES - CLEAR IT DOWN
JRST .POPJ1] ;AND GIVE A SKIP RETURN
GETCH1: SKIPE PARPTR(X) ;ARE WE READING A PARAMETER?
JRST GETPCH ;YES - GET A PARAMETER CHAR
MOVE A,MICJFN(X) ;NO - GET A CHAR
BIN ;FROM THE INPUT FILE
JUMPE B,CHKEOF ;CHECK FOR END OF FILE
.POPJ1: AOS (P) ;SKIP RETURN WITH CHAR IN B
.POPJ: RET ;RETURN
GETPCH: ILDB B,PARPTR(X) ;GET NEXT CHAR
JUMPN B,.POPJ1 ;NON-ZERO MEANS WE HAVE A CHAR
MOVE T1,STKPTR(X) ;NULL MEANS WE ARE DONE WITH THIS PARAMETER
POP T1,PARPTR(X) ;GET THE NEXT PARAMETER FROM THE STACK
MOVEM T1,STKPTR(X) ;RE-SAVE THE POINTER
JRST GETCH1 ;AND GO GET A CHAR
CHKEOF: GTSTS ;GET FILE STATUS
TXNN B,GS%EOF ;END OF FILE?
JRST GETCH ;NO - FLUSH NULL
RET ;YES - EOF (NON-SKIP) RETURN
ISBRK: ;A ROUTINE TO CHECK FOR BREAK CHARS
MOVSI T1,-BRKLEN ;GET THE LENGTH OF THE BREAK LIST
CAMN B,BRKLST(T1) ;CHECK AGAINST CHAR ON BREAK LIST
JRST .POPJ1 ;IT IS GIVE SKIP RETURN
AOBJN T1,.-2 ;ITS NOT - CHECK NEXT CHAR ON LIST
RET ;NONE LEFT - IT CANNOT BE A BREAK
LOWUP: CAIG B,"z" ;GREATER THAN LOWER-CASE Z?
CAIGE B,"a" ;OR LESS THAN LOWER-CASE A?
CAIA ;YES - DON'T CONVERT
TRZ B,40 ;NO - MAKE UPPER CASE
CAIG B,"Z" ;A LETTER?
CAIGE B,"A" ;WELL?
RET ;NO - NON-SKIP RETURN
JRST .POPJ1 ;YES - SKIP RETURN
SETPRC: MOVEI T2,PARSTK-1(T1) ;ADDRESS OF START OF STACK MINUS ONE
HRLI T2,-^D40 ;MAKE IOWD
MOVEM T2,STKPTR(T1) ;STORE IT AWAY
MOVEM X,LSTPDB(T1) ;SAVE PREVIOUS PDB ADDRESS
MOVE X,T1 ;AND SET UP NEW POINTER
RET ;RETURN TO OUR CALLER
SUBTTL ERROR MESSAGES
TOOMNY: HRROI A,[ASCIZ/
?MICPND - Parameters Nested too Deeply - Aborting
/]
JRST EOF1
BDJSYS: AOSE ERRLP ;IS THIS THE SECOND ERROR?
JRST [MOVEI A,[ASCIZ/
?MICTME - Too Many Errors - MIC will exit/]
PSOUT ;TELL HIM WE ARE TRULLY DEAD
SETO A, ;CLOSE ALL FILES
CLOSF ;DO IT
JFCL ;IGNORE ERRORS THIS TIME
HALTF ;AND EXIT
JRST .-1] ;ALL DONE
HRROI A,[ASCIZ/
?MICJSE - JSYS Error: /]
PSOUT ;OUTPUT ERROR MESSAGE
MOVX A,.PRIOU ;PRIMARY OUTPUT FOR ERROR
HRLOI B,.FHSLF ;OUR FORK,,LAST ERROR
ERSTR ;GIVE HIM ERROR MESSAGE
JFCL ;IGNORE ERRORS
JFCL
JRST EOF2 ;LOOK LIKE END OF FILE
SUBTTL INTERRUPT CODE
MICABT: TXOE F,F.ABT ;ARE WE ALREADY ABORTED
JRST MICAB1 ;YES - JUST DISMISS THIS INTERRUPT
MOVEI A,EOF ;CHANGE THE PC FOR THE DEBRK
MOVEM A,LVL1PC ;DO IT
HRROI A,[ASCIZ/
[MICABT - MIC is aborting]
/]
PSOUT ;TELL HIM WHAT WE ARE DOING
MICAB1: DEBRK ;BACK TO EOF
ERCAL BDJSYS ;WE BLEW IT
MICBRK: TXOE F,F.BRK ;ARE WE ALREADY IN A BREAK?
JRST MICBK1 ;YES - DON'T RETYPE MESSAGE
PUSH P,A ;SAVE AN AC
HRROI A,[ASCIZ/
[MICBRK - MIC is breaking]
/]
PSOUT ;TELL USER WE ARE BREAKING
POP P,A ;RESTORE THE AC
MICBK1: DEBRK ;YES - DISMISS INTERRUPT
ERCAL BDJSYS ;HOW DID WE GET HERE!!!!?
MICPRC: TXZN F,F.BRK ;ARE WE IN A BREAK?
JRST MICPC1 ;NO - JUST DISMISS INTERRUPT
PUSH P,A
HRROI A,[ASCIZ/
[MICPRC - MIC is proceeding]
/]
PSOUT ;TELL USER WE ARE CONTINUING
POP P,A
MICPC1: DEBRK ;DISMISS THE INTERRUPT
ERCAL BDJSYS ;WE BLEW IT
MICNST: ;HERE WHEN WE RECEIVE A NESTED CALL FROM EXEC
MOVEM F,FSAV(X) ;SAVE OUR FLAG WORD
AOS MICPAG ;GO TO NEXT PAGE
MOVEI A,MIC1 ;GET ADDRESS OF WHERE TO RESTART
HRRM A,LVL1PC ;AND MAKE IT LOOK LIKE OLD PC
DEBRK ;DISMIS INTERRUPT
ERCAL BDJSYS ;WE BLEW IT
SUBTTL DATA AND STORAGE
BRKLST: EXP 3,12,13,14,15,33
BRKLEN==.-BRKLST
ERRLP: EXP -1 ;ERROR COUNT
LEVTAB: EXP LVL1PC ;WHERE TO STORE THE PC & FLAGS
EXP LVL2PC
EXP LVL3PC
CHNTAB: XWD 1,MICNST ;NESTED CALL INTERRUPT - FROM EXEC
XWD 1,MICABT ;CONTROL-A INTERRUPT
XWD 1,MICBRK ;CONTROL-B INTERRUPT
XWD 1,MICPRC ;CONTROL-P INTERRUPT
BLOCK ^D31 ;REST NOT USED
LVL1PC: 0
LVL2PC: 0
LVL3PC: 0
WAITTM: 0
GJIBLK: BLOCK 1 ;WHERE TO STORE SUB-SYSTEM NAME
PDL==100
PDP: BLOCK PDL
END MIC