Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in XMega assembly that reads a number from Port B and adds to it

ID: 664153 • Letter: W

Question

Write a program in XMega assembly that reads a number from Port B and adds to it a number from Port E. The result of the addition should be written to Port F. If an overflow condition is detected. an LED on Port R. pin 1 should be activated. Note that these ports and numbers may differ from what is available on your A3BU lab board. Things to keep in mind: . From where is your data coming? . Where is your data going? . How do you set your necessary inputs and outputs? . Where will you store your data during the operation of the program? Make sure you satisfy the necessary conditions to operate each port.

Explanation / Answer

CONCEPT:

Assembly code for addition using LED

ANSWER:

CODE:

section .text ; denotes code section
.global main
main:
LDI PortB16, 255   
STS portE, PortB16 ;//from Port B
STS PortR, PortB16 ; add to port E
LDI PortB17, 1 ; load R17 with 1, R16 already has 255
ADD PortB16, PortB17 ;
STS PORTB, R16 ; Sum to port B
LDS PORTB, SREG ; Load the Status register
STS PORTR, PORTB16; display it on port R
.END

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote