What is the difference between lsr and asr Write the ARM ass

What is the difference between lsr and asr? Write the ARM assembly code to load the numbers stored in num1 and num2, add them together, and store the result in numsum. Use only r0 and r1. Given the following variable definitions: num 1: .word x num 2: .word y where you do not know the values of x and y, write a short sequence of ARM assembly instructions to load the two numbers, compare them, and move the largest number into register r0.

Solution

1. ASR:- Its full form is arithmetic shift right. It is arithmetic shift operation. If the original value is positive, the vacated bits at the most significant end of the word iis filled with zeros and if the value is negative, the vacated spaces are filled with 1. Let us consider an example for more illustration:-

MOV r0, r1, ASR # 3:- It will shift the value of r1 3 places right and fill empty bits with copies of original most significant bit.

As it is negative number empty spaces will be filled with ones:-

LSR:- Logical shift right is bitwise operation that is useful to shift the bits. It is different from ASR as it does not preserve a number\'s sign bit. In this, the bits are moved by specified number of bits and empty spaces are filled with zeros only. Considering above example:-

After lsr of 3 bits gives:-

2. MOV r0, num1

MOV r1, num2

ADD r0,r1

MOV numsum,r0

END

3. MOV r1,num1

Mov r2,num2

CMP r1,r2

JG Second

Second: MOV r0,r1

END

1 0 1 1 1 1 0 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 0 1 1 0 1 0 1
 What is the difference between lsr and asr? Write the ARM assembly code to load the numbers stored in num1 and num2, add them together, and store the result in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site