;****************************************************************
;*								*
;*	>>>>>>> S o f t D e s i g n <<<<<<<			*
;*								*
;* self relocating receiver routine				*
;* for serial data transmission via cp/m reader channel		*
;* allows binary file transfer from host computer		*
;* by terminating file with five times eof			*
;* message is stored in tpa for save command			*
;*								*
;****************************************************************

; usage:

; enter program code on receiving computer
; using ddtz inline assembler with "a100" command
; or in hex using ddtz "s100" command.
; exit from ddtz to cpmz80 system by "g0" command.

; save as file read.com
; with "save 1 read.com" cpmz80 command.

; adjust transmission line parameters (baud rate, stop bits, parity)
; on sending and receiving computer.

; start read.com on receiving machine.

; to send file x:yyyyyyyy.zzz execute on sending machine
; "pip pun:=x:yyyyyyyy.zzz[o],eof:,eof:,eof:,eof:,eof:".

; save file on receiving machine
; with "save n x:yyyyyyyy.zzz" command.


; 100   21 0E 01 11  80 00 01 1C  00 ED B0 C3  80 00 21 00   !........m0C..!.
; 110   01 1E 05 E5  D5 0E 03 CD  05 00 D1 E1  77 23 FE 1A   ...eU..M..Qaw#~.
; 120   28 04 1E 05  18 ED 1D 20  EA C7 00 00  00 00 00 00   (....m. jG......
; 130   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00   ................
; 140   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00   ................
; 150   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00   ................
; 160   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00   ................
; 170   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00   ................



	.Z80
	ASEG
	ORG	0100H


BDOS	EQU	0005H
TPA	EQU	0100H
START	EQU	0080H

PROLEN	EQU	PROEND - PROGRM

EOF	EQU	1AH



READ:	LD	HL,PROGRM
	LD	DE,START
	LD	BC,PROLEN
RELOCT: LDIR			;relocate receiver program
	JP	START


PROGRM: LD	HL,TPA		;receiver program
	LD	E,5

GETCHR: PUSH	HL
	PUSH	DE
	LD	C,3
	CALL	BDOS		;get reader character
	POP	DE
	POP	HL

	LD	(HL),A
	INC	HL

ENDFL?: CP	EOF
	JR	Z,ISEOF
	LD	E,5
	JR	GETCHR

ISEOF:	DEC	E
	JR	NZ,GETCHR


EXIT:	RST	0


PROEND: END
                                                           