T'Scoopz 0 Newbie Poster

Hello, this is my first thread. I'm a freshman in Computer Engineering and currently taking Intro to Computer Systems with Yale Patts & Sanjay J. Patel's book. I've been using this wonderful website to help better understand the computer language world.

We are currently beginning to write programs and such, and I would like some clarifications for this particular assignment. Simply, am I doing this right? Thanks alot in advance!

-----------Below is the assignment-----------------------------------

*Instructions in bold are the actual programming to finish the assignment.

The following program should take the number in R0 and rotate it left the number of times specified in R1. Assume R0 and R1 are set by the user before the program begins. You may also assume the user will only input a positive value for R1. Our program should put the final rotated value intp R0. Fill in the missing code segments to make the code below work.

In order to rotate left we must first determine the bit in the leftmost position. If it is a 1, then we shift left and add 1. If it is a 0, then we can just shift left.

.ORIG x3000

            ; We use R1 to keep track of how many times
            ; we still need to rotate
            ; At the beginning of each time through
            ; the loop we must check if we are done rotating 
SHIFTLOOP   ADD R1,R1,#0
              [B]BRp DONE[/B]

            ; As explained above, we must check the leftmost
            ; bit before rotating. If the leftmost bit of the
            ; number is one we should jump to label ISONE
            ADD R0,R0,#0
              [B]BRn ISONE[/B]

            ; If here the left most bit is a zero
            ; We just shift the value left

            ; Shifts value in R0 left and stores result in R0
              [B]ADD R0,R0,#1[/B] 
              [B]BRnzp NEXT[/B]

            ; If here the left most bit is a one
            ; We must shift the value left then
            ; add 1 to do a rotate

            ; Shifts value in R0 left and stores result in R0
ISONE     [B]ADD R0,R1,R1[/B] 
              [B]ADD R0,R0,#1[/B]

            ; We decrement our counter in R1
            ; that indicates how many rotates we have
            ; left to do
NEXT    [B]ADD R1,R1,#-1[/B]
            [B]BRnzp SHIFTLOOP[/B]

            ; We have completed the program
DONE    HALT
            .END