	org	100h

NIC	EQU	2EH
BOD	EQU	58H
ESC	EQU 	27
POCBY	EQU	08H
CR	EQU	0DH
lf	equ	0ah
ADR	equ	9000h
POCZN	equ	0
;
;
START:	LXI H,ADR
	MVI B,POCZN
N8BYTE:	MVI D,POCBY
N1BYTE:	MVI A,8
	CMP D
	CNZ MEZERY
	CZ  ZNAKY
	CALL TBYTE
	INX H
 	DCR D
	JNZ N1BYTE
	CALL RADNI
	DCR B
	JNZ N8BYTE
	rst	0
HEXTAB:	DS 2
;
;
MEZERY:	ret
	PUSH H
	PUSH B
	PUSH PSW
	MVI E,5
MEZ1:	PUSH D
	MVI C,20H
	CALL TISKZN
	POP D
	DCR E
	JNZ MEZ1
	POP PSW
	POP B
	POP H
	RET
;
ZNAKY:	MVI A,POCZN
	SUB B
	MOV E,A
	CALL HEXA
	PUSH H
	LHLD HEXTAB
	MOV C,H
	CALL TZNC
	MOV C,L
	CALL TZNC
	call	radni
	pop	h
	ret
	MVI C,20H
	CALL TZNC
	POP H
	MVI A,20H
	CMP E
	cnc	ridi
	MOV C,E
	CALL TZNC
	MVI C,20H
	CALL TZNC
	RET
RIDI:	MVI C,ESC
	JMP TZNC
TZNC:	PUSH H
	PUSH D
	PUSH B
	PUSH PSW
	CALL TISKZN
	POP PSW
	POP B
	POP D
	POP H
	RET
RADNI:	MVI C,CR
	CALL TZNC
	mvi	c,lf
	call	tznc
	RET
TBYTE:	PUSH B
	PUSH D
	MOV B,M
BITY:	MVI E,8
BIT:	MOV A,B
	ANI 80H
	CZ NULA
	CNZ JEDNA
	MOV A,B
 	RLC
	MOV B,A
	DCR E
	JNZ BIT
	call	radni
	POP D
	POP B
	ret
NULA:	MVI C,NIC
	JMP TZNC
JEDNA:	MVI C,BOD
	JMP TZNC
HEXA:	PUSH H
	PUSH B
	PUSH D
	PUSH PSW
	ANI 0FH
	CALL PULHEX
	STA HEXTAB
	MOV A,E
	ANI 0F0H
 	RLC
	RLC
	RLC
	RLC
	CALL PULHEX
	STA HEXTAB+1
	POP PSW
	POP D
	POP B
	POP H
	RET
PULHEX:	ADI 30H
	CPI 3AH
	RC
	ADI 7
	RET

tiskzn	mov	e,c
	mvi	c,2
	call	5
	ret

	end
