Answer to Question #240460 in Electrical Engineering for abhishek

Question #240460
Write an AVR assembly program for the ATmega328PB that uses a loop to sum the decimal numbers 1, 2, 3, ..., 19, 20, noting where the result is stored as well as its value in hexadecimal and decimal.
1
Expert's answer
2021-09-24T02:14:21-0400


    ORG OOOOh
    LJMP main
    ORG 0x40h
main:
    MOV R0,#14h      ; N=20 value to get Sum from 1 to 20
    MOV R1,#01h
loop:
    ADD A,R1
    INC R1
    DJNZ R0, loop
    MOV R4,A         ; Final Sum is stored in register R4
end




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS