.NOLIST
.INCLUDE "M16DEF.INC"
.LIST
.DEF SUMAL = R17
.DEF SUMAH = R18


LDI R26,0XFF
OUT DDRB,R26
LDI R27,0
OUT SPH,R27
OUT SPL,R26

POCZ:
	
	LDI R31,0
	LDI R30,0X80
	LDI R29,0
	LDI R28,0X60
	LDI SUMAL,0
	LDI SUMAH,0

	ST Y+,R27
	ST Y+,R27
	ST Y+,R27
	ST Y+,R27
D2:
	LDI R19,8	
LOOP:
	LPM R16,Z+
	ADD SUMAL,R16
	BRCS SUMH
D:
	DEC R19
	CPI R19,0
	BRNE LOOP
	CLC
	ROR SUMAH
	ROR SUMAL
	CLC	
	ROR SUMAH
	ROR SUMAL
	CLC	
	ROR SUMAH
	ROR SUMAL
	ST Y+,SUMAL
	SUBI R30,7
	LDI SUMAL,0
	LDI SUMAH,0
	CPI R30,0XE4
	BRNE D2
	ST Y+,R27
	ST Y+,R27
	ST Y+,R27

D3:
	LDI R28,0X60
D4:
	LD R16,Y+
	OUT PORTB,R16
	CPI R28,0XC2
	BREQ D3
	JMP D4

SUMH:
	INC SUMAH
	JMP D

TABELA:
.ORG 0X40
.DB 0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250
.DB 250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250
.DB 240,230,220,210,200,190,180,170,160,150,140,130,120,110,100,90,80,70,60,50,40,30,20,10,0
.DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
