Answered step by step
Verified Expert Solution
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 ATmegaPB 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, equatesdefinitions 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 EQU ENDVAL EQUSTEP ; ensure Stack Pointer holds last address in SRAM LDI R HIGH RAMEND OUT SPH R LDI R LOW RAMEND OUT SPL R ; load constants into GPRs for use LDI R STARTVAL LDI R STEP LDI R ENDVAL PUSH R ; save Rs value on stack RCALL SUMVALS ; call subroutine POP R ; restore Rs value from stack END: RJMP END ; infinite loop at program's end ; Subroutine repeatedly adds STEP R ; to STARTVAL R until the sum becomes ; larger than ENDVAL R Answer that is ; less than or equal to ENDVAL will be held ; in R SUMVALS : MOV R R ; store current sum in R ADD R R ; add STEP to sum in R CP R R; test if ENDVAL sum BRPL SUMVALS ; loop again if ENDVAL sum RET ; return from subroutine
Given the AVR Assembly program below written for the ATmegaPB 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, equatesdefinitions 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
EQU ENDVAL
EQUSTEP
; ensure Stack Pointer holds last address in SRAM
LDI R HIGH RAMEND
OUT SPH R
LDI R LOW RAMEND
OUT SPL R
; load constants into GPRs for use
LDI R STARTVAL
LDI R STEP
LDI R ENDVAL
PUSH R ; save Rs value on stack
RCALL SUMVALS ; call subroutine
POP R ; restore Rs value from stack
END: RJMP END ; infinite loop at program's end
; Subroutine repeatedly adds STEP R
; to STARTVAL R until the sum becomes
; larger than ENDVAL R Answer that is
; less than or equal to ENDVAL will be held
; in R
SUMVALS :
MOV R R ; store current sum in R
ADD R R ; add STEP to sum in R
CP R R; test if ENDVAL sum
BRPL SUMVALS ; loop again if ENDVAL sum
RET ; return from subroutine
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started