Left Rotation

In a left rotation operation, like a left shift operation, every bit in the word is shifted one place to the left. Unlike the left shift operation, the rightmost bit becomes the old leftmost bit rather than a zero. It is as though you were reading the word off a bracelet, and you rotated the bracelet left by one bit (moving your start position one bit to the right). For example:

        1111111001111111 becomes
        1111110011111111

        1010111000011011 becomes
        0101110000110111
    

Write a Hack assembly program that performs the left rotation operation on the word in RAM[0] a total of RAM[1] times, and stores the result in RAM[2]. You may assume RAM[1] is non-negative, and you don’t need to optimise when RAM[1] ≥ 16. You may want to use your answer for the left shift exercise as a base.

Hint: The difference between a left shift and a left rotation depends only on the most significant bit of RAM[1]. The Hack CPU already provides an easy way of testing whether that bit is 1 — can you see what it is?