;PROGRAMM TRANSMIT
;
BOOT    EQU	00H
FDOS	EQU   	BOOT+5H
FCB     EQU   	BOOT+5CH
BUFFER	EQU   	BOOT+80H
TPA	EQU   	BOOT+100H
;
CONOUT  EQU   	BOOT+2H
RDRIN	EQU   	3
PUNOUT  EQU   	4
PRNTSTR EQU   	9
OPENF   EQU   	0FH
SEARCHF EQU   	11H
SEARCHN	EQU   	12H
READSEQ EQU   	14H
;
        ORG   	TPA
;
;
	LXI   	H,STACK
	SPHL
	LXI   	H,FCB
   	LXI   	D,FCB1
;
	MVI   	B,33
LOOP1:  MOV   	A,M
	STAX  	D
        INX   	H
 	INX   	D
 	DCR   	B
	JNZ   	LOOP1

   	LXI   	D,FCB
        MVI   	C,SEARCHF
	JMP   	SEARCH
	;
LOAD:   MVI   	C,OPENF
	LXI   	D,FCB
        CALL  	FDOS
        MVI   	A,00H
  	STA   	FCB+32
	MVI     A,'C'
	CALL  	SENDCHR
	MVI   	B,11
	LXI   	H,FCB+1
;
LOOP6:  MOV	A,M
	CALL	SENDCHR
	INX	H
	DCR	B
	JNZ	LOOP6
;
LOOP7:	MVI	C,READSEQ
	LXI	D,FCB
	CALL	FDOS
	CPI	0
	JNZ	EOF
	MVI	A,'N'
	CALL 	SENDCHR
	LXI	H,BUFFER
	MVI	B,128
;
LOOP8:	MOV	A,M
	CALL 	SNDBYTE
	INX	H
	DCR	B
	JNZ	LOOP8
	MVI	A,'*'
	CALL 	PRNTCHR
	JMP 	LOOP7
;
EOF:	CALL	CRLF
;SUCHE NAECHSTE DATEI
	LXI 	H,FCB1
	LXI 	D,FCB
	MVI	B,33
;
LOOP2:	MOV 	A,M
	STAX	D
	INX	H
	INX	D
	DCR	B
	JNZ	LOOP2
	LXI	D,FCB	
	MVI	C,SEARCHN
;
SEARCH:	CALL 	FDOS
	CPI	0FFH
	JZ	LAST
;
	RLC
	RLC	
	RLC
	RLC
	RLC
	LXI	H,BUFFER+1
	MOV	E,A
	MVI	D,00H
	DAD	D
	LXI	D,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