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 program to compute the quotient A/B and remainder A%B and store each value in memory as a 16-bit little-endian unsigned integer.

For the 16-bit input operands A and B are pre-loaded into two pairs of registers (R17:R16 for A and R19:R18 for B). Do not modify the ldi commands as they are already pre loaded.

Here is the code for reference

;divmod16

.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

image text in transcribed

divmocl 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 B0x0003 ldi rl6, 0x12Low byte of operand ldi rl7, 0x34 High byte of operand A ldi rl8, 0x03:Low byte of operand E ldi r19, 0x00 High byte of operand B : Your task: Perform the integer division operation A/B and store the result in data nemory : Store the 2 byte quotient in DIV1:DIVO and store the 2 byte remainder in MODl:MODO. divmod16.asn code gives the correct qotien value (n memory locations in memory locations The divmod16.asm code gives the correct quotient and remainder values for all valid : Your code here. DIV1:DIVO) when the denominator (B) is less than 256 divnod16.asn code gives the correct ue MOD1: MODO) when the denominator (B) is less than 256 : End of program (do not change the next two 1ines) stop: rimp stop ; Do not move or modify any code below th15 line. You may add extra variable5 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) Bits 7...0 of the quotient DIVO .byte DIVI: MODO: MODI byte 1 Bits 15...8 of the quotient byte 1 Bits 7...0 of the remainder byte 1Bits 15...8 of the remainder divmocl 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 B0x0003 ldi rl6, 0x12Low byte of operand ldi rl7, 0x34 High byte of operand A ldi rl8, 0x03:Low byte of operand E ldi r19, 0x00 High byte of operand B : Your task: Perform the integer division operation A/B and store the result in data nemory : Store the 2 byte quotient in DIV1:DIVO and store the 2 byte remainder in MODl:MODO. divmod16.asn code gives the correct qotien value (n memory locations in memory locations The divmod16.asm code gives the correct quotient and remainder values for all valid : Your code here. DIV1:DIVO) when the denominator (B) is less than 256 divnod16.asn code gives the correct ue MOD1: MODO) when the denominator (B) is less than 256 : End of program (do not change the next two 1ines) stop: rimp stop ; Do not move or modify any code below th15 line. You may add extra variable5 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) Bits 7...0 of the quotient DIVO .byte DIVI: MODO: MODI byte 1 Bits 15...8 of the quotient byte 1 Bits 7...0 of the remainder byte 1Bits 15...8 of the remainder

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions