COPAASM;---------------------------------
;      PROGRAMM COPY-PASTE
;
;KOPIEREN UND EINFUEGEN VON EDAS-
;QUELLTEXT UEBER RAM 8 BLOCK 0
;---------------------------------
CAOS:	EQU 0F003H
	ORG 0BA00H
PAADR:	DEFW 0
READY:	DEFB 0
MMERK:	DEFB 0
;
FTAST:	NOP		;F-TASTEN WIE
	DEFB 05H	;BEI FORMAT
	NOP
	DEFB 06H
	NOP
	DEFB 9CH	;STOP
	NOP
	DEFB 8FH	;START
	NOP
	DEFB 8CH	;N.N.
	NOP
	DEFW 0DDDDH
	DEFM 'COPY'
	DEFB 1
INIT0:	LD HL,FTAST
	LD DE,0B900H
	LD BC,0000BH
	LDIR
	LD HL,(48H)
	LD A,H
	OR L
	JR Z,S1
	CALL CAOS
	DEFM '#not ready!'
	DEFB 7
	NOP
	CALL CAOS
	DEFB 2CH
	RET
S1:	CALL PADR
	LD HL,COPY1
	LD BC,PASTE1-COPY1
	LDIR
	CALL RAM8ON
	LD HL,(46H)
	LD BC,(44H)
	XOR A
	SBC HL,BC
	LD BC,(40H)
	ADD HL,BC
	PUSH HL
	LD DE,(42H)
	INC DE
	EX DE,HL
	XOR A
	SBC HL,DE
	LD B,H
	LD C,L
	POP HL
	LD DE,8000H
	CALL JUMP
	LD A,3
	LD (READY),A
	INC DE
	BIT 6,D
	JR Z,S2
	CALL CAOS
	DEFM '#memory overflow!'
	DEFW 0A0DH
	DEFB 7
	NOP
S2:	DEC DE
	EX DE,HL
	LD DE,8000H
	XOR A
	SBC HL,DE
	CALL CAOS
	DEFB 1AH
	CALL CAOS
	DEFM '#bytes copied'
	DEFW 0A0DH
	NOP
	CALL RAMRET
	LD HL,PASTE
	LD (0B799H),HL
	RET
;			COPY
COPY1:	IN A,(88H)
	RES 2,A
	OUT (88H),A
S10:	LD A,8FH
	CPIR
	JR Z,S11
S12:	LD A,3
	LD (DE),A
	IN A,(88H)
	SET 2,A
	OUT (88H),A
	RET
;
S11:	LD A,M
	CP 9CH
	JR Z,S10
	CP 3
	JR Z,S12
	LDI
	BIT 6,D
	JR Z,S11
	DEC DE
	JR S12
;			PASTE
PASTE1:	IN A,(88H)
	RES 2,A
	OUT (88H),A
S20:	LD A,M
	INC HL
	CP 0AH
	JR Z,S20
	CP 3
	JR Z,S21
	LD (DE),A
	INC E
	DJNZ S20
S21:	LD B,A
	IN A,(88H)
	SET 2,A
	OUT (88H),A
	LD A,B
	RET
;
PASTE:	CALL PADR
	LD HL,PASTE1
	LD BC,PASTE-PASTE1
	LDIR
	CALL RAM8ON
	CALL DADR
	EX DE,HL
	LD HL,8000H
	LD A,(READY)
	CP 3
	JR Z,S30
	LD HL,(PAADR)
S30:	LD B,0BFH
	CALL JUMP	;A=B !
	LD (PAADR),HL
	LD (READY),A
	XOR A
	LD (DE),A
	LD A,B
	CP 3		;letzter Block?
	JR NZ,S31	;nein
	LD A,7
	CALL CAOS	;BEEP
	NOP
S31:	CALL RAMRET
	CALL DADR
	LD (0B7D1H),HL
	SET 6,(IX+8)
	LD DE,(0B7A0H)
	RET
;
; Programm-Adresse = Beginn des Marken-
;		     bereiches
; Daten-Adresse = Programm-Adresse + 40
;
DADR:	LD HL,(70H)
	LD BC,40H
	ADD HL,BC
	RET
PADR:	LD HL,(70H)
	LD (JUMP+1),HL
	EX DE,HL
RET:	RET
JUMP:	JP RET		;zum Programm
;
; Schalten eines 16K-Blockes auf
; Adresse 8000H, auf den nach Ab-
; schalten des IRM zugegriffen wird.
;
RAM8ON:	LD A,(0B803H)
	LD (MMERK),A
	LD D,3
	LD L,3
	LD A,2
	CALL CAOS
	DEFB 26H
	RET
;
; R}ckschalten des RAM
;
RAMRET:	LD A,(MMERK)
	LD D,A
	LD L,3
	LD A,2
	CALL CAOS
	DEFB 26H
	RET
ےےےےےےےےےےےےےےےےےےےےےےےےےےےےےےےےےےےےےےے