BAK2ASM 
 
 
 
 
;   Programmteil 2	(P2)
 
 
 
	;TEST FUER PIO-INTERRUPT KC 85/4
	;===============================
 
 
KIST	EQU	8128H	;KEYBOARD
KSOLL	EQU	8328H
TIST	EQU	8928H	;TAPE
TSOLL	EQU	8B28H
MOON	EQU	9108H	;AUSGABEZUST PIO
			;PORT A
	;-------------------------------
	;HAUPTPROGRAMM
 
	ORG	ENDT1
 
 
 
KBTAPE	HALT
 
 
 
	;UNTERPROGRAMME
	;--------------
 
 
CLS:	POP	IY	;RET
	LD	A,0AH	;FARBSPEICHER
	OUT	(84H),A	;LOESCHEN
	LD	HL,8000H
	LD	DE,8001H
	LD	BC,27FFH
	LD	M,39H
	LDIR
	LD	A,08H	;PIXELSPEICHER
	OUT	(84H),A	;LOESCHEN
	LD	HL,8000H
	LD	DE,8001H
	LD	BC,27FFH
	LD	M,0
	LDIR
	PUSH	IY	;RET
	LD	IY,8108H
	RET
 
;***************************************
;******** UP Signatur *****************
;
;   PE: HL     = Startadresse
;	DE     = Laenge Speicherbereich
;   PA: DE     = IST-Signatur
;
;   VR: AF/BC/DE/HL
;
;***************************************
;
SIGN	PUSH DE
	POP  BC
PRUSU 	LD   DE,-1
PRUS1	LD   A,M
	XOR  D
	LD   D,A
	RRCA
	RRCA
	RRCA
	RRCA
	AND  0FH
	XOR  D
	LD   D,A
	RRCA
	RRCA
	RRCA
	PUSH AF
	AND  1FH
	XOR  E
	LD   E,A
	POP  AF
	PUSH AF
	RRCA
	AND  0F0H
	XOR  E
	LD   E,A
	POP  AF
	AND  0E0H
	XOR  D
	LD   D,E
	LD   E,A
	INC  HL
	DEC  BC
	LD   A,B
	OR   C
	JR   NZ,PRUS1
	RET
 
	;LDIR    IRM-TEST FUER KC85/4
	;============================
 
IRM5:	LD	IY,5555H
	JR	IRM
IRMA:	LD	IY,0AAAAH
IRM:	LD	A,4FH
	OUT	(8AH),A
	LD	A,3FH
	OUT	(88H),A
	LD	A,0FH
	OUT	(8AH),A
	LD	A,0AH
	OUT	(84H),A
	LD	SP,0A000H
	LD	HL,8000H
	LD	DE,8001H
	LD	BC,3FFFH
	LD	M,39H
	LDIR
	LD	A,08H
	OUT	(84H),A
	PUSH	IY
	POP	AF
IRMLOP	LD	HL,8000H
	LD	DE,8001H
	LD	BC,3FFFH
	LD	M,A
	LDIR
	JR	IRMLOP
 
 
 
 
	;LDIR    RAMTEST FUER KC 85/4
	;============================
 
RAM5:	LD	SP,0A000H
	CALL	CLS
	LD	HL,RT55
	CALL	TEXT
	LD	A,55H
	PUSH	AF
	JR	RAM
RAMA:	LD	SP,0A000H
	CALL	CLS
	LD	HL,RTAA
	CALL	TEXT
	LD	A,0AAH
	PUSH	AF
RAM:	LD	A,4FH
	OUT	(8AH),A
	LD	A,0FFH
	OUT	(88H),A
	LD	A,0FH
	OUT	(8AH),A
	LD	A,03H
	OUT	(86H),A
	POP	AF
RAMLOP	LD	HL,0
	LD	DE,1
	LD	BC,07FFFH
	LD	M,A
	LDIR
	JR	RAMLOP
 
 
 
; Verkopplungstest und Bittest RAM
; --------------------------------
 
;---------------------------------------
ADTAB	EQU	0A001H
FEHL	EQU	0A000H+20
 
RAMVE:	DI
	IM	2
	LD	A,98H
	LD	I,A
	LD	IX,9000H
	LD	(IX),0
	LD	SP,0A000H
	LD	A,0FH
	OUT	(P1AS),A
	OUT	(P1BS),A
	LD	A,0EH
	OUT	(P1AD),A
	LD	A,60H
	OUT	(P1BD),A
	LD	A,28H
	OUT	84H
	LD	A,3
	OUT	86H	 ;RAM4 ON
	CALL	CLS
 
	LD	HL,0     ;RAM0
	LD	M,0	 ;LOESCHEN
	LD	DE,1
	LD	BC,03FFFH
	LDIR
	LD	HL,ADTAB  ;FEHLERTABELLE
	LD	M,0	  ;LOESCHEN
	LD	DE,ADTAB+1
	LD	BC,16
	LDIR
	LD	HL,0
	LD	DE,3FFFH  ;ANZAHL
	XOR	A
	LD	(FEHL),A  ;FEHLER-MZ
	LD	M,55H	  ;ERSTE ZELLE
	LD	A,M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	IY	;POS
	PUSH	HL
	LD	HL,ABFEH
	CALL	TEXT
	LD	A,B	;AUS OFFSET WIRD
	DEC	A	;BIT BESTIMMT
	ADD	0
	DAA
	CALL	TEXBY
	LD	HL,PIN
	CALL	TEXT
	LD	HL,PITAB ;PINTABELLE
	LD	A,B	 ;ZUR UMRECHNUNG
	AND	7	 ;A0-A7 = A8-A15
	ADD	L
	JR	NC,DR2
	INC	H
DR2:	LD	L,A
	LD	A,M	;AUSLESEN PIN
	CALL	TEXBY	;DRUCK
	POP	HL
	POP	IY
	LD	DE,8
	ADD	IY,DE
	RET
PITAB:	DEFW	0509H	;PINTABELLE
	DEFW	0607H
	DEFW	1112H
	DEFW	1310H
;---------------------------------------
 
; BLOCKTEST MIT 1 BYTE
 
BBBT:	LD A,0FH
	OUT 8AH
	OUT 8BH
	LD A,0AH
	OUT 88H		;IRM OFF
	LD A,60H
	OUT 89H
	LD A,28H
	OUT 84H		;RAF0
	LD A,3
	OUT 86H
	LD	HL,0
	LD	M,0
	LD	HL,4000H
	LD	M,0
	LD	HL,8000H
	LD	M,0
	LD	HL,0C000H
	LD	M,0CCH
	LD	A,(0)
	CP	0
	JP	NZ,BLER
	LD	A,(4000H)
	CP	0
	JP	NZ,BLER
	LD	A,(8000H)
	CP	0
	JP	NZ,BLER
 
	LD	HL,8000H
	LD	M,88H		;RAF0
	LD	A,(0)
	CP	0
	JR	NZ,BLER
	LD	A,(4000H)
	CP	0
	JR	NZ,BLER
	LD	A,(8000H)
	CP	88H
	JR	NZ,BLER
 
	LD	A,38H
	OUT	84H		;RAF1
	LD	M,99H
	LD	A,(8000H)
	CP	99H
	JR	NZ,BLER
	LD	A,28H
	OUT 	84H		;RAF0
 
	LD	HL,4000H
	LD	M,44H
	LD	A,(0)
	CP	0
	JR	NZ,BLER
	LD	A,(4000H)
	CP	44H
	JR	NZ,BLER
	LD	A,(8000H)
	CP	88H
	JR	NZ,BLER
 
	LD	HL,0
	LD	M,11H
	LD	A,(0)
	CP	11H
	JR	NZ,BLER
	LD	A,(4000H)
	CP	44H
	JR	NZ,BLER
	LD	A,(8000H)
	CP	88H
	JR	NZ,BLER
	LD	HL,TBLOK
	LD	IY,8118H
	LD	A,0EH
	OUT	88H	;IRM ON
	CALL	TEXT
	JR	BLT1
BLER:	LD	B,A
	LD	A,0EH
	OUT	88H	;IRM ON
	PUSH	HL
	LD	HL,TBLER
	LD	IY,8118H
	CALL	TEXT
	POP	HL
	LD	A,H
	CALL	TEXBY
	LD	A,L
	CALL	TEXBY
	LD	A,B
	CALL	TEXBY
 
; DATENTEST MIT 16K-BLOECKEN
 
BLT1:	LD	HL,0
	CALL	DAT	;0-4000
	LD	HL,4000H
	CALL	DAT	;4000-8000
	LD	SP,100H
	LD	A,0AH
	OUT	88H	;IRM OFF
	LD	HL,8000H
	CALL	DAT	;RAF0
	LD	A,38H
	OUT	84H
	LD	HL,8000H
	CALL	DAT	;RAF1
 
	LD	A,0EH
	OUT	88H	 ;IRM ON
	LD	IY,8128H
	LD	HL,KDF
	CALL	TEXT	 ;KEIN DATENFEH
DA1:	LD	HL,OK	 ;ENDE
	LD	IY,81C0H
	CALL	TEXT
	HALT
 
;UP 16K-BLOCK DATENTEST
 
; PE: HL=ANFANGSADRESSE
 
DAT:	PUSH HL
	LD M,55H
	INC HL
	LD M,0AAH
	LD D,H
	LD E,L
	DEC HL		;QUELLE
	INC DE		;ZIEL
	LD BC,3FFEH
	LDIR		;FILL 55,AA
	LD BC,410	;RUND 6ms
DA8:	DEC BC
	LD A,B
	OR C
	JR NZ,DA8	;ZEITSCHLEIFE
 
	POP HL
	LD BC,2000H
	LD D,55H
	LD E,0AAH
DA7:	LD A,M
	XOR D
	JR NZ,ERR1
	INC HL
	LD A,M
	XOR E
	JR NZ,ERR1
	INC HL
	DEC BC
	LD A,B		 ;GESAMTER BER.
	OR C
	JR NZ,DA7
	RET
 
ERR1:	LD	IY,8130H
	LD	B,A
	LD	A,0EH
	OUT	88H	 ;IRM ON
	LD	A,B
	LD	B,8	 ;SUCHEN UND
ER2:	RLA		 ;DRUCKEN DER
	CALL	C,DRDA	 ;FEHLER-BITS
	DJNZ	ER2
	JP 	WAIT	 ;ZELLE WR/RD
 
DRDA:	PUSH	AF
	PUSH	HL
	PUSH	IY
	LD	HL,DBFEH
	CALL	TEXT
	LD	A,B	;B AUS SUCHE
	DEC	A	;WIRD ZU BIT
	CALL	TEXBY	;DRUCK
	POP	IY
	LD	DE,8
	ADD	IY,DE
	POP	HL
	POP	AF
	RET
 
;---------------------------------------
 
FARBT:	LD 	SP,100H
	CALL	CLS
	LD	A,0FH
	OUT	8AH
	OUT	8BH
	LD	A,0EH
	OUT	88H
	LD	A,8
	OUT	84H	;PIX
 
	LD HL,8000H
	LD DE,8001H
	LD BC,27FFH
	LD M,0FFH
	LDIR		;/CLS
 
	LD C,20
	LD DE,80H
	LD HL,9480H
FARB0:	LD B,80H
FARB1:	LD M,0
	INC HL
	DJNZ FARB1	;SW ECKE
	ADD HL,DE
	DEC C
	JR NZ,FARB0
 
	LD A,0AH
	OUT 84H		;FARBE
	LD IY,FATAB
	LD HL,8000H
	LD DE,8001H
	LD BC,200H
	LD M,0
	LDIR		;2 REIHEN SW
FARB4:	LD A,(IY)
	LD M,A
	INC IY
	LD BC,300H
	LDIR
	CP 36H		;LETZT?
	JR NZ,FARB4
	LD BC,200H
	LD M,3FH
	LDIR		;2 REIHEN WS
	HALT
 
FATAB:	DEFW 4808H	;VIOL,BL
	DEFW 5810H	;PUP-RT,RT
	DEFW 1868H	;PUR,BLGN
	DEFW 2251H	;GN/RT,OR/BL
	DEFW 2C63H	;TUR/GR,GRBL/PUR
	DEFW 3675H	;GB/GB,GBGN/TUR
 
 
CSCTC:	LD	SP,0A000H
	LD	IX,100H
	CALL	CLS
	LD	HL,TCTC
	CALL	TEXT
	IM	2
	LD	A,0A0H
	LD	I,A
	LD	HL,INTK0 ;INTTAB
	LD	(0A0F0H),HL
	LD	HL,INTK1
	LD	(0A0F2H),HL
	LD	HL,INTK2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