Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

=+ Are they breakable for any reason?

Answered: 1 week ago