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
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...
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).
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 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...
Are the following sets groups: (a) continuous real functions on [0, 1] with operation addition; (b)...
Are the following sets groups: (a) continuous real functions on [0, 1] with operation addition; (b) continuous real functions on [0, 1] with operation multiplication.
Determin if the following sets of numbers are closed under the given operation. Question 2 options:...
Determin if the following sets of numbers are closed under the given operation. Question 2 options: Even numbers under the operation of division Multiplies of the number 3 under the operation of subtraction Negative numbers under the operation of multiplication 1. Closed 2. Not Closed
1. (10 pts) Apply Booth's Algorithm to multiply the following 6-bit unsigned numbers, showing the contents...
1. (10 pts) Apply Booth's Algorithm to multiply the following 6-bit unsigned numbers, showing the contents of the A, Q, M registers and the C bit, through the 6 steps: 100110 and 111001 (i.e., decimal 38 and 57) 2 Assuming single-precision (i.e., 32-bits) IEEE 754 standard, unpack the following 32- bit string into decimal floating-point form: 11001110100001000110010000110100
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT