.include "m2560def.inc" .equ cf = 3 ;current floor .equ ef = 5 ; expect floor .equ direction = 0 ;0 down 1 up Start: clr r20 clr r21 clr r22 ser r16 out DDRC, r16 // set Port A for output ser r16 out DDRG, r18 // ldi r20,cf ldi r21,ef ldi r22,direction Loop: cpi r20,ef rjmp Go_up //error here !!!!!!!!! breq end Go_down: ldi r22,0 rjmp Condition Go_up: ldi r22,1 rjmp Condition Condition: cpi r20, 1 breq First_Floor cpi r20, 2 breq Second_Floor cpi r20, 3 breq Third_Floor cpi r20, 4 breq Forth_Floor cpi r20, 5 breq Fifth_Floor cpi r20, 6 breq Sixth_Floor cpi r20, 7 breq Seventh_Floor cpi r20, 8 breq Eighth_Floor cpi r20, 9 breq Ninth_Floor cpi r20, 10 breq Tenth_Floor First_Floor: ldi r16, 0x00 // write the pattern out PORTC, r16 ldi r18, 0x04 out PORTG, r18 cpi r22,1 //error here !!!!!!!!! breq goup rjmp godown Second_Floor: ldi r16, 0x00 // write the pattern out PORTC, r16 ldi r18, 0x0C out PORTG, r18 cpi r22,1 breq goup rjmp godown Third_Floor: ldi r16, 0x01 // write the pattern out PORTC, r16 ldi r18, 0x0C out PORTG, r18 cpi r22,1 breq goup rjmp godown Forth_Floor: ldi r16, 0x03 // write the pattern out PORTC, r16 ldi r18, 0x0C out PORTG, r18 cpi r22,1 breq goup rjmp godown Fifth_Floor: ldi r16, 0x07 // write the pattern out PORTC, r16 ldi r18, 0x0C out PORTG, r18 cpi r22,1 breq goup rjmp godown Sixth_Floor: ldi r16, 0x0F // write the pattern out PORTC, r16 ldi r18, 0x0C out PORTG, r18 cpi r22,1 breq goup rjmp godown Seventh_Floor: ldi r16, 0x1F // write the pattern out PORTC, r16 ldi r18, 0x0C out PORTG, r18 cpi r22,1 breq goup rjmp godown Eighth_Floor: ldi r16, 0x3F // write the pattern out PORTC, r16 ldi r18, 0x0C out PORTG, r18 cpi r22,1 breq goup rjmp godown Ninth_Floor: ldi r16, 0x7F // write the pattern out PORTC, r16 ldi r18, 0x0C out PORTG, r18 cpi r22,1 breq goup rjmp godown Tenth_Floor: ldi r16, 0xFF // write the pattern out PORTC, r16 ldi r18, 0x0C out PORTG, r18 cpi r22,1 breq goup rjmp godown goup: inc r22 rjmp Loop godown: dec r22 rjmp Loop end: rjmp end

Line 26 and 70 have the error about "relative branch out of reach "

How could I fix it?

Moreover, I am asked to use timer0 to count 2 seconds for each loop, could anyone tell me how to do this?

Thanks a lot!