
 .TITLE EEG DATA
 .ABS
/ DEF'N  IOT'S
/
MTCL=707302
MTLC=707304
MTGO=707344
MTRS=707352
MTSE=707341
MTSF=707301
/
DACX=701544
DACY=701524
DAC1=701561
DA2=701521
/
ADST=701502
ADRD=701532
ADSF=701501
/
RTCF=705342
RTSF=705341
RTLD=705222
RTLB=705324
RTST=705321
/
TLS=700406
TCF=700402
TSF=700401
/
KRB=700312
KSF=700301
/
ION=700042
IOF=700002
EBA=707764
LAS=750004
/
/
/ INTERUPT HANDLER
/
 .LOC 0
PIC 0    /RET. ADDR.
 JMP SKPCHN    /GO TO SKIP CHAIN
/
 .LOC 50
SKPCHN IOF
 DAC AC
 ADSF
 SKP
 JMP ADCF    /ADC FLG.
 RTSF
 SKP
 JMP ADCT     /RTC FLG.
 MTSF
 SKP
 JMP MTFLG
 MTSE
 SKP
 JMP MTERR   /MAG TAPE ERROR.
AC 0
/
 LAC (ILLINT    /ILLEGAL INTERUPT
 JMS MSG
 LAC (JMP* PIC
 DAC .+2
 ION
 NOP
/
/
INIT JMS MTREW
 JMS CRLF
 JMS CRLF
 LAC (240
 JMS PRNT
 JMS PRNT
 LAC (MHDR
 JMS MSG    /PRINT PROG. HEADER
/
START LAC (QTAG
 JMS MSG
 LAC (76
 JMS PRNT
 JMS INPUTI
 DAC N   /TAG #
/
/
/ CLEAR DATA BUFFER
 LAC (BUF
 DAC TEMP
 LAC (-2067
 DAC TST
CLLOOP DZM* TEMP
 ISZ TEMP
 ISZ TST
 JMP CLLOOP
/ BUFFER CLEARED
/
 LAC (QLABEL
 JMS MSG     /ASK FOR DATA LABEL
 LAC (76    / '>'  PROMPT
 JMS PRNT
 JMS INPUTC   /INPUT CHAR. STRING
 LBLBUF      /ADDR. FOR CHAR. STRING
/
 LAC (QNPT
 JMS MSG     / ASK FOR # OF SAMPLES
 LAC (76
 JMS PRNT
 JMS INPUTI   /INPUT DEC. INT.
 DAC NS
 TCA
 DAC DCNT   / INIT. DISPLAY &
 DAC ICNT  / INPUT CNT.
 LAC NS
 ADD (377
 RTR         / DIV. BY 256
 RTR
 RTR
 RTR
 AND (7
 DAC NBLK    / # OF 256WD DATA BLKS.
 TCA
 DAC OCNT
/
 LAC (QTIME
 JMS MSG        /ASK FOR TIMING INTERVAL
 LAC (76
 JMS PRNT
 JMS INPUTI
 DAC TIME
/
 LAC (BUF
 DAC DPT
 DAC IPT
 DAC OPT
/
 JMS STTM  /START TIMING
 ION
/
/ LOOP TO DISPLAY INPUT
/ TO EXIT - ADC & RTC INTERUPT
/
LOOP JMS DISP
 NOP
 JMP LOOP
/
/ INFIN - INPUT STREAM FINISHED
/    ENTERED VIA ADCF
INFIN LAC (HDRBUF-1   /INPUT FIN
 EBA    /ENABLE BANK ADDR.
 DAC 17763            /START OUTPT.
/
 LAW -416   /WD. COUNT (270 DEC.)
 DAC 17762
 RTCF
 MTCL
 LAC MTWRT    /WRITE HEADER BLK.
 MTLC
 MTGO
/
 LAC AC   /RESTORE ACC.
 ION
/
OLOOP JMS DISP   /LOOP WHILE WAITING FOR OUTPUT
 LAS
 SAD (1
 JMP START
 JMP OLOOP
/
/ OLOOP EXIT BY MAG. TAPE FLGS
MTFLG LAC PIC
 DAC MPIC    /SAVE PI PT.
 EBA
 LAW -416
 DAC 17762
 LAC OPT      /OUTPUT BLK ADDR. PT
 TAD (-1
 DAC 17763    / CA-1
 MTCL
/
 LAC MTWRT
 MTLC
 MTGO        /WRITE A DATA BLK
/
 LAC OPT
 ADD (416
 DAC OPT    /NEW DATA BLK PT.
/
 ISZ OCNT
 SKP
 JMP OFIN    /ALL BLKS WRITTEN
 ION
 LAC AC
 JMP* MPIC   /MORE BLKS TO BE WRITTEN; DISPLAY & WAIT FOR FLGS
MPIC 0
/
/
OFIN IOF
 JMP OLOOP   /STAY IN DISP. LOOP
/
/ DISPLAY ROUTINE:
DISP 0
 DAC1
 DAC2     /SET DAC MODE
 LAC* DPT   /GET ARG
 DACY
 LAC DCNT       /INDEX
 RTL
 RTL
 RTL    /ADJ.
 DACX    /DISPLAY X
/
 ISZ DPT   /INC. PT.
 ISZ DCNT  /INC COUNT
 JMP* DISP   /CONT. DISPLAYING
/
 LAC (BUF   /1 LOOP FIN.
 DAC DPT    /RE-INIT. PT. & CNT.
 LAC NS
 TCA
 DAC DCNT
 JMP* DISP
/
/
/  START TIMING ROUTINE
RTWT=705324
STTM 0
 RTCF   /CLEAR FLG.
 LAC TIME   / IN MSEC.
 RTLD
 RTWT
 700000
 700000
 700000   /WT.
 RTST     /START 
 JMP* STTM
/
/
/  ADC  START CONV.
ADCT LAC PIC   /RTC PIC ENTRY
 DAC APIC
 ADST    /START COVERSION
 JMS STTM   /START TIMING
 LAC AC    /RESTORE AC
 ION
 JMP* APIC
APIC 0
/
/
/ READ AND STORE ADC BUFFER
ADCF LAC PIC    /ADC PIC ENTRY
 DAC ADPIC
 ADRD    /READ BUFF.
 TCA
 DAC* IPT
 ISZ IPT
 ISZ ICNT   /INC. & TEST IF INPUT FIN.
 SKP
 JMP INFIN  /INPUT IS FIN.
 ION        /NOT FIN.
 JMP* ADPIC
ADPIC 0
/
/
/  MT ERROR HANDLER
/ ON ERR. BCKSPC. & RE-WRITE
MTERR LAC OPT    /MT ERR PIC ENTRY
 TAD (-416     /BACK UP OUTDATA PT.
 DAC OPT
/
 LAC OCNT
 TAD (-1
 DAC OCNT    /MOVE BACK CNT.
/
 LAC (-416
 DAC 17762
 LAC (DUM-1
 DAC 17763
 LAC BKSPC    /READ REV.
 MTLC
 MTGO   /READ INTO DUM
 MTSF
 JMP .-1
 JMP MTFLG   /RE - WRITE THE BLK.
BKSPC 100000
/
/
/
/ OUTPUT A .SIXBT MSG TERMN. BY CRLF
/  STRING MUST BE TERM. BY A 00 CHAR.
/
MSG 0
 IOF
 DAC BPT   /SAVE BUFF. POINTER
MLOOP LAW -3  / 3 CHAR. PER WD.
 DAC TST
 LAC* BPT   / GET WD.
 DAC TEMP
/
RLOOP LAC TEMP   /LOOP 3X PER WD/
 RTL
 RTL
 RTL    / MSB IN LINK , THEN ROT 6 BIT
 DAC TEMP
 RAL
 AND (77
 DAC CHAR
 SNA
 JMP MSGFIN   /END OF BUFF
 AND (40    /TEST IF
 SNA        /ALPH
 JMP .+4
 LAC CHAR   / NON-ALPH
 XOR (200
 JMP .+3
 LAC CHAR   / ALPH
 XOR (300
 JMS PRNT   /PRINT THE CHAR
 ISZ TST    /IS WD. COMPLETE ?
 JMP RLOOP  /NO
 ISZ BPT
 JMP MLOOP  /YES
MSGFIN JMS CRLF
 JMP* MSG
CHAR 0
/
/  PRINT 8- BIT CHAR
PRNT 0
 TLS
 TSF
 JMP .-1
 TCF    /CLEAR FLAG
 JMP* PRNT
/
/
/
/ INPUT AN 18 BIT DECIMAL INTEGER
/
INPUTI 0
 IOF
 LAW -6
 DAC CNTI   /MAX 6 DIGITS
 DZM NUM /CLEAR RESULT
 JMS RD   /GET 1ST CHAR.
 SAD (215   /CHECK IF CR.
 JMP IFIN  / END OF NUMBER
 SAD (377
 JMP INUL  /NULL
 AND (17   /GET LOWER 4 BITS
 DAC NUM
 ISZ CNTI   /1ST DIGIT
ILOOP JMS RD
 SAD (215
 JMP IFIN
 SAD (377
 JMP INUL
 AND (17
 DAC TEMP
 LAC NUM   /MULT. PREVIOUS REA;SULT X10
 RAL  /X2
 DAC NUM
 RTL
 ADD NUM
 ADD TEMP
 DAC NUM  /+ LAST DIGIT
 ISZ CNTI
 JMP ILOOP  /DO NEXT DIGIT
IFIN JMS CRLF /FORCE FINISH IF OVERFLO
 LAC NUM
 JMP* INPUTI
/
INUL LAC (215
 JMS PRNT
 LAC (240
 .REPT 7
 JMS PRNT
 LAC (215
 JMS PRNT
 LAC (76
 JMS PRNT
 JMP INPUTI+2
/
/
CRLF 0
 LAC (215
 JMS PRNT
 LAC (212
 JMS PRNT
 JMP* CRLF
/
/
/
/ INPUTC - INPUT A CHAR STRING UNTIL CR. ENCOUNTERED
/
INPUTC 0
 LAC* INPUTC     /BUFFER ADDR.
 DAC ALPHNUM
/
/ INITIALIZE BUFF. TO BLKS.
 LAC ALPHNUM
 DAC TEMP
 LAC (-404
 DAC TST
 LAC (40
CLOOP DAC* TEMP   /CLEAR TO BLKS
 ISZ TEMP
 ISZ TST
 JMP CLOOP
/
ICLOOP JMS RD   /READ A CHAR. FROM TTY
 SAD (377    /CHECK IF NULL
 JMP ICNUL
 SAD (215       /CHECK IF CR
 JMP ICFIN
 DAC* ALPHNUM
 ISZ ALPHNUM
 JMP ICLOOP     /GO FOR ANOTHER CHAR.
ICFIN ISZ ALPHNUM  /FIN. (CR ENCOUNTERED)
 DZM* ALPHNUM    /TERM.
 JMS CRLF
 ISZ INPUTC
 JMP* INPUTC  /RETURN
/
ICNUL LAC (257   /RUB-OUT
 JMS PRNT
 JMS CRLF
 JMP INPUTC+1   /START OVER
ALPHNUM 0
/
/
RD 0   /READ A CHAR. FROM TTY
 KSF
 JMP .-1
 KRB
 JMP* RD
/
/
MTREW 0  /REWIND MAGTAPE
 LAC (4000
 MTLC
 JMP* MTREW
/
/
/   BUFFERS:
/
HDRBUF 707070   /FLAG
N 0
TIME 0
NS 0
 .REPT 6
 0
LBLBUF .BLOCK 404   /REST OF LABEL BUFF.
BUF .BLOCK 2070   /MAIN DATA BLOCK
DUM .BLOCK 416  /DUMMY BLK USED FOR REV. READ
/
/ SIXBT MESSEAGES :
/
MHDR .SIXBT 'EEG DATA AQUISITION PRGM'
 0
QTAG .SIXBT 'ENTER TAG NO.'
 0
QLABEL .SIXBT 'ENTER DATA LABEL'
 0
QNPT .SIXBT 'ENTER NO. OF SAMPLES'
 0
QTIME .SIXBT 'ENTER TIMING INTERVAL IN MSEC.'
 0
ILLINT .SIXBT 'ILLEGAL INTERUPT'
 0
/
/ CONSTANTS:
/
DCNT 0
ICNT 0
OCNT 0
DPT 0
IPT 0
OPT 0
TEMP 0
CNTI 0
NBLK 0
MTWRT 40700
BPT 0
TST 0
NUM 0
/
 .END INIT
