Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the AVR Assembly program below written for the ATmega 3 2 8 PB microcontroller, fill in the program ( flash ) memory and data

Given the AVR Assembly program below written for the ATmega328PB microcontroller, fill in the program (flash) memory and data memory with appropriate values by hand. For instructions, list the instruction's mnemonic and replace labels, equates/definitions, functions and operations in operands with their values in hexadecimal form. The first four instructions are entered to get you started. For values written to locations in data memory, list the (potentially multiple) values in hexadecimal form at the correct locations.
; define some constants
. EQU STARTVAL =3
. EQU ENDVAL =14
. EQUSTEP=4
; ensure Stack Pointer holds last address in SRAM
LDI R16, HIGH (RAMEND)
OUT SPH, R 16
LDI R16, LOW (RAMEND)
OUT SPL, R 16
; load constants into GPRs for use
LDI R16, STARTVAL
LDI R17, STEP
LDI R18, ENDVAL
PUSH R16 ; save R16's value on stack
RCALL SUMVALS ; call subroutine
POP R16 ; restore R16's value from stack
END: RJMP END ; infinite loop at program's end
; Subroutine repeatedly adds STEP (R17)
; to STARTVAL (R16) until the sum becomes
; larger than ENDVAL (R18). Answer that is
; less than or equal to ENDVAL will be held
; in R19.
SUMVALS :
MOV R19, R16 ; store current sum in R19
ADD R16, R17 ; add STEP to sum in R16
CP R18, R16; test if ENDVAL >= sum
BRPL SUMVALS ; loop again if ENDVAL sum
RET ; return from subroutine
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions