;  
; IEEE TEST PROGRAMM
;
R0 EQU 0000H ; I\O REG
R1 EQU 0001H ; INT1\STAT1
R2 EQU 0002H ; INT2\STAT2
R3 EQU 0003H ; SER.PO\SER.PO
R4 EQU 0004H ; ADDR STA\ADDR.MOD
R5 EQU 0005H ; COM.PA.TH\AUX.MOD
R6 EQU 0006H ; ADDR.0\ADDR.0/1
R7 EQU 0007H ; ADDR.1\EOS
ISL1 EQU 0030H ;INTERF.SEL
MYAD EQU 0008H ;READ MY ADDR.
;
; INITIALZATION
;
ORG 1000H
IDLE: CALL KEY
LDA KBY
CPI 31H
CZ INIT
CPI 32H
CZ SERE
CPI 33H
CZ REDA
MVI A,00H
STA KBY
JMP IDLE
;
KEY: IN 41H
RAR
RNC
IN 40H
STA KBY
RET
KBY: DB 0
;
INIT: MVI A,02H ;CHIP RESET
OUT ISL1+R5
MVI A,00H  ;CLEAR ACCU
OUT ISL1+R1 ;DISABLE INTERR.
NOP  
OUT ISL1+R2 
MVI A,21H
OUT ISL1+R4 ;SET T/R MO3,SET ADDR.MO1
IN ISL1+MYAD ;READ MY ADR. FROM SWITCH
STA ADFE
OUT ISL1+R6 ;MY ADDR.TO ADDR 0
MVI A,0E0H
OUT ISL1+R6 ;DISA.ADDR1
MVI A,0AH
OUT ISL1+R7 ;SET EOS CODE
MVI A,24H
OUT ISL1+R5 ;SET CLOCK FREQU.
MVI A,8CH
OUT ISL1+R5 ;SET AUX.MOD A
MVI A,0B3H
OUT ISL1+R5 ;SET AUX.MOD B
MVI A,60H
OUT ISL1+R5 ;SET PP AUX.MOD
XRA A ;CLEAR ACCU
STA STFE
OUT ISL1+R5 ;IMMEDIATE EXEC.
CALL IFC
RET
;
; SERIAL POLL
;
SERE: MVI A,3FH
CALL CST
OUT ISL1+R0
MVI A,13H
OUT ISL1+R5
MVI A,18H
CALL CST
OUT ISL1+R0
LXI B,0610H
CALL WAITA
MVI A,46H
CALL CST
OUT ISL1+R0
LXI B,0410H
CALL WAITA
MVI A,10H
OUT ISL1+R5
SERF:IN ISL1+R0
ANI 40H
JZ SERF
MVI A,11H
OUT ISL1+R5
MVI A,19H
CALL CST
OUT ISL1+R0
RET
;
; DATA OUT
;
DST:IN ISL1+R1
ANI 02H
JZ DST
MOV A,B
OUT ISL1+R0
RET
;
;DATA IN
;
DIN:IN ISL1+R1
ANI 01H
JZ DIN
IN ISL1+R0
MOV B,A
RET
;
; COMMAND OUT
;
CST:PUSH PSW
IN ISL1+R1
MOV D,A
CSS:IN ISL1+R2
MOV E,A
ANI 08H
JNZ CSU
IN ISL1+R4
ANI 40H
JNZ CSS
MVI A,11H
OUT ISL1+R5
NOP
NOP
JMP CSS 
CSU:POP PSW
RET
;
CHB : DW 0AE00H
STFE: DW 0
ADFE: DW 0
BUFF: DS 1025
;
; TALKER ADDR.
;
TAAD:MVI A,3FH
CALL CST
OUT ISL1+R0
MVI A,29H
CALL CST
OUT ISL1+R0
MVI A,46H
CALL CST
OUT ISL1+R0
LXI B,0610H
CALL WAITA
MVI A,10H   ;STAND BY
OUT ISL1+R5
RET
;
; INTERFACE CLEAR
;
IFC: MVI A,1EH ;SET IFC CODE
OUT ISL1+R5
LXI B,0110H ;SET DELAY COUNTER 100 USEC
CALL WAITA
MVI A,16H
OUT ISL1+R5
RET
;
; TIME DELAY
;
WAITA: DCR C
JNZ WAITA
MVI C,0FFH
DCR B
JNZ WAITA
RET
;
; RECEIVE DATA
;
REDA:MVI A,00H
STA CHB
CALL TAAD   
LXI H,BUFF
REDE: CALL DIN
MOV M,B
INX H
MVI A,0AH
CMP B
JNZ REDE
REDD:LDA CHB
MOV M,A
MVI A,11H
OUT ISL1+R5
RET
;
END































































