Trailing-Edge
-
PDP-10 Archives
-
BB-H348C-RM_1982
-
swskit-v21/demos/sender.mac
There are 3 other files named sender.mac in the archive. Click here to see a list.
;THIS PROGRAM READS A FILE, SENDS THE FILE DATA OVER A NETWORK
;LINK, AND PUTS ANY DATA SENT BACK TO IT OVER THE NETWORK LINK
;INTO AN OUTPUT FILE. THIS PROGRAM IS INTENEDED TO BE USED
;WITH AN ECHOER SUCH AS "EKONET".
;THE PROGRAM IS INTERRUPT DRIVEN. THE NON-INTERRUPT PORTION
;READ THE INPUT FILE, AND WRITES THE FILE DATA TO THE
;NETWORK. THE INTERRUPT PORTION READS ANY DATA SENT TO IT
;AND PUTS THAT DATA INTO THE OUTPUT FILE. ALSO, THE TWO PROTIONS
;COOPERATE TO DETERMINE WHEN ALL OF THE DATA HAS BEEN ECHOED,
;AND THE INTERRUPT PORTION IS RESPONSIBLE FOR CLOSING THE CONNECTION.
SEARCH MONSYM,MACSYM
.REQUIRE SYS:MACREL
SALL ;MAKE LISITNG NICE
;DEFINE VARIABLES AND STORAGE AREA
P==17 ;PUSH-DOWN POINTER
NPDL==10 ;SIZE OF PUSH-DOWN LIST
PDL: BLOCK NPDL ;RESERVE THE PUSH-DOWN LIST
CNTR: BLOCK 1 ;COUNT OF BYTES TO RECEIVE BEFORE EOF
SAVEAC: BLOCK 3 ;REGISTER SAVE AREA FOR PSI PORTION
LEVTAB: PC ;PC SAVE FOR LEVEL 1
PC ;FOR LEVEL 2 (UNUSED)
PC ;FOR LEVEL 3 (UNUSED)
PC: Z 0 ;PC SAVE ERROR FOR PSI
CHNTAB: 1,,GOTSOM ;CHANNEL 0 INTERRUPT FOR DATA ARRIVED
;START OF PROGRAM
START: RESET ;INITIALIZE PROCESS
MOVE P,[IOWD NPDL,PDL] ;SET UP PUSH-DOWN LIST
;GET A JFN FOR THE INPUT FILE
HRROI 1,[ASCIZ /
INPUT FILE NAME:/]
PSOUT ;PROMPT FOR INPUT FILE NAME
MOVX 1,GJ%OLD!GJ%CFM!GJ%SHT!GJ%FNS
MOVE 2,[.PRIOU,,.PRIIN] ;GET FILE NAME FROM TTY:
GTJFN
JRST [ JSERR ;OUTPUT ERROR
JRST START] ;AND START OVER
MOVE 14,1 ;SAVE JFN FOR LATER USE
MOVX 2,<FLD(44,OF%BSZ)+OF%RD> ;OPEN FILE FOR READ
OPENF
JRST [ JSERR ;PRINT OUT ERROR
JRST START] ;AND START OVER
SETZB 12,CNTR ;NOT AT EOF YET
SETZM 11 ;INITIALZIE INTERRUPT COUNTER
; ..
;GET A JFN FOR THE OUTPUT FILE
GETOUT: HRROI 1,[ASCIZ /
OUTPUT FILE NAME:/]
PSOUT ;PROMPT FOR OUTPUT FILE NAME
MOVX 1,GJ%FOU!GJ%CFM!GJ%SHT!GJ%FNS
MOVE 2,[.PRIOU,,.PRIIN] ;READ FILE NAME FROM TTY:
GTJFN
JRST [ JSERR ;PRINT OUT ERROR
JRST GETOUT] ;AND TRY AGAIN
MOVE 13,1 ;SAVE JFN FOR LATER USE
MOVX 2,<FLD(44,OF%BSZ)+OF%WR> ;OPENF FOR WRITE
OPENF
JRST [ JSERR ;PRINT OUT ERROR
JRST GETOUT] ;AND TRY AGAIN
;GET A JFN FOR THE NETWORK LINK
GETCON: HRROI 1,[ASCIZ /
DECnet File Specification (DCN:node-TASK-taskname.):/]
PSOUT ;PROMPT FOR NETWORK FILE SPEC
MOVX 1,GJ%SHT+GJ%FNS
MOVE 2,[.PRIOU,,.PRIIN] ;GET FILE NAME FROM TTY:
GTJFN
JRST [ JSERR ;PRINT ERROR
JRST GETCON] ;AND TRY AGAIN
MOVE 15,1 ;SAVE JFN OF CONNECTION
MOVX 2,<FLD(44,OF%BSZ)+OF%RD+OF%WR> ;OPEN FOR READ/WRITE
OPENF
JRST [ JSERR ;PRINT ERROR
JRST GETCON] ;AND TRY AGAIN
;SET UP INTERRUPTS FOR NETWORK JFN
MOVE 1,15 ;GET NETWORK JFN
MOVEI 2,.MOACN ;FUNCTION TO SET INTERRUPT ASSIGNMENTS
MOVX 3,<FLD(.MONCI,MO%CDN)+FLD(.MONCI,MO%INA)+FLD(0,MO%DAV)>
MTOPR ;SET INT CHANNELS
MOVEI 1,.FHSLF
MOVE 2,[LEVTAB,,CHNTAB]
SIR ;DEFINE INTERRUPT TABLES
MOVX 2,1B0
AIC ;TURN ON CHANNEL 0 ONLY
EIR ;ENABLE THE SYSTEM FOR THIS PROCESS
; ..
;NOW GET SOME FILE DATA
READ: MOVE 1,14 ;GET JFN OF INPUT FILE
MOVE 2,[POINT 36,10000]
MOVNI 3,1000 ;READ ONE ENTIRE PAGE
SIN ;GET NEXT PAGE
MOVE 2,[POINT 36,10000]
ADDI 3,1000 ;COMPUTE BYTES GOTTEN
ADDI 12,0(3) ;ACCUMULATE TOTOAL BYTES SENT OVER NETWORK
JUMPE 3,EOF ;IF NONE READ, MUST BE AT EOF
MOVNI 3,0(3) ;COMPUTE NEG OF BYTES TO SEND TO THE LINK
MOVE 1,15 ;GET NETWORK JFN
SOUTR ;WRITE TO THE NETWORK
MOVE 1,14 ;GET INPUT FILE JFN AGAIN
GTSTS ;GET STATUS
TXNN 2,GS%EOF ;AT EOF YET?
JRST READ ;NO. GO GET MORE FILE DATA
;AT THE EOF ON THE INPUT FILE
EOF: MOVEM 12,CNTR ;ALL DONE
;SAVE BYTE COUNT OF BYTES TO GET BACK
HRROI 1,[ASCIZ /
%EOF ENCOUNTERED
/]
PSOUT ;INFORM USER OF INPUT DONE CONDITION
MOVE 1,14
CLOSF ;CLOSE THE INPUT FILE
JFCL
WAIT ;AND WAIT
;DATA ARRIVED INTERRUPT HAPPENDED. READ ALL DATA
GOTSOM: DMOVEM 1,SAVEAC ;GOT SOME DATA. SAVE REGISTERS
MOVEM 3,SAVEAC+2 ;SAVE ALL REGS
GOTSO2: MOVE 1,15 ;GET NETWORK JFN
SIBE ;CHECK INPUT COUNT
JRST GOTSO1 ;HAVE SOME TO READ
;NO MORE DATA BYTES TO READ THIS TIME
SKIPN CNTR ;AT EOF ON INPUT SIDE?
JRST GOTSO4 ;NO
CAME 11,CNTR ;YES. GOT ALL BYTES YET?
JRST GOTSO4 ;NO
;ALL BYTES HAVE BEEN ECHOED. FINISH UP
MOVE 1,15 ;YES. GET JFN
CLOSF ;CLOSE CONNECTION
JFCL
MOVE 1,13 ;GET OUTPUT SIDE
CLOSF ;CLOSE IT TOO
JFCL
HALTF ;AND DONE
;NO MORE BYTES TO READ, BUT NOT ALL HAVE BEEN ECHOED YET
GOTSO4: DMOVE 1,SAVEAC ;RESTORE NON-PSI REGISTERS
MOVE 3,SAVEAC+2
DEBRK ;AND GO BACK TO THE NON-PSI PORTION
;HAVE SOME BYTES TO READ FROM THE NETWORK.
; 1/ NETWORK JFN
; 2/ COUNT OF BYTES TO READ
GOTSO1: ADDI 11,0(2) ;COUNT BYTES GOTTEN BACK
MOVNI 3,0(2) ;GET NEGATIVE OF BYTES TO READ
MOVE 4,3 ;SAVE COUNT FOR WRITTING TO OUTPUT FILE
MOVE 2,[POINT 36,20000]
SIN ;GET DATA
MOVE 2,[POINT 36,20000]
MOVE 3,4 ;GET BACK COUNT
MOVE 1,13 ;GET JFN OF OUTPUT FILE
SOUT ;WRITE THE DATA TO THE OUTPUT FILE
JRST GOTSO2 ;AND GOT CHECK FOR MORE BYTES
END START