.RADIX 16
	LXI D,END
	LXI B,MAI
	LXI H,0A000
	INR D
COPY:	LDAX B
	MOV M,A
	INX B
	INX H
	MOV A,H
	CMP D
	JNZ COPY
MAI:	.PHASE 0A000
	JMP MAINA
FORM61:	DB 1B,"61",1B,"80",0
TITR:DB	0C ;***************************************************
DB 0D,0A,	"   Turbo MONITOR   Ver 2.0 for 13.11.93  (C)AZMaster"
DB 0D,0A,	00 ;***************************************************
SYMB	EQU	0E2E9
KL	EQU	0E18F
INV	EQU	0E850
HRG	EQU	0BF80
TBU	EQU	0BF82
LEN	EQU	0BF60
LTB	EQU	0BF50
BF83	EQU	0BF83
STAT	EQU	0E113
RLAT	EQU	0BFEC
STRT	EQU	0BF70
STECK	EQU	0BF00
STSP	EQU	0BF4F
RSD	EQU	0BFA0
RST:	DI
	SHLD RSD+5
	LXI H,2
	DAD SP
	SHLD RSD+3
	POP H
	SHLD RSD+1
	SHLD HRG
	LXI SP,RSD+0D
	PUSH PSW
	PUSH B
	PUSH D
	LXI SP,STSP
	MVI A,0C3
	STA RSD
	CALL RSTPR
RSKL:	CALL KLVC
	CPI 0D
	JNZ RSKL
RSTR:	LXI SP,RSD+7
	MVI A,0C3
	STA RSD
	POP D
	POP B
	POP PSW
	LXI SP,RSD+3
	POP H
	SPHL
	LHLD RSD+5
	JMP RSD

RSTPR:	CALL D0A
	LXI D,RSDAT	;RST 01 
	LXI H,RSD+2
RSPR:	MVI B,3
RSP:	LDAX D
	MOV C,A
	ORA A
	RZ
	CALL SYM
	INX D
	DCR B
	JNZ RSP
	MVI C,"="
	CALL SYM
	MOV A,M
	CALL HEX
	DCX H
	MOV A,M
	CALL HEX
	INX H
	INX H
	INX H
	CALL PRB
	JMP RSPR
RSDAT:DB " PC SPH,LD,EB,CA,F",0

MAINA:	LXI H,00100
	SHLD HRG
	MVI A,0C3
	STA 08
	LXI H,RST
	SHLD 09
	CALL BEEP
MAIN:	LXI SP,STSP
	LXI D,FORM61
	CALL PRINT
	LXI D,TITR
	CALL PRIND
	LXI D,0363D
	CALL CURC
MON:	LXI D,0300
	CALL SCRN
	CALL LPS
	LXI D,0520
	CALL CURC
	LXI H,DANN
TIT:	CALL PRB
	MOV C,M
	CALL SYM
	INX H
	MOV A,M
	ORA A
	JNZ TIT
HR0:	LHLD HRG
	MVI L,0
ADR:	CALL CRLF
PRH:	MOV A,M
	CALL HEX
	INR L
	MOV A,L
	ANI 0F
	CPI 0
	JNZ PRH
	MOV A,L
	SUI 10
	MOV L,A
	CALL PRB
	CALL BUK
	MOV A,L
	CPI 0
	JNZ ADR
	CALL D0A
	CALL LPR
	LXI D,0363D
	CALL CURC
	CALL RSTPR
	LXI D,INFO
	CALL PRIND
	LHLD HRG
KUR:	LXI D,00405
	MOV A,L
	ANI 0F0
	RRC
	RRC
	RRC
	RRC
	ADD D
	MOV D,A
	MOV A,L
	ANI 0F
	ADD A
	ADD E
	MOV E,A
	CALL SCRN
	LDA TBU
	CPI 09
	JZ TABU
M0:	MVI B,1
M2:	CALL KLV
	MOV C,A
	CPI 03		;EXIT
	JZ EXIT
	CALL POKE
	MOV A,B
	ORA A
	JNZ M6
	CALL RE1
	JMP M2
M6:	MOV A,C
	CPI 09
	JNZ M7
	STA TBU
	JMP KUR
TABU:	CALL A0D
	MVI E,26
LD0F:	MOV A,L
	ANI 0F
	ADD E
	MOV E,A
	CALL SCR1
TAB1:	CALL KLVC
	CPI 09
	JNZ M7
	XRA A
	STA TBU
	JMP KUR
M7:	CPI 8B		;SEARCH
	JZ SEARCH
	CPI 9E
	JZ F1
	CPI 81
	JZ F2
	CPI 86
	JZ F3
	CPI 92
	JZ F4
	CPI 83
	JZ F5
	LDA TBU
	CPI 09
	MOV A,C
	JNZ M8
	CALL M9
	JMP TAB1
M9:	CPI 93
	JZ LETA
	CPI 08
	JZ LETA
	CPI 84
	JZ RGTA
	CPI 85
	JZ UP
	CPI 98
	JZ DOWN
	ANI 7F
	CPI 20
	MOV M,C
	JNC MET1
	MVI C,20
	CPI 0D
	JNZ MET1
	CALL SYM
	CALL RGT1
	MVI M,0A
	MVI C,20
MET1:	CALL SYM
	JMP RGT1
LETA:	MOV A,L
	ORA A
	RZ
	ANI 0F
	JNZ LT1
	MVI C,19
	CALL SYM
	LXI D,01018
	CALL CURC
LT1:	DCR L
	MVI C,08
	JMP SYM
RGTA:	MVI C,18
	CALL SYM
RGT1:	INR L
	JZ LT1
RGT2:	MOV A,L
	ANI 0F
	RNZ
	LXI D,01008
	CALL CURC
	MVI C,0A
	JMP SYM
M8:	CPI 1B		;MONITOR
	JNZ M3
	CALL NIZ
	JMP RSTR
M3:	CPI 0D		;MAIN
	JZ MAIN
	CPI 99		;FILL
	JZ FILL
	CPI 7F		;FIL
	JZ FIL1
	CPI 2B
	JZ PLUS
	CPI 2D
	JZ MIN
	CPI "G"		;GOTO
	JNZ RRST
	LXI D,MAIN
	PUSH D
	PCHL
RRST:	CPI "X"		;REN RST01
	JNZ JAMP
RRS0:	LXI D,1504
	LXI H,RSD+2
RRS1:	PUSH D
	CALL SCRN
	POP D
RRS2:	CALL POKH
	JC RRS0
RRN:	MVI A,09
	ADD E
	MOV E,A
	CPI 3A
	JZ MON
	INX H
	INX H
	INX H
	JMP RRS1

JAMP:	CPI "J"		;JAMP
	JNZ ADDH
JAMD:	DB "JAMP",0D,0A,00
JAM:	LXI D,0300
	CALL SCRN
	LXI D,JAMD
	CALL PRINT
	LXI H,HRG+1
	CALL POKH
	JC JAM
	JMP MON

ADDD:	DB 0C,"Hex [",0
ADDH:	CPI "H"		;ADD
	JNZ MOVE
ADD:	LXI D,ADDD
	CALL PRINT
	LXI H,STRT+1
	CALL POKH
	JC ADD
	MVI C,"+"
	CALL SYM
	LXI H,STRT+3
	CALL POKH
	JC ADD
	MVI C,"="
	CALL SYM
	LHLD STRT
	XCHG
	LHLD STRT+2
	DAD D
	CALL HEXH
	CALL KLV
	JMP MAIN

MOVD:	DB 0C,"MOVE }",0
MOVE:	CPI "M"		;MOVE
	JNZ RAMR
MOVS:	LXI D,MOVD
	CALL PRINT
	LXI H,STRT+1
	CALL POKH
	JC MOVS
	MVI C,"-"
	CALL SYM
	LXI H,STRT+3
	CALL POKH
	JC MOVS
	MVI C,"="
	CALL SYM
	LXI H,STRT+5
	CALL POKH
	JC MOVS
	LHLD STRT
	MOV B,H
	MOV C,L
	LHLD STRT+2
	MOV D,H
	MOV E,L
	INX D
	LHLD STRT+4
MOV:	LDAX B
	MOV M,A
	INX B
	INX H
	MOV A,C
	CMP E
	JNZ MOV
	MOV A,B
	CMP D
	JNZ MOV
	JMP MAIN

STROM SET BF83
RWDSK SET BF83+1
DRIVE SET BF83+2
RAM:DB "0123 ?",0
RAMR:	CPI "R"		;DRIVE
	JNZ RAMW
	LXI D,WRID
	JMP RA4
RAMW:	CPI "W"
	JNZ PRINTT
	LXI D,WRIT
RA4:	STA RWDSK
	CALL VERH
	CALL PRINT
RA5:	CALL KLVC
	CPI "A"
	JC RA5
	CPI "F"
	JNC RA5
	STA DRIVE
	CALL SYM
	MVI C,":"
	CALL SYM
	LDA DRIVE
	SUI "A"
	STA DRIVE
	JNZ DISK
RA0:	LXI D,RAM
	CALL PRINT
RRR:	CALL KLVC
	SUI 30
	CPI 4
	JNC RRR
	STA STROM
	JMP MAIN	

PRINTT:	CPI "T"		;TYPE
	JNZ PGM
	MVI C,1F
	CALL SYM
	XCHG
	CALL PRINT
CONT:	LXI D,CON
	CALL PRINKL
	JMP MAIN

PGM:	CPI "P"		;P G M
	JZ PROG

	CPI "p"		;LPRN
	JZ LPRN

	CPI 10		;LTAB
	JZ LTAB

	CALL MET2
	SHLD HRG
	JMP M2

MET2:	CPI 93
	JZ LEFT
	CPI 08
	JZ LEFT
	CPI 84
	JZ RGHT
	CPI 85
	JZ UP
	CPI 98
	JZ DOWN
	RET

LEFT:	MOV A,B
	CPI 2
	JZ LE2
	MOV A,L
	ANI 0F
	RZ
LE3:	DCR L
	MVI B,2
LE1:	MVI C,08
	JMP SYM
LE2:	MVI B,1
	JMP LE1
RGHT:	MVI C,18
	CALL SYM
	MOV A,B
	CPI 01
	MVI B,2
	RZ
RE1:	INR L
	JZ LE3
	MOV A,L
	ANI 0F
	MVI B,01
	JZ CRLF
	RET
UP:	MOV A,L
	ANI 0F0
	RZ
	MOV A,L
	SUI 10
	MOV L,A
	MVI C,19
	JMP SYM
DOWN:	MOV A,L
	ADI 10
	ANI 0F0
	RZ
	MVI A,10
	ADD L
	MOV L,A
	MVI C,0A
	JMP SYM

POKE:	CPI 47
	RP
	CPI 30
	RM
	SUI 30
	CPI 0A
	JM M4
	SUI 7
M4:	PUSH PSW
	CALL HE1
	MOV A,B
	CPI 2
	JZ M5
	MOV A,M
	ANI 0F
	MOV B,A
	POP PSW
	RLC
	RLC
	RLC
	RLC
	ADD B
	MOV M,A
	MVI B,2
	RET

M5:	MOV A,M
	ANI 0F0
	MOV B,A
	POP PSW
	ADD B
	MOV M,A
	XRA A
	MOV B,A
	RET

POKH:	CALL POK
	DCX H
	RC
	CPI 0D
	RZ
POK:	MVI B,1
PK1:	CALL KLVC
	CPI 0D
	RZ
	CPI 08
	JNZ PK2
	STC
	RET
PK2:	CALL POKE
	MOV A,B
	ORA A
	JNZ PK1
	RET

BUK:	MOV A,M
	MOV C,A
	ANI 7F
	CPI 20
	JP M24
M23:	MVI C," "
M24:	CALL SYM
	INR L
	MOV A,L
	ANI 0F
	CPI 0
	JNZ BUK
	RET

BEEP:	LXI B,6060
BELL:	MVI A,0F
	OUT 0E2
	MOV A,C
BBB:	DCR A
	JNZ BBB
	OUT 0E2
	MOV A,C
BBD:	DCR A
	JNZ BBD
	DCR B
	JNZ BELL
	RET

NTREK SET BF83+3
NSEKT SET BF83+4
NUMBS SET BF83+5
TIPD SET BF83+6
DISK:	LXI D,TRAK
	CALL PRINT
	CALL DESDV
	STA NTREK
	LXI D,SEKT
	CALL PRINT
	CALL DESDV
	STA NSEKT
	LXI D,NUMB
	CALL PRINT
	CALL DESDV
	STA NUMBS
	LXI D,IO
	CALL PRINT
	CALL KLVC
	CPI "N"
	JZ D2
	CPI "Y"
	JNZ MAIN
D2:	STA TIPD
	CALL SYM
	CALL READD
	JMP CONT

READD:	CALL NIZ
RD:	CALL A0D
	LDA NTREK
	MOV D,A
	LDA NSEKT
	MOV E,A
	LDA TIPD
	CPI "Y"
	CZ TABL
	MOV A,H
	CPI 09C
	JNC ERROR
	LXI B,00084
	LDA RWDSK
	CPI "W"
	LDA DRIVE
	JNZ D3
	MVI C,0A4
	CALL FDWR
	DCR L
	JMP D4
D3:	CALL FDRD
D4:	CPI 0
	JNZ ERROR
SEK:	LDA NTREK
	MOV D,A
	LDA NSEKT
	INR A
	CPI 0A
	JC D5
	INR D
	MOV A,D
	STA NTREK
	MVI A,01
D5:	STA NSEKT
	MOV E,A
	CALL CRD0
	CALL DVDES
	LDA NUMBS
	DCR A
	STA NUMBS
	JNZ RD
	RET

ERROR:	PUSH PSW
	LXI D,ERD
	CALL PRINT
	POP PSW
	CALL HEX
	LXI B,70FF
	LXI D,TRAK
	CALL PRINT
	LDA NTREK
	CALL DVA
	LXI D,SEKT
	CALL PRINT
	LDA NSEKT
	CALL DVA
	LXI D,ERR
	CALL PRINKL
	CPI "A"
	JZ MAIN
	JMP READD

DVDES:	CALL DV1
	MOV A,E
DVA:	MOV D,A
DV1:	MVI C,0
	MVI B,8
DV2:	MOV A,D
	RLC
	MOV D,A
	MOV A,C
	ADC C
	DAA
	MOV C,A
	DCR B
	JNZ DV2
	JMP HEX

TABLIC:DB 01,08,06,04,02,09,07,05,03
TABL:	LXI B,TABLIC-1
	MOV A,E
	ADD C
	MOV C,A
	JNC D8
	INR B
D8:	LDAX B
	MOV E,A
	RET

DESDV:	CALL D1
	RLC
	RLC
	RLC
	MOV B,A
	RRC
	RRC
	ADD B
	MOV B,A
	CALL D1
	ADD B
	RET
D1:	CALL KLVC
	SUI 30
	JM D1
	CPI 0A
	JP D1
	PUSH PSW
	CALL SYM
	POP PSW
	RET

FDRD:	CALL DRSEL	;READ *** DISK ***
	RC
	CALL SETSD
	RC
	CALL CHTEN
	RC
	XRA A
	 RET
FDWR:	CALL DRSEL	;WRITE
	RC
	CALL  SETSD
	RC
	CALL ZAPIS
	RC
	XRA A
	 RET
DRSEL:	PUSH B		;SET DRIVE
	MVI B,07
	CPI 1
	JZ DIS
	MVI B,27
	CPI 2
	JZ DIS
	MVI B,03
	CPI 3
	JZ DIS
	MVI B,23
	CPI 4
	JZ DIS
	MVI B,0
DIS:	MOV A,B
	OUT 25
	POP B
USTK:	IN 25		;ZAPUSK DRIVE
	RLC
	JC F95B
	IN 20
	ANI 80
	RZ
F95B:	PUSH B
	LXI B,0FA00
	CALL F97F
F962:	IN 20
	ANI 80
	JZ PAUSE
	IN 25
	RLC
	JNC F962
	MVI A,20
	 JMP RPAU
PAUSE:	DCR C
	JNZ PAUSE
	DCR B
	JNZ PAUSE
	XRA A
RPAU:	POP B
	 RET
F97F:	IN 25
	ANI 4E
	RAR
	OUT 25
	ORI 8
	OUT 25
	 RET
SETSD:	MVI B,2		;SET SEKT AND TREK
SDOR:	MOV A,D
	OUT 23
	MVI A,1C
	OUT 20
	NOP
	NOP
SSD:	IN 24
	IN 20
	ANI 19
	CPI 0
	JZ SSEKT
	DCR B
	STC
	RZ
	MVI A,08
	OUT 20
	NOP
	NOP
	IN 24
	JMP SDOR
SSEKT:	MOV A,E
	OUT 22
	 RET
ZAPIS:	MOV A,C		;SAVE
	OUT 20
ZAPC:	IN 24
	RRC
	MOV A,M
	OUT 23
	INX H
	JC ZAPC
	JMP ERTR
CHTEN:	MOV A,C		;LOAD
	OUT 20
	 JMP REA1
REA0:	MOV M,A
	INX H
REA1:	IN 24
	RRC
	IN 23
	JC REA0
ERTR:	IN 20		;ERR
	MOV C,A
	ANI 0DF
	RZ
	STC
RET:	 RET

ERD:DB "Error-",07,0
ERR:DB "Retry,Abort-?",0
WRID:DB "Read/",0
WRIT:DB "Write/",0
TRAK:DB "/Track-",0
SEKT:DB "/Sekt-",0
NUMB:DB "/N-",0
CON:DB "{OK}",0
IO:DB "/kod-?",0
KOD:DB 1B,40,1B,52,03,1A

FILL:	MOV C,M
	MVI A,0A0
FIL:	MOV M,C
	INX H
	CMP H
	JNZ FIL
	JMP MON
FIL1:	MOV C,M
FI1:	MOV M,C
	INR L
	JNZ FI1
	JMP MON

HEXD:	XCHG
	CALL HEXH
	XCHG
	RET
HEXH:	MOV A,H
	CALL HEX
	MOV A,L
HEX:	PUSH PSW
	ANI 0F0
	RRC
	RRC
	RRC
	RRC
	CALL HE1
	POP PSW
	PUSH PSW
	ANI 0F
	CALL HE1
	POP PSW
	RET
HE1:	PUSH D
	LXI D,DANN
	ADD E
	JNC HE2
	INR D
HE2:	MOV E,A
	LDAX D
	MOV C,A
	CALL SYM
	POP D
	RET
DANN:	DB "0123456789ABCDEF",0

CRLF:	MVI C,0A
	CALL SYM
CRD0:	CALL A0D
	CALL HEXH
PRB:	MVI C,20
	JMP SYM

D0A:	MVI C,0A
	CALL SYM
A0D:	MVI C,0D
	JMP SYM

KLV:	PUSH H
	PUSH D
	PUSH B
	LXI H,0
KL1:	CALL STAT
	ORA A
	JNZ KL0
KL2:	DCR A
	JNZ KL2
	DCR H
	JNZ KL1
	CALL INV
	INR L
	JMP KL1
KL0:	MOV A,L
	ANI 01
	CNZ INV
	POP B
	POP D
	POP H
	CALL KL
	RET

KLVC:	CALL KLV
	MOV C,A
	CPI 03
	JZ MAIN
	RET

PRINKL:	CALL PRIND
	JMP KLVC

PRIND:	CALL D0A
PRINT:	MVI B,10
PRNT:	LDAX D
	ORA A
	RZ
	CPI 0D
	JNZ PPRI
	DCR B
	JNZ PPRI
	CALL KLVC
	MVI B,10
	LDAX D
PPRI:	MOV C,A
	CALL SYM
	INX D
	JMP PRNT

SYM:	MOV A,C
	ANI 80
	JZ RUS
	MVI A,01
RUS:	STA RLAT
	CALL SYMB
	LDA LTB+1
	CPI 10
	RNZ
	JMP LPRI

VERH:	MVI C,0C
	JMP SYM

SCRN:	CALL VERH	;TAB PRINT
	MOV A,D
	ORA A
	MVI C,0A
SCR0:	JZ SCR1
	CALL SYM
	DCR D
	JNZ SCR0
SCR1:	MOV A,E
	MVI C,18
	ORA A
	RZ
SCR2:	CALL SYM
	DCR E
	JNZ SCR2
	RET

NIZ:	LXI D,1500
	CALL SCRN
	LXI D,7F20
	CALL CURC
	LXI D,1500
	JMP SCRN

CURC:	MOV C,E
CURS:	CALL SYM
	DCR D
	RZ
	JMP CURS

LTAB:	MVI A,10
	STA LTB
	JMP MON

LPS:	LDA LTB
	CPI 10
	RNZ
	STA LTB+1
	LXI D,KOD
	JMP LPRINT

LPR:	XRA A
	STA LTB
	STA LTB+1
	RET

LPRN:	XCHG
	CALL LPRINT
	JMP MON

LPRINT:	LDAX D
	MOV C,A
	CPI 1A
	RZ
	CALL LPRI
	INX D
	JMP LPRINT

LPRI:	IN 80
	ANI 08
	JNZ LPRI
ACK:	IN 41
	ANI 10
	JNZ ACK
	MOV A,C
	OUT 0E0
	MVI A,9
	OUT 0E3
	MVI A,8
	OUT 0E3
	RET

PLUS:	LHLD HRG
	INR H
	JMP FF

MIN:	LHLD HRG
	DCR H
	JMP FF
F1:	MVI H,01
	JMP FF
F2:	MVI H,40
	JMP FF
F3:	MVI H,0B0
	JMP FF
FF:	XRA A
	MOV L,A
	SHLD HRG
	JMP MON
F4:	MOV A,H
	ADI 10
	JMP FA
F5:	MOV A,H
	SUI 10
FA:	MOV H,A
	JMP FF

SEAD:	DB 0C,"SEARCH [",0
SEARCH:	LXI D,SEAD
	CALL PRINT
	LXI H,STECK
S0:	MVI B,1
S1:	CALL KLVC
	CPI 08
	JZ SEARCH
	CPI 0D
	JZ POISK
	CPI "*"
	JZ S4
	LDA TBU
	CPI 09
	JNZ S2
S4:	MOV M,C
	CALL SYM
	JMP S5
S2:	MOV A,C
	CALL POKE
	MOV A,B
	ORA A
	JNZ S1
S5:	INR L
	JMP S0
POISK:	MOV B,L
	MOV D,H
	XRA A
	MOV E,A
	LHLD HRG
	INX H
	ADD B
	JZ SEA1
	STA STECK+10
SEA1:	LDAX D
	CMP M
	JZ S6
S3:	CPI "*"
	JZ S6
	LDA STECK+10
	CMP B
	JZ SEA2
	MOV B,A
	MVI E,0
	JMP SEA1
S6:	DCR B
	JZ AGA
	INR E
SEA2:	INR L
	JNZ SEA1
	INR H
	JNZ SEA1
	JMP MAIN
AGA:	LDA STECK+10
OGO:	DCR A
	JZ RETS
	DCX H
	JMP OGO
RETS:	SHLD HRG
	LXI B,0FF30
	CALL BELL
	JMP MAIN

PA	SET	00H
PB	SET	01H
PC	SET	02H
PU	SET	03H
PRGD	SET	0BF60
DATA:	DB 09," *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* ",0D,0A
	DB 09," |       Programmator ROM      | ",0D,0A
	DB 09," |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ",0D,0A
	DB 09," |  1. D2716    |  1. Read     | ",0D,0A
	DB 09," |  2. D2732    |  2. Check FF | ",0D,0A
	DB 09," |  3. D2764    |  3. Write    | ",0D,0A
	DB 09," |  4. D27128   |  4. Verify   | ",0D,0A
	DB 09," |  5. D27256   |  5. CRC-16   | ",0D,0A
	DB 09," |  6. D27512/1 |  6. Testing  | ",0D,0A
	DB 09," |  7. D27512/2 |  7. EXIT     | ",0D,0A
	DB 09," *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* ",0D,0A
DAT:	DB 09," |                             | ",0D,0A
	DB 09," *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* ",0
UKAZ:	DB "=>",0
OCH:	DB 08,08,20,20,0
WARN:	DB 09,"Testing VPP ???",0
ERPD:	DB 07," Abort,Retry,Next ?",0
PROG:	MVI A,80
	OUT PU
	LXI D,00500
	CALL SCRN
	LXI D,DATA
	CALL PRINT
	LXI B,5050
	CALL BELL
	LXI D,070A
	CALL ROMM
	LDA PRGD+1
	STA PRGD+4	;Namber ROM
	MVI D,7
	MVI E,6
	MOV B,A
	CPI 1
	JNZ PGA
	DCR D
	INR E
PGA:	XCHG
	SHLD PRGD+2	;Data RF2
	XCHG
	MVI A,08
PGE:	STA PRGD	;Length ROM
	RAL
	CPI 00
	JZ PPG
	DCR B
	JNZ PGE
PPG:	LXI D,0719
	CALL ROMM
	CALL NIZA
	LDA PRGD+4
	LXI D,8000
	CPI 7
	JZ PP2
	LXI D,0000
PP2:	LDA PRGD+1
	LHLD HRG
	CPI 1
	JZ READ
	CPI 2
	JZ CHKFF
	CPI 3
	JZ WRITE
	CPI 4
	JZ VERIF
	CPI 6
	JZ TEST
	CPI 5
	JNZ MON

CHECS:	LXI B,0
CRC:	MOV A,C
	XRA M
	ADD B
	MOV B,A
	RAL
	XRA C
	MOV C,A
	CALL NEXT
	JNZ CRC
	MOV H,B
	MOV L,C
	CALL HEXH
	CALL KLV
	JMP PROG
	
CHKFF:	CALL READ1
	CPI 0FF
	JZ NEX
	CALL NIZA
	CALL HEXD
	CALL PRB
	CALL READ1
	CALL HEX
	CALL KLVP
NEX:	CALL NEXT
	JZ PROG
	JMP CHKFF

TEST:	CALL READ1
	SUB M
	JZ TST1
	JNC TST1
	CALL NIZA
	CALL HEXD
	CALL PRB
	CALL READ1
	CALL HEX
	CALL PRB
	MOV A,M
	CALL HEX
	CALL KLVP
TST1:	CALL NEXT
	JZ PROG
	JMP TEST

ROMM:	XCHG
	MVI A,1
	STA PRGD+1
PP1:	CALL MARC
PP0:	CALL KLV
	MOV C,A
	CPI 03
	JZ MON
	LXI D,OCH
	CPI 0D
	RZ
	CPI 98
	JZ NZ
	CPI 85
	JNZ NMR
	LDA PRGD+1
	CPI 1
	JZ PP0
	DCR A
	JMP CPI
NZ:	LDA PRGD+1
	INR A
	CPI 08
	JZ PP0
CPI:	STA PRGD+1
	CALL PRINT
	JMP PP1
NMR:	SUI 30
	JZ PP0
	CPI 8
	JNC PP0
	STA PRGD+1
	CALL PRINT
MARC:	LDA PRGD+1
	ADD H
	MOV D,A
	MOV E,L
	CALL SCRN
	LXI D,UKAZ
	CALL PRINT
	RET

VERIF:	CALL READ1
	CMP M
	JZ VER2
	CALL NIZA
	CALL HEXD
	CALL PRB
	CALL READ1
	CALL HEX
	CALL PRB
	MOV A,M
	CALL HEX
	CALL KLVP
VER2:	CALL NEXT
	JZ PROG
	JMP VERIF

PRINCH:	LDAX D
	MOV C,A
	CALL SYM
	INX D
	DCR B
	RZ
	JMP PRINCH

WRITE:	XCHG
	LXI D,WARN
	CALL PRINT
	MVI A,0B	;VPROG 1
	OUT PU
	CALL KLVP
	CALL NIZA
	LXI D,01620
	CALL CURC
	XRA A
	STA PRGD+5
	XCHG
	LHLD HRG
PG2:	CALL READ1
	CMP M
	JZ PGN
PGB:	MVI B,0
PGC:	INR B
	MOV A,B
	CPI 55
	JNZ EREND
ERROM:	PUSH D
	PUSH B
	CALL NIZA
	CALL HEXD
	CALL PRB
	MVI A,0FF
	CALL HEX
	LXI D,ERPD
	CALL PRINT
	POP B
	POP D
	XRA A
	STA PRGD+5
PG4:	CALL KLV
	CPI "A"
	JZ PROG
	CPI 03
	JZ PROG
	CPI "N"
	JZ PGN
	CPI "R"
	JNZ PG4
	JMP PGB
EREND:	MVI C,1
	CALL WRROM
	CALL READ1
	CMP M
	JNZ PGC
	MOV A,B
	ADD B
	ADD B
	MOV C,A
	LDA PRGD+5
	ORA A
	JNZ USK
	PUSH B
	CALL NIZA
	CALL HEXH
	CALL PRB
	POP B
	MOV A,C
	CALL HEX
USK:	CALL WRROM
PGN:	CALL NEXT
	JZ PROG
	CALL STAT
	JZ PG2
	CALL KLVP
	STA PRGD+5
	JMP PG2

WRROM:	MVI A,80	;Write ROM
	OUT PU
	MVI A,0B	;VSTAB +
	OUT PU
	MOV A,D
	OUT PA
	MVI A,0F	;RG (A)
	OUT PU
	MOV A,E
	OUT PA
	MOV A,M
	OUT PB
	DI
	MVI A,0F	;BELL +V
	OUT 0E2
	LDA PRGD+3	;CE 0
	OUT PU
	MVI A,0D	;PGM 0
	OUT PU
	MVI A,5		;VPP +
	OUT PU
BGSEK:	MVI A,20	;*****
MLSEK:	DCR A		;* P *
	JNZ MLSEK	;* A *
	DCR C		;* U *
	JNZ BGSEK	;* S *
			;*****
	MVI A,80
	OUT PU		;SBROS
	XRA A
	OUT 0E2
	EI
	RET

READ:	CALL READ1	;READ ROM
	MOV M,A
	ANI 3F
	OUT 0E1
	ANI 0F
	OUT 0E2
	CALL NEXT
	JNZ READ
	JMP MAIN

READ1:	MVI A,82	;A<=ROM(DE)
	OUT PU
	MOV A,D
	OUT PA
	MVI A,0F	;RG (A)
	OUT PU
	MOV A,E
	OUT PA
	MVI A,07	;CE 0
	OUT PU
	MVI A,03	;OE 0
	OUT PU
	IN PB
	RET

NEXT:	INX H
	INR E
	RNZ
	INR D
	LDA PRGD
	DCR A
	STA PRGD
	RET

NIZA:	PUSH D
	LXI D,100C
	CALL SCRN
	POP D
	RET

KLVP:	CALL KLV
	CPI 03
	RNZ
	LXI SP,STSP
	JMP PROG

EXIT:	MVI C,1F
	CALL SYM
	JMP 00
INFO:
DB "       (Copyright(C) AZMaster)",0
END:
.PRINTX "END FILE
"

	END