;	name	teplomer
	org	0
	
dalas 	bit 	P2.0
jedn	equ	01110000b
des	equ	10110000b
sto	equ	11010000b
;-----------------------------hlavni program	
hlavni:
	call 	reset
	mov	A,#0CCh
	call	zapis
	mov	A,#044H
	call 	zapis
	
	;--------prodleva 750ms
	mov	R7,#255
	djnz	R7,$
	mov 	R7,#255
	djnz	R7,$
	mov	R7,#240
	djnz	R7,$
	;--------konec prodlevy
	
	mov	A,#0BEH
	call 	zapis
	call 	cteni	;nizsi cast
	mov	30H,A
	call	cteni	;vyssi cast
	mov	31H,A
;prevod 2 bytu	
	mov	R6,#4
	mov	A,30H
zase:	rr	A
	djnz	R6,zase
	mov	B,A
	
	mov	R6,#5
	mov	B,31H
zasej:	rl	A
	djnz	R6,zasej
	
	orl	A,B
;konecne cislo po prevodu je v A

vypis:		
	mov 	B,#100
	div	AB
	add	A,sto		;stovky
	mov	P0,A
	djnz	R7,$
	
	mov	A,B		;nacist zbytek po deleni
	mov	B,#10
	add	A,des		;desitky
	mov	P0,A
	djnz	R7,$
	
	mov	P0,B
	djnz	R7,$		;jednotky
sjmp	hlavni
	
;------------------------------konec hlavniho programu
;_____________________________________reset pulz
reset:
	clr	dalas
	;----------------prodleva 480us
	mov	R7,#255
	djnz	R7,$
	mov	R7,#225
	djnz	R7,$
	;----------------konec prodlevy
	setb	dalas
	;----------------prodleva 70us
	mov	R7,#70
	djnz	R7,$
	;----------------konec prodlevy
	
	jnb	dalas,ano
	jmp	reset
ano:
	;----------------prodleva 410us
	mov	R7,#255
	djnz	R7,$
	mov	R7,#155
	djnz	R7,$
	;----------------konec prodlevy
ret
;_______________________________________zapis
	mov	R6,#008H	;8x budu rotovat		
zapis:
	rrc	A
	jnc	je
	
	mov	R7,#4	
	jmp 	neni
	
je:
	mov R7,#48	;prodleva 48us

neni:
	clr	dalas
	djnz	R7,$
	setb	dalas
	;----------------prdleva 128us
	mov	R7,#128
	djnz	R7,$
	;----------------konec prodlevy
	djnz	R6,zapis
	;----------------300us prodleva
	mov	R7,#255
	djnz	R7,$
	mov	R7,#45
	djnz	R7,$
	;----------------konec prodlevy
ret
;_____________________________________cteni
	mov	R6,#008H
cteni:	
	clr	dalas
	;--------------prodleva	3us
	mov	R7,#3
	djnz	R7,$
	;--------------konec prodlevy
	setb	dalas
	;--------------prodleva 18us
	mov	R7,#18
	djnz	R7,$
	;--------------konec prodlevy
	mov	c,dalas
	rrc	A
	;--------------prodleva	128us
	mov	R7,#128
	djnz	R7,$
	djnz	R6,cteni
	;--------------prodleva	300us
	mov	R7,#255
	djnz	R7,$
	mov	R7,#45
	djnz	R7,$
	;--------------konec prodlevy
ret
end