Explain how extended shifting is performed-00599
This subjective question is related to the book/course vu cs402 Theory of Automata. It can also be found in vu cs402 Mid Term Solved Past Paper No. 2.
Using our basic shifting and rotation instructions we can effectively shift a 32bit number in memory word by word. We cannot shift the whole number at once since our architecture is limited to word operations. The algorithm we use consists of just two instructions and we name it extended shifting.
num1: dd 40000shl word [num1], 1
rcl word [num1+2], 1
The DD directive reserves a 32bit space in memory; however the value we placed there will fit in 16bits. So we can safely shift the number left 16 times.
The least significant word is accessible at num1 and the most significant word is accessible at num1+
The two instructions are carefully crafted such that the first one shifts the lower word towards the left and the most significant bit of that word is dropped in carry. With the next instruction we push that dropped bit into the least significant bit of the next word effectively joining the two 16bit words.
The final carry after the second instruction will be the most significant bit of the higher word, which for this number will always be zero.