Left Shift

Consider a binary word. In a left shift operation, written ≪ in C, every bit in the word is shifted one place to the left, with a zero being added to the right to keep the length the same. For example,

        1111111001111111
        becomes 
        1111110011111110

        1010111000011011
        becomes
        0101110000110110.
    

Write a Hack assembly program that performs the left shift operation on the word in RAM[0] a total of RAM[1] times, and stores the result in RAM[2], i.e. RAM[2] ← RAM[0] ≪ RAM[1]. You may assume RAM[1] is non-negative, and you don’t need to optimise when RAM[1] ≥ 16.

Hint: While the Hack CPU doesn’t support left shifts natively, they can be expressed nicely in terms of an operation it does support. The part of your code that actually performs the left shift should be very short. You should try and work this out for yourself, but if you are having trouble, here is the solution in ROT13 (decoder here): Gb fuvsg k yrsg ol bar cbfvgvba, nqq k gb vgfrys.