0

I can't figure out how to write the code in Assembler to get the desired result: sequentially light the LEDs clockwise with an interval of 0.5 seconds Assembler is not my strong point, I have a rough idea how to write this cide in C, but Assembler is a bit complicated for me. Maybe someone has some ideas what I should do. Thank you for any help

.device AT90USB162
.include "usb162def.inc"B
.def tmp= r16
.equ RedDiod=5
.equ YellowDiod=6
.equ GreenDiod=0;PD
.equ BlueDiod=2
.cseg
.org $0000 
 rjmp reset 
.org $0040
;*******начало основной программы
reset:
ldi tmp,high(RAMEnd)

 ldi tmp,low(RAMEnd)
 out spl,tmp

ldi tmp,$00 
 out PortB,tmp
 out PortC,tmp
 ldi tmp,0b00010010
 out PortD,tmp
 ldi tmp,0b11111111 
 out DDRB,tmp 
 ldi tmp,0b11111100 ;
 out DDRC,tmp 
 ldi tmp,0b01101001 ;
 

out DDRD,tmp 
delay:
 ldi r17,0xff; количество повторів
 ldi r18,0x7 ; у r17-r20
 ldi r19,0
 ldi r20,0
_delay: subi r17,0x1
 sbci r18,0
 sbci r19,0
 sbci r20,0
 brcc _delay
 ret
main:
ldi tmp,(1<<RedDiod)|(1<<YellowDiod)|(1<<BlueDiod)
 out PortC,tmp
ldi tmp,(1<< GreenDiod)
 out PortD,tmp
 end: jmp end
JinHo
  • 1
  • 1
  • 1
    Write it in C then. Show your attempt. Translate statement by statement, or use a compiler for hints. – Jester Mar 02 '23 at 13:34

0 Answers0