Question

Implement the following functions with AVR assembly language 1) 2-byte addition (i.e, addition on 16-bit numbers)...

Implement the following functions with AVR assembly language 1) 2-byte addition (i.e, addition on 16-bit numbers) 2) 2-byte signed subtraction 3) 2-byte signed multiplication

Homework Answers

Answer #1

1) 2-byte addition Code

.DEF  AL = R16         ;To hold low byte of value1
.DEF  AH = R17         ;To hold high byte of value1
.DEF  BL = R18         ;To hold low byte of value2
.DEF  BH = R19         ;To hold high byte of value2
add:
     ADD AL,BL         ;Add the lower bytes together
     ADC AH,BH         ;Add the higher bytes and include carry bit
     BRCS OVERFLOW
     ret

2) 2 byte signed subtraction

subtract:

      SUB AL,BL         ;Subtract two low bytes
      SBC AH,BH         ;Subtract two high bytes and include carry 
      BRCS UNDERFLOW
      ret

3) 2 byte signed multiplication

mul16x16_16:

mul   r22, r20       ; al * bl
movw   r17:r16, r1:r0
mul   r23, r20       ; ah * bl
add   r17, r0
mul   r21, r22       ; bh * al
add   r17, r0
ret

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Complete this AVR assembly language fragment so that it adds the unsigned 16-bit value in register...
Complete this AVR assembly language fragment so that it adds the unsigned 16-bit value in register pair r9:r6 to the unsigned 16-bit value in r7:r8. (Registers 9 and 7 are the most signficant bytes in these 16-bit quantities. The result ends up in r7:r8.) addadcadiwr6r7r8r9  addadcadiwr6r7r8r9 ,  addadcadiwr6r7r8r9 addadcadiwr6r7r8r9  addadcadiwr6r7r8r9 ,  addadcadiwr6r7r8r9
What is the machine code that corresponds to the AVR Assembly Language Instruction and r31, r0...
What is the machine code that corresponds to the AVR Assembly Language Instruction and r31, r0 (Enter your answer as a 16 bit binary number. There must be no spaces or punctuation marks - just enter sixteen 1's or 0's.)
VERILOG Design an Arithmetic Logic Unit (ALU) that can perform four-bit 1. Four-bit addition; 2. Four-bit...
VERILOG Design an Arithmetic Logic Unit (ALU) that can perform four-bit 1. Four-bit addition; 2. Four-bit subtraction; 3. Four-bit multiplication; 4. Four-bit comparator (that compares two binary numbers to check whether two numbers are equal, or one is less/greater than other). Write test benches and simulate each module/submodule. Hint: First make individual modules of the four-bit adder, four-bit subtractor, four-bit multiplier, four-bit comparator modules (make all these in same/one project) and then use a multiplexer to combine these modules to...
Implement the following expression in assembly language:                                  &nb
Implement the following expression in assembly language:                                                 BX = –val2 + 7 - (- val3 + val1) * 2 Assume that val1, val2, and val3 are 8-bit integer variables Initialize val1 with 12, val2 with 9, and val3 with 2 You are only allowed to use 16-bit registers to hold intermediate results, whenever needed. Use ONLY mov, add, sub, movzx, movzx, or neg instructions whenever needed. Use the debugger to verify your answer. Please answer using this format for...
2. On the Arduino Uno (and other ATMega based boards) an “int” stores a 16-bit (2-byte)...
2. On the Arduino Uno (and other ATMega based boards) an “int” stores a 16-bit (2-byte) value. “int” store negative numbers with a technique called 2's complement math. The highest bit, sometimes referred to as the "sign" bit, flags the number as a negative number. The rest of the bits are inverted and 1 is added. The Arduino takes care of dealing with negative numbers for you, so that arithmetic operations work transparently in the expected manner. a-What is the...
Write the following ANNA assembly language programs. 1.HighestnumberWrite an ANNA assembly program (high.ac) that will continuously...
Write the following ANNA assembly language programs. 1.HighestnumberWrite an ANNA assembly program (high.ac) that will continuously prompt the user for numbers. When the user enters a negative number, print the highest positive number entered by the user and exit the program. Print a zero if they did not enter any positive numbers. 2.DivisionWrite an ANNA assembly program (div.ac) that divides two positive numbers that come from user input and returns both the quotient and the remainder. For example, if the...
2 Convert each of the following octal numbers to 10-bit binary, hexadecimal, and decimal. Show your...
2 Convert each of the following octal numbers to 10-bit binary, hexadecimal, and decimal. Show your work. (a) 368 (b) 7568 3 Convert the following binary values into Decimal, Octal and hexadecimal. Show your work. (a) 111010101011112 (b) 1010111011001102 (c) 1011101010001112 (d) 1111101011102 4 Convert the following hexadecimal numbers to 16-bit binary and decimal numbers. Show your work. (a) FE9816 (b) FCAD16 (c) B00C16 (d) FEDF16 5 Perform the addition on the following unsigned binary numbers. Indicate whether or not...
Implement a 2-bit adder using only a 32x3 ROM. The adder adds two 2-bit numbers, {A1...
Implement a 2-bit adder using only a 32x3 ROM. The adder adds two 2-bit numbers, {A1 A0} and {B1 B0}. The adder also has a carry-in (Cin) input. Thus there are 5 inputs: A1 A0, B1 B0, Cin. There are 3 outputs, a 2-bit sum (S1 S0) as well as a carry-out (Cout). Include a diagram of the ROM: label inputs/outputs correctly and show the contents of ROM cells (0's/1's).
Implement the following C++ expression val1 = (val2 * val3) / (val4 − 3) in assembly...
Implement the following C++ expression val1 = (val2 * val3) / (val4 − 3) in assembly language using: • 8-bit unsigned operands • 16- bit unsigned operands • 32-bit unsigned operands a- Use the MASM assembler with .Data to initialize your variables, write your code in the .code segment. Add comments explaining your code b- Modify the code to prompt the user to enter the information -use 32-bit unsigned operands only-, and show the output on the console, and dump...
Concern the following 16-bit floating point representation: The first bit is the sign of the number...
Concern the following 16-bit floating point representation: The first bit is the sign of the number (0 = +, 1 = -), the next nine bits are the mantissa, the next bit is the sign of the exponent, and the last five bits are the magnitude of the exponent. All numbers are normalized, i.e. the first bit of the mantissa is one, except for zero which is all zeros. 1. How many significant binary digits do numbers in this representation...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT