m820241130002.asm

; (C) David Vajda
; 2024-11-30
; AVR - Atmega8 - LED Blink/Count

.include "m8def.inc"

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

ldi r16, 0xff
out DDRB, r16

ldi r16, 0x00
loop1:
com r16
out PORTB, r16
com r16
rcall sleep
inc r16
rjmp loop1

sleep:
push r17
push r16
ldi r16, 0xff
sleep_loop1:
ldi r17, 0xff
sleep_loop2:
dec r17
brne sleep_loop2
dec r16
brne sleep_loop1
pop r16
pop r17
ret