1. Logical shifts
A logical shift moves all bits in the register a number of places. The bits that move off the end of the register are lost. The syllabus instructions are `LSL #n` for a left shift and `LSR #n` for a right shift, where n is the number of places.
In a left shift the bits move towards the left and zeros are introduced on the right-hand end. In a right shift the bits move towards the right and zeros are introduced on the left-hand end. A logical shift puts zeros at the end that is emptied, whatever the bit was before.
Write the direction beside your working before you move any bits.
LSL #2: 0100 1111 → 0011 1100
LSR #3: 0001 0111 → 0000 0010
Examiner insight
Worked example 11 mark
The current contents of the ACC are:
0 0 0 1 0 1 1 1
Show the contents of the ACC after the execution of the following instruction.
`LSR #3`
- 1
a right shift of 3 places moves every bit 3 places to the right; the last three bits, 111, are lost
- 2
three zeros are introduced on the left-hand end: 0000 0010 [1]