What is the difference between lsr and asr Write the ARM ass
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 |
