Question: [25 pts) 3. Consider the following AVR assembly code that performs 16-bit by 16-bit multiplication. Hint: See the Lab 5 documentation for relevant background information.

 [25 pts) 3. Consider the following AVR assembly code that performs16-bit by 16-bit multiplication. Hint: See the Lab 5 documentation for relevant

[25 pts) 3. Consider the following AVR assembly code that performs 16-bit by 16-bit multiplication. Hint: See the Lab 5 documentation for relevant background information. Assume the data memory locations $0100 through $0107 initially have the values shown below. Use this information to answer the questions on page 4. Data Memory Address content 0100 0101 00 0102 0103 02 0104 0105 00 0106 00 0107 Idi 1 di 10. 12. .include "m128def.inc" ; Include definition file .def rlo - r0 ; Low byte of MUL result .def Thir1 ; High byte of MUL result .def A r2 ; An operand .def B -r3 ; Another operand .def zero - r4 ; Zero register .def oloop - r17 ; Outer Loop Counter .def loop - r18 i Inner Loop Counter .org $0000 rmp INIT .org $0054 2. INIT: clr zero ; Set zero register to zero MAIN: YL, low (addrB) Load low byte ldi YH, high (addrB) Load high byte ldi ZL, low (LAddre) Load low byte ZH, high (LAddrP); Load high byte ldi oloop, 2 Load counter 8. MUL16_OLOOP: ldi XL, low (addrA) Load low byte ldi XH, high (addrA) Load high byte ldi iloop, 2 : Load counter 11. MUL16 ILOOP: ld A X+ ; Get byte of A operand ld B, Y ; Get byte of B operand mul AB ; Multiply A and B ld A, 2+ ; Get a result byte from memory B, 2+ ; Get the next result byte from memory add rlo, A i rlo rlo + A adc rhi, B ; rhi c rhi + B + carry ld A, 2 ; Get a third byte from the result adc A, zero ; Add carry to A 2, A ; Store third byte to memory st -2, rhi ; Store second byte to memory -2, rlo ; Store first byte to memory adiw ZH:2L, 1 ; 2 2 + 1 dec iloop ; Decrement counter brne MUL16_ILOOP ; Loop if iLoop !- 0 sbiw ZH:2L, 1 ; 2 2 - 1 adiw YH:YL, 1 ; YEY+ 1 dec oloop ; Decrement counter brne MUL16_OLOOP Loop if oLoop !- 0 30. Done: rjmp Done .org $0100 addA: .byte 2 addrB: .byte 2 LAddr: .byte 4 id st NNNNNNNNNNE (a) What are the two 16-bit values in hexadecimal) being multiplied? (b) What are the contents of memory locations pointed to by LAddrP, LAddr P+1, LAddr P+2, and Laddr2+3 after the loop MUL16_ILOOP (lines 11-25) completes for the first time? (c) What are the contents of memory locations pointed to by LAddrP, LAddrP+1, LaddrP+2, and LaddrP+3 after the loop MUL16_ILOOP (lines 11-25) completes for the second time (d) What are the contents of memory locations pointed to by LAddrP, LAddrP+1, LAddr P+2, and Laddr P+3 after the loop MUL16_ILOOP (lines 11-25) completes for the third time? (e) What are the contents of memory locations pointed to by LAddr P. LAddrP+1, LAddr P+2, and LAddr P+3 after the loop MUL16_ILOOP (lines 11-25) completes for the fourth time

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!