TM1637_DIO	bit	P2.0
TM1637_CLK	bit	P2.1

TM1637_TMP	equ	020h

		org	0000h

main:		call	tm1637_start
		mov	tm1637_tmp, #040h
		call	tm1637_send
		call	tm1637_stop

		call	tm1637_start
		mov	tm1637_tmp, #0C0h
		call	tm1637_send

		mov	tm1637_tmp, #07Fh
		call	tm1637_send

		mov	tm1637_tmp, #07Fh
		call	tm1637_send

		mov	tm1637_tmp, #007h
		call	tm1637_send

		mov	tm1637_tmp, #05Bh
		call	tm1637_send

		call	tm1637_stop

		call	tm1637_start
		mov	tm1637_tmp, #089h
		call	tm1637_send
		call	tm1637_stop
		

		sjmp	$

tm1637_start:	setb	tm1637_clk
		setb	tm1637_dio
		nop
		clr	tm1637_dio
		ret

tm1637_stop:	clr	tm1637_clk
		nop
		clr	tm1637_dio
		nop
		setb	tm1637_clk
		nop
		setb	tm1637_dio
		nop
		ret

tm1637_getack:	clr	tm1637_clk
		call	delay_5us
		jb	tm1637_dio, $
		setb	tm1637_clk
		nop
		clr	tm1637_clk
		ret
		

tm1637_send:	push	ACC
		push	PSW
		clr	C
		mov	A, tm1637_tmp
		mov	R7, #008h
tm1637_loop:	clr	tm1637_clk
		rrc	A
		mov	tm1637_dio, C
		nop
		setb	tm1637_clk
		nop
		djnz	R7, tm1637_loop
		call	tm1637_getack
		pop	PSW
		pop	ACC
		ret
		
delay_5us:	ret

		end

