[20 pts] 3- Consider the following AVR assembly. Assume the data memory location
ID: 3598605 • Letter: #
Question
[20 pts] 3- Consider the following AVR assembly. Assume the data memory locations $0100 through S0107 initially have the following values in hexadecimal: Data Memory Address content 0100 0101 0102 0103 0104 0105 0106 0107 04 02 OB 01 .org $0000 rjmp INIT .org $0046 clr ldi YL, low (addrB) ldi YH, high (addrB) ldi ZL, low(LAddrP) ldi ZH, high (LAddrP) ldi r17, 2 2. INIT: 3. MAIN: 8 MUL16 OLOOP: ldi XL, low (addrA) ldi XH, high (addrA) ldi r18, 2 10 11. MUL16 ILOOP ld 12 13 r4, Y ld mul r3,r4 ld ld add ro, r3 adcrl, r4 ld adcr3, r2 9 15 16. 17 r3, Z 20. 21 2, r3 -z, rl -z, r0Explanation / Answer
Answer to (a):
From the question:
addrA = 0100
addrB = 0102
LAddrP = 0106
Here X is a pointer to addrA, Y is apointer to addrB and Z is a pointer to LAddrP
Thus the contents of X, Y and Z are
X = 0100, Y = 0102 and Z = 0106
Answer to (b):
r18 is initialized to 2.
When the loop labeled MUL16_ILOOP is executed first time, r18 becomes 1 (dec r18) and the loop is executed. However, next time r18 becomes 0 and the loop is not executed.
This occurs for 2 times : first time for r17=2 and next time for r17=1
Thus the loop label MUL16_ILOOP is executed 2x2 = 4 times.
Answer to (c):
At line 11, r3 = 04(decimal 4)
At line 12, r4 = 0B(decimal 11)
At line 13, r1,r0 = 00 2C(decimal 44)
At line 14, r3 = 0
At line 15, r4 = 0
At line 16, r0 = 2C
At line 17, r1 = 00
Thus the contents of r0=2C and r1=00 after execution of lines 11-17 for the first times.
Answer to (d):
With similar logic the contents of location (LAddrP) = 2C, (LAddrP+1)=00, (LAddrP+2)=00,(LAddrP+3)=00
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.