Question: AVR language code. Let A and B be 16-bit unsigned integers. The product AB requires at most 32 bits. The quotient A/B and remainder A%B

AVR language code. Let A and B be 16-bit unsigned integers. The product AB requires at most 32 bits. The quotient A/B and remainder A%B each require at most 16 bits.

Modify the code below to compute the product AB and store it in memory as a 32-bit little-endian unsigned integer

Here is the code for reference:

;mul32.asm

.cseg

.org 0

; Initialization code

; Do not move or change these instructions or the registers they refer to.

; You may change the data values being loaded.

; The default values set A = 0x3412 and B = 0x0003

ldi r16, 0x12 ; Low byte of operand A

ldi r17, 0x34 ; High byte of operand A

ldi r18, 0x03 ; Low byte of operand B

ldi r19, 0x00 ; High byte of operand B

; Your task: Perform the integer division operation A/B and store the result in data memory.

; Store the 2 byte quotient in DIV1:DIV0 and store the 2 byte remainder in MOD1:MOD0.

; ... Your code here ...

; End of program (do not change the next two lines)

stop:

rjmp stop

; Do not move or modify any code below this line. You may add extra variables if needed.

; The .dseg directive indicates that the following directives should apply to data memory

.dseg

.org 0x200 ; Start assembling at address 0x200 of data memory (addresses less than 0x200 refer to registers and ports)

DIV0: .byte 1 ; Bits 7...0 of the quotient

DIV1: .byte 1 ; Bits 15...8 of the quotient

MOD0: .byte 1 ; Bits 7...0 of the remainder

MOD1: .byte 1 ; Bits 15...8 of the remainder

Here is a photo of the code template.

AVR language code. Let A and B be 16-bit unsigned integers. The

mu132.asm .cseg .org Initialization code :Do not move or change these instructions or the registers they refer to. : You may change the data values being loaded. ; The default values set A = 0x3412 and B = 0x0003 ldi rl6, 0x12Low byte of operand A ldi rl7, 0x34 High byte of operand A ldi rl8, 0x03Low byte of operand EB ldi rl9, 0x00High byte of operand B : Your task: Perform the integer division operation A/B and store the result in data memory. ; Store the 2 byte qu tient in DIVI: DIVO and store the 2 byte remainder in MODI:MODO The mu132.asm code gives the correct result when both operands are less than 16 Note that to be "correct", the result must be stored in the required memory locations OUT3:OUTO) Solutions which store the result anywhere else (or leave it in registers) will not receive any marks :... Your code here e mu132.asm code gives the correct result when the product The mu132.asm code gives the correct result when one operand is less than 256 (and the other operand is unconstrained) The mul32.asm is at most 216-1 : End of program (do not change the next two lines) stop: rjmp stop gives correct operand pairs. :Do not move or modify any code below this line. You may add extra variables if needed :The .dseg directive indicates that the following directives should apply to data memory .dseg org 0x200Start assembling at address 0x200 of data memory (addresses less than 0x200 refer to registers and ports) byte l Bits 7...0 of the quotient .byte 1 Bits 15...8 of the quotient byte l Bits 7...0 of the remainder byte :Bits 15.. .8 of the remainder DIVO MODO MOD1: mu132.asm .cseg .org Initialization code :Do not move or change these instructions or the registers they refer to. : You may change the data values being loaded. ; The default values set A = 0x3412 and B = 0x0003 ldi rl6, 0x12Low byte of operand A ldi rl7, 0x34 High byte of operand A ldi rl8, 0x03Low byte of operand EB ldi rl9, 0x00High byte of operand B : Your task: Perform the integer division operation A/B and store the result in data memory. ; Store the 2 byte qu tient in DIVI: DIVO and store the 2 byte remainder in MODI:MODO The mu132.asm code gives the correct result when both operands are less than 16 Note that to be "correct", the result must be stored in the required memory locations OUT3:OUTO) Solutions which store the result anywhere else (or leave it in registers) will not receive any marks :... Your code here e mu132.asm code gives the correct result when the product The mu132.asm code gives the correct result when one operand is less than 256 (and the other operand is unconstrained) The mul32.asm is at most 216-1 : End of program (do not change the next two lines) stop: rjmp stop gives correct operand pairs. :Do not move or modify any code below this line. You may add extra variables if needed :The .dseg directive indicates that the following directives should apply to data memory .dseg org 0x200Start assembling at address 0x200 of data memory (addresses less than 0x200 refer to registers and ports) byte l Bits 7...0 of the quotient .byte 1 Bits 15...8 of the quotient byte l Bits 7...0 of the remainder byte :Bits 15.. .8 of the remainder DIVO MODO MOD1

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!