m820250116siebensegmentcount.asm


; (C) David Vajda
; 2025-01-16
; AVR/Atmega8 LED, PORTB, Sieben Segment Count

.include "m8def.inc"

ldi r16, HIGH (RAMEND)
out SPH, r16
ldi r16, LOW (RAMEND)
out SPL, r16

ldi r16, 0xff
out DDRB, r16

loop2:
ldi r16, 0x09
loop1:
out PORTB, r16
rcall sleep
dec r16
brne loop1
rjmp loop2

sleep:
push r16
push r17
ldi r16, 0xff
sleep_loop_outer:
ldi r17, 0xff
sleep_loop_inner:
dec r17
brne sleep_loop_inner
dec r16
brne sleep_loop_outer
pop r17
pop r16
ret