Bitwise Shift Instructions Flashcards
1
Q
lsl form
A
lsl xd, xn, xm
xn: bit pattern to be shifted
xm: shift count
2
Q
What does lsl do?
A
- Zero is shifted into the rightmost bit (shifted out bits lost)
- Quick way to do multiplication by a power of 2 (by 2^n) where n is the shift count
- 32 bit & immediate forms exist
3
Q
Multiply 5x8 using lsl
A
mov x20, 5 //0000 0101
mov x21, 3 //2^3 = 8
lsl x19, x20, x21 //0010 1000
4
Q
What does lsr do?
A
- Quick way to divide by power of 2
- Any remainder is lost
- Does not work for negative signed integers (use ASR to preserve the sign bit)
- 32-bit & immediate forms exist
5
Q
15/4 using lsr
A
mov x20, 15 //0000 1111
mov x21, 2 //2^2 = 4
lsr x19, x20, x21 //0000 0011
6
Q
If the original multiplier in binary multiplication is negative, what extra step is needed?
A
Subtract the multiplicand from the high-order part of the result (from the product register)
7
Q
Do 2x-5 (binary multiplication, 4 bits)
A
11110110, check notes for procedure