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

Write or type AVR Assembly code for this scenario. Please turn this sheet in wit

ID: 3753259 • Letter: W

Question

Write or type AVR Assembly code for this scenario. Please turn this sheet in with your solution. Add the integer values from d4 to d9 using a loop. Inside of a loop perform these operations 60 times with a 1 second delay of each input Input two 4-bit value from the lowest and highest bits of Port C respectively Subtract the lower input from the higher input and output the value (in hexadecimal) on a 7-segment display connected to Port D. If the value is negative output the character X If the difference in positive, the result should also be stored in memory starting at location 0x1000

Explanation / Answer

As per the givedata wrote the programas shown below

.include "m328pdef.inc"

.CSEG

                digit: .DB 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F                 ------digit series -----

.ORG    0x0005

                rjmp RESET     -----before reset data --------

RESET:              ------reseting the data --------------

                ; INIT - Stack Pointer

                ldi             R16, HIGH(RAMEND)

               out             SPH, R16

                ldi             R16, LOW(RAMEND)

                out             SPL, R16

       

----------------------------------------sub prog.variable------------------------------------

.def    drem16uL=r14

.def    drem16uH=r15

.def    dres16uL=r16

.def    dres16uH=r17

.def    dd16uL =r16

.def    dd16uH =r17

.def    dv16uL =r18

.def    dv16uH =r19

.def    dcnt16u =r20

; LOAD - Divident(dd8u) And Divisor(dv8u) => 432(1B0) / 100 = 4.32----------------------------------------equation

                ;-----------------------------------------------------------------------for Divident

                ldi             dd16uH, HIGH(0x01B0)

                ldi             dd16uL, LOW(0x01B0)

               

                ---------------------------------------------------------------------------for Divisor

                ldi             dv16uH, HIGH(100)

                ldi             dv16uL, LOW(100)

                call    div16u

               

                

                ldi             ZH, HIGH(digit)                         

                ldi             ZL, Low(digit)

                add             ZH, dres16uH                       

                adc             ZL, dres16uL                         

                lpm             R23, Z                                         

               

loop:

                rjmp loop              

//##program//##

div16u:

        clr     drem16uL                        

        sub    drem16uH, drem16uH     

        ldi     dcnt16u,17                     

d16u_1:                                                      --------------------------------------------------------------------for reg 1------------

        rol     dd16uL                          

        rol     dd16uH

        dec     dcnt16u                       

        brne d16u_2                        

        ret                                             

d16u_2:                     -----------------------------------------for reg2-------------------

    rol drem16uL                 

        rol     drem16uH

        sub     drem16uL,dv16uL       

        sbc     drem16uH,dv16uH        

        brcc    d16u_3                 

        add     drem16uL,dv16uL         

        adc     drem16uH,dv16uH

        clc                                            

        rjmp    d16u_1               

d16u_3: sec                                    

        rjmp    d16u_1

                       

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