code:
.include "m16def.inc"
main:
ldi r16,$ff ;DDRB la port xuat
out DDRD,r16
ldi r16,$00 ;tat tat ca cac led
out PORTD,r16
pre_loop:
ldi r30,0b00001000 ;high
ldi r31,0b00010000 ;low
ldi r28,0
loop:
lsl r30
lsr r31
mov r29,r30
or r29,r31
cpi r29,$00 ;if (r29==0)
breq pre_loop ;pre_loop
out PORTD,r29
jmp delay
rjmp loop
delay:
ldi r16,250
loop0:
ldi r17,250
loop1:
dec r17
cpi r17,$00
brne loop1
dec r16
cpi r16,$00
brne loop0
jmp loop
ret
.include "m16def.inc"
main:
ldi r16,$ff ;DDRB la port xuat
out DDRD,r16
ldi r16,$00 ;tat tat ca cac led
out PORTD,r16
pre_loop:
ldi r30,0b00001000 ;high
ldi r31,0b00010000 ;low
ldi r28,0
loop:
lsl r30
lsr r31
mov r29,r30
or r29,r31
cpi r29,$00 ;if (r29==0)
breq pre_loop ;pre_loop
out PORTD,r29
jmp delay
rjmp loop
delay:
ldi r16,250
loop0:
ldi r17,250
loop1:
dec r17
cpi r17,$00
brne loop1
dec r16
cpi r16,$00
brne loop0
jmp loop
ret