Question: 16. 10 points) Write a subroutine (name is swap2bits) that swaps the 2 bits within the upper nibble and nibbles. The number is passed to

16. 10 points) Write a subroutine (name is swap2bits) that swaps the 2 bits within the upper nibble and nibbles. The number is passed to the subroutine using r16 and the result is returned in register 122. e the following examples for better understanding D [r16]- Upper Nibble (4bits) 10 Lower Nibble (4bits) 01 10 after swap2bits, [22] = Upper Nibble (4bits) Lower Nibble (4bits) 1010 01 Upper Nibble (4bits) Lower Nibbl Lower Nibble (4bits) 10 2) [r16] = after swap2bits, [r22] = 01 Lower Nibble (4bits) 01 Upper Nibble (4bits) L 10 Answer: .cseg at: LDI r16, HIGH (RAMEND OUT CPU_SPH, r16 LDI r16, LOW(RAMEND) OUT CPU_SPL, r16 Idi r16, 0xA3 call swap2bits end: rjmp end swap2bits: 16. 10 points) Write a subroutine (name is swap2bits) that swaps the 2 bits within the upper nibble and nibbles. The number is passed to the subroutine using r16 and the result is returned in register 122. e the following examples for better understanding D [r16]- Upper Nibble (4bits) 10 Lower Nibble (4bits) 01 10 after swap2bits, [22] = Upper Nibble (4bits) Lower Nibble (4bits) 1010 01 Upper Nibble (4bits) Lower Nibbl Lower Nibble (4bits) 10 2) [r16] = after swap2bits, [r22] = 01 Lower Nibble (4bits) 01 Upper Nibble (4bits) L 10 Answer: .cseg at: LDI r16, HIGH (RAMEND OUT CPU_SPH, r16 LDI r16, LOW(RAMEND) OUT CPU_SPL, r16 Idi r16, 0xA3 call swap2bits end: rjmp end swap2bits
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
