我必須做一個彙編程序。我應該像一個環網櫃的工作: -Ring counter avr彙編器,
功能,8個指示燈:
(0000 000X, 0000 00X0, 0000 0X00, 0000 X000, 000X 0000, 00X0 0000, 0X00 0000, X000 0000)
我已經作出了計劃,但它的工作,如:
(0000 000x, 0000 00xx, 0000 0xxx, 0000 xxxx, 000x xxxx, 00xx xxxx,0xxx xxxx,xxxx xxxx)
有人可以幫助我如何一個一個做LED燈?
我的代碼
.include "m2560def.inc"
ldi r20, HIGH(RAMEND) ; R20 = high part of RAMEND address
out SPH,R2 ; SPH = high part of RAMEND address
ldi R20, low(RAMEND) ; R20 = low part of RAMEND address
out SPL,R20 ; SPL = low part of RAMEND address
ldi r20, 0xFF
out DDRA, r20
ldi r20, 0b10000001
out PORTA, r20
loop_1: ; Begin a loop
rcall Delay
lsl r20
out PORTA,r20
cpi r20,0x00 ;
breq reset
jmp loop_1
Delay:
inc r16
cpi r16,0xFF
brne del_1
ret go back to loop
del_1:
inc r21
cpi r21,0xFF
brne del_1
jmp Delay
reset:
ldi r20, 0xFF
out PORTA, r20
ret