Trailing-Edge
-
PDP-10 Archives
-
BB-H348C-RM_1982
-
swskit-v21/demos/tlk.mac
There are no other files named tlk.mac in the archive.
TITLE TLK
SALL
SEARCH MONSYM,MACSYM
.REQUIRE SYS:MACREL
FILSTR: BLOCK 20
SRVSTR: ASCIZ /SRV:16/
DATWRD==^D20
MAXDAT==5*DATWRD
DATBUF: BLOCK DATWRD
HOST: BLOCK 5
SAVA: BLOCK 4
T1==1
T2==2
T3==3
T4==4
SRVJFN==5
DCNJFN==6
P==17
NPDL==20
PDL: BLOCK NPDL
;TEXT INPUT VARIABLES
INWRD==^D20
MAXINP==5*INWRD
INBUF: BLOCK INWRD
PC: BLOCK 1 ;INTERRUPT PC
PC1: BLOCK 1 ;LEVEL 2 PC
LEVTAB: PC
PC1
PC
CHNTAB: 1,,GOTCI
1,,GOTDAT
2,,GOTE
;START OF PROGRAM
START: RESET ;GET A CLEAN SLATE
MOVEI T1,.FHSLF ;FOR THIS FORK
MOVE T2,[LEVTAB,,CHNTAB]
SIR ;DEFINE INT SYSTEM TABLES
MOVX T2,7B2 ;CHANNELS TO ENABLE
AIC
EIR ;TURN ON SYSTEM
MOVE T1,["E"-100,,2]
ATI ;PUT ^E ON CHANNEL 2
;SET UP STACK
MOVE P,[IOWD NPDL,PDL]
;SET UP A SERVER
CALL GETSRV ;DO IT
;GET SERVER NAME
START1: CALL GETNAM ;GET IT AND MODIFY FILE SPEC
; ..
;NOW WAIT FOR INPUT FROM TERMINAL
INPUT: HRROI T1,[ASCIZ /TLK>/]
PSOUT ;OUTPUT THE STRING
HRROI T1,INBUF ;WHERE DATA IS GOING
MOVEI T2,MAXINP ;THE INPUT COUNT
HRROI T3,[ASCIZ /TLK>/]
RDTTY ;GET INPUT DATA
JSHLT ;ERROR!!!!
TXNN T2,RD%BTM ;SAW A TERMINATOR?
JRST [ HRROI T1,[ASCIZ /
?NOT CONFIRMED
/]
PSOUT
MOVEI T1,.PRIIN ;GET INPUT DESIGNATOR
CFIBF ;CLEAR ITS INPUT
JFCL
JRST INPUT] ;TRY AGAIN
MOVNI T2,0(T2) ;GET REMAINING COUNT
ADDI T2,MAXINP ;COMPUTE BYTES RECEIVED
CAIG T2,2 ;MORE THAN EOL?
JRST INPUT ;NO
;HAVE SOME INPUT. STRIP OFF EOL'S AND SEND IT OFF
SETZM T3
DPB T3,T1 ;GET RID OF TERMINATOR
BKJFN ;BACK UP POINTER
JFCL
LDB T2,T1 ;LOOK AT PREVIOUS CHAR
CAIN T2,.CHCRT ;A CR?
DPB T3,T1 ;ZAP OFF CR AS WELL
; ..
;MAKE NETWORK CONNECTION
MOVX T1,GJ%SHT
HRROI T2,FILSTR ;GET STRING
GTJFN ;GET A JFN
JRST DCNERR ;FAILED
MOVE T4,T1 ;SAVE JFN
MOVE T2,[070000,,100000]
OPENF ;GET CONNECTION
JRST DCNERR
SETZM T3
HRROI T2,INBUF
SOUTR ;SEND THE MESSAGE
ERJMP DCNER1
CLOSF ;CLOSE THE CONNECTION
DCNER1: JRST [ MOVE T1,T4 ;GET BACK JFN
TXO T1,CZ%ABT ;ABORT IT THIS TIME
CLOSF
JFCL
JRST DCNERR]
JRST INPUT ;DO IT AGAIN
;ERROR ENCOUTNERED
DCNERR: JSERR ;SAY WHY
HRROI T1,[ASCIZ /
?MESSAGE NOT SENT
/]
PSOUT
JRST INPUT ;AND WAIT AROUND
;INTERRUPT ROUTINES FOR RECEIVE
GOTCI: CALL SAVAC ;SAVE REGS
MOVE T1,SRVJFN ;GET SERVER JFN
MOVEI T2,.MORDA ;GET OPTIONAL DATA
MOVE T3,[POINT 8,HOST] ;USE HOST STRING FOR NOW
MTOPR ;GET OPTDATA FIELD
ERJMP ERR ;FAILED
JUMPE T4,ERR ;MUST HAVE SOME OPTDATA
REPEAT 0,< ;FOR NOW, LET ANY TERM WORK
MOVX T3,<BYTE (8)0,0,377,377>
TDC T3,HOST
TXNE T3,<BYTE (8)0,0,377,377>
JRST ERR
> ;END OF REPEAT 0
MOVX T3,<BYTE (8)0,0,377>
TDNE T3,HOST+1 ;WANT SINGLE MESSAGE MODE?
JRST ERR ;NO. DON'T DO IT THEN
MOVEI T2,.MORHN
HRROI T3,HOST ;READ IN HOST
MTOPR ;GET IT
ERJMP ERR ;FAILED
;HAVE CONNECT
MOVE T1,SRVJFN ;GET JFN AGAIN
MOVEI T2,41 ;ACCEPT CONNECTION
SETZB T3,T4 ;NO OPTIONAL DATA
MTOPR
ERJMP ERR ;IN CASE
CALL RSTREG ;RETORE REGS
DEBRK ;AND DONE
ERR: HRROI T1,[ASCIZ /
?ERROR ON CONNECT
/]
PSOUT ;SAY THERE WAS A PROBLEM
CALL KILSRV ;GET RID OF SERVER
CALL GETSRV ;GET A NEW ONE
CALL RSTREG
DEBRK ;AND DONE
;DATA RECEIVED
GOTDAT: CALL SAVAC
MOVE T1,SRVJFN
MOVEI T2,.MORLS ;GET CURRENT STATUS
MTOPR
TXNN T3,MO%CON!MO%SYN ;IS IT CONNECTED?
JRST DATERR ;NO. IGNORE THIS
HRROI T2,DATBUF
MOVNI T3,MAXDAT
SINR ;GET THE DATA
ERJMP DATERR ;IF DATA ERROR
SETZM T1 ;GET A NULL
IDPB T1,T2 ;TIE OFF STRING
HRROI T1,[ASCIZ /
[/]
PSOUT
HRROI T1,HOST
PSOUT
HRROI T1,[ASCIZ /]/]
PSOUT
HRROI T1,DATBUF ;GET DATA
PSOUT ;PRINT IT OUT
HRROI T1,[ASCIZ /
/]
PSOUT ;DO EOL
DATERR: CALL CLSSRV ;CLOSE DOWN SERVER
CALL GETSRV ;GET A NEW ONE
CALL RSTREG ;GET BACK ACS
DEBRK ;AND DONE
;ROUTINES TO SAVE AND RESTORE REGS
SAVAC: DMOVEM T1,SAVA
DMOVEM T3,SAVA+2
RET
RSTREG: DMOVE T1,SAVA
DMOVE T3,SAVA+2
RET
;SUBROUTINE TO GET A SERVER JFN AND DO PROPER PI ASSIGNMENTS
GETSRV: MOVX T1,GJ%SHT ;SHORT FORM CALL
HRROI T2,SRVSTR ;THE FILE SPEC
GTJFN ;GET A JFN
JRST SRVERR ;OOPS
MOVEM T1,SRVJFN ;SAVE JFN
MOVE T2,[070000,,200000] ;READ ONLY
OPENF ;GET A CONNECTION
JRST SRVERR ;OOPS
;HAVE A JFN. ASSIGN INT. CHANNELS FOR IT
MOVEI T2,.MOACN ;THE FUNCTION
MOVX T3,<FLD(1,MO%DAV)+FLD(0,MO%CDN)>
MTOPR ;ASSIGN CHANNELS
ERJMP SRVERR ;OOPS, AGAIN
RET ;AND DONE
;ERROR OCCURRED
SRVERR: JSERR ;TYPE OUT FAILURE
HALTF ;AND FIVE UP
;CLOSE OR ABORT A SERVER
CLSSRV: TDZA T1,T1
KILSRV: MOVX T1,CZ%ABT
ADD T1,SRVJFN
CLOSF ;CLOSE THE CONNECTION
JRST [ MOVE T1,SRVJFN
TXO T1,CZ%ABT
CLOSF
JFCL
JRST .+1]
RET ;DONE
;ROUTINE TO READ IN NEW HOST NAME FOR SENDS
GETNAM: MOVE T1,[ASCIZ /DCN:/]
MOVEM T1,FILSTR ;BUILD NEW NAME
HRROI T1,[ASCIZ /
HOST NAME FOR SEND: /]
PSOUT
MOVE T1,[POINT 7,FILSTR,27] ;POINT TO BYTE FOR INSERT
MOVEI T2,10
HRROI T3,[ASCIZ /HOST NAME FOR SEND :/]
RDTTY ;GET THE NAME
JSHLT ;HORRIBLE ERROR
TXNN T2,RD%BTM ;HAVE A TERMINATOR
JRST [ HRROI T1,[ASCIZ /
?NOT CONFIRMED
/]
PSOUT
MOVEI T1,.PRIIN
CFIBF
JFCL
JRST GETNAM] ;TRY AGAIN
BKJFN ;BACK UP BYTE POINTER
JFCL
LDB T3,T1 ;LOOK AT PREVIOUS CHAR
CAIN T3,.CHCRT ;A CR?
BKJFN ;YES. BACK UP AGAIN
JFCL
HRROI T2,[ASCIZ /-16.;BDATA:000000377377000000000/]
SETZM T3
SOUT ;FINISH OFF STRING
IDPB T3,T2 ;PUT IN A NULL
RET ;AND DONE
;^E INTERRUPT. REPROMPT FOR HOST NAME
GOTE: PUSH P,T1 ;SAVE A REG
MOVEI T1,START1 ;GET NEW ADDRESS
MOVEM T1,PC1 ;INTO THE BREAD PC
POP P,T1
MOVE P,[IOWD NPDL,PDL] ;RESET THE STACK
DEBRK ;AND GO DO IT
END START