I understand that SRL and SRA stand for Shift Right Logical and Shift Right Arithmetic respectively. My question is which of the two pushes zeroes in from the left and which one pushes ones in from the left? I keep on getting the two mixed up.
1 Answer
-
Shift Right Logical shifts zeros in from the left.
Shift Right Arithmetic replicates the sign bit on the left. The new MSB after the SRA operation will be the same as the old MSB (before the SRA operation). This models a "divide by two" operation on twos-complement numbers, such that a positive number (say 15) turns into 7 after the SRA operation (the integer result after division by two) and a negative number (say -18) turns into -9 after the SRA operation:
15: 00001111 7: 00000111
-18: 11101110 -9: 11110111
Source(s): 8080 programming in the 70's.