;*************************************************
;		'T'	$
;************************************************
 	ERRORLEVEL -302
	LIST p=16F628A, R=DEC		
	INCLUDE<P16f628A.INC> 

	__CONFIG   _LVP_OFF & _BODEN_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT 


RAM		EQU	20h	; první adresa paměti RAM 
CISLO		EQU	RAM+1
CISLO_H		EQU	RAM+2
CISLO_L		EQU	RAM+3
DTISIC		EQU	RAM+4
TISIC		EQU	RAM+5
STO		EQU	RAM+6
DESET		EQU	RAM+7
JEDNA		EQU	RAM+8
;******************************************************************
	ORG	0
	GOTO	START
	ORG	4
	GOTO	INIT
;-------------------------------------------------------------------
INIT	GOTO	$	

START	MOVLW	0X00
	MOVWF	CISLO_H
	MOVLW	0X00
	MOVWF	CISLO_L
	CALL	HEX2ASCII
	GOTO	$-1	
;**********************************************************************
; Podprogram prevede 16 bitove cislo z HEX na ASCII
; CISLO_H a CISLO_L -> DTISIC, TISIC, STO, DESET, JEDNA
; Priklad: FFFFh -> 65535d

HEX2ASCII	swapf	CISLO_H,W
	andlw	0x0F		;*** PERSONALLY, I'D REPLACE THESE 2
	addlw	0xF0		;*** LINES WITH "IORLW 11110000B" -AW
	movwf	TISIC
	addwf	TISIC,F
	addlw	0xE2
	movwf	STO
	addlw	0x32
	movwf	JEDNA

	movf	CISLO_H,W
	andlw	0x0F
	addwf	STO,F
	addwf	STO,F
	addwf	JEDNA,F
	addlw	0xE9
	movwf	DESET
	addwf	DESET,F
	addwf	DESET,F

	swapf	CISLO_L,W
	andlw	0x0F
	addwf	DESET,F
	addwf	JEDNA,F

	rlf	DESET,F
	rlf	JEDNA,F
	comf	JEDNA,F
	rlf	JEDNA,F

	movf	CISLO_L,W
	andlw	0x0F
	addwf	JEDNA,F
	rlf	TISIC,F

	movlw	0x07
	movwf	DTISIC
	movlw	0x0A
;       ------------------------
;******************************
LB1	addwf	JEDNA,F
	decf	DESET,F
	btfss	STATUS,C
	goto	LB1
	MOVWF	CISLO
	MOVF	JEDNA,W
	ADDLW   	0X30
	MOVWF	JEDNA	
;       ------------------------
LB2	MOVF	CISLO,W
	addwf	DESET,F
	decf	STO,F
	btfss	STATUS,C
	goto	LB2
	MOVWF	CISLO
	MOVF	DESET,W
	ADDLW   	0X30
	MOVWF	DESET
;       ------------------------
LB3	MOVF	CISLO,W
	addwf	STO,F
	decf	TISIC,F
	btfss	STATUS,C
	goto	LB3
	MOVWF	CISLO
	MOVF	STO,W
	ADDLW   	0X30
	MOVWF	STO
;       ------------------------
LB4	MOVF	CISLO,W
	addwf	TISIC,F
	decf	DTISIC,F
	btfss	STATUS,C
	goto	LB4
	MOVWF	CISLO
	MOVF	TISIC,W
	ADDLW   	0X30
	MOVWF	TISIC
;       ------------------------
LB5	MOVF	DTISIC,W
	ADDLW   	0X30
	MOVWF	DTISIC
;       ------------------------
;***** ZAMEZENI ZBYTECNYCH 0 ***********************
	MOVF	DTISIC,W
	BCF	STATUS,Z
          XORLW	0X30		
          BTFSS	STATUS,Z
	GOTO	$+3
	MOVLW	' '
          MOVWF	DTISIC

	MOVF	TISIC,W
	BCF	STATUS,Z
          XORLW	0X30		
          BTFSS	STATUS,Z
	GOTO	$+8
	BCF	STATUS,Z
          MOVF	DTISIC,0
          XORLW	' '
          BTFSS	STATUS,Z
          GOTO	$+3
          MOVLW	' '
          MOVWF	TISIC

	MOVF	STO,W
	BCF	STATUS,Z
          XORLW	0X30		
          BTFSS	STATUS,Z
          GOTO	$+8
          BCF	STATUS,Z
          MOVF	TISIC,0
          XORLW	' '
          BTFSS	STATUS,Z
          GOTO	$+3
          MOVLW	' '
          MOVWF	STO	

	MOVF	DESET,W
	BCF	STATUS,Z
          XORLW	0X30		
          BTFSS	STATUS,Z
          GOTO	$+8
          BCF	STATUS,Z
          MOVF	STO,0
          XORLW	' '
          BTFSS	STATUS,Z
          GOTO	$+3
          MOVLW	' '
          MOVWF	DESET	
;***************************************************
	INCFSZ	CISLO_L
	GOTO	$+2
	INCFSZ	CISLO_H
;***********************************************
	return
	GOTO	$		;HODNOTA 65535
;************************************************


	END


