Intro thread and help needed please

Reply

Join Date: Feb 2008
Posts: 12
Reputation: T'Scoopz is an unknown quantity at this point 
Solved Threads: 0
T'Scoopz T'Scoopz is offline Offline
Newbie Poster

Intro thread and help needed please

 
0
  #1
Mar 21st, 2008
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.
  1. .ORIG x3000
  2.  
  3. ; We use R1 to keep track of how many times
  4. ; we still need to rotate
  5. ; At the beginning of each time through
  6. ; the loop we must check if we are done rotating
  7. SHIFTLOOP ADD R1,R1,#0
  8. [B]BRp DONE[/B]
  9.  
  10. ; As explained above, we must check the leftmost
  11. ; bit before rotating. If the leftmost bit of the
  12. ; number is one we should jump to label ISONE
  13. ADD R0,R0,#0
  14. [B]BRn ISONE[/B]
  15.  
  16. ; If here the left most bit is a zero
  17. ; We just shift the value left
  18.  
  19. ; Shifts value in R0 left and stores result in R0
  20. [B]ADD R0,R0,#1[/B]
  21. [B]BRnzp NEXT[/B]
  22.  
  23. ; If here the left most bit is a one
  24. ; We must shift the value left then
  25. ; add 1 to do a rotate
  26.  
  27. ; Shifts value in R0 left and stores result in R0
  28. ISONE [B]ADD R0,R1,R1[/B]
  29. [B]ADD R0,R0,#1[/B]
  30.  
  31. ; We decrement our counter in R1
  32. ; that indicates how many rotates we have
  33. ; left to do
  34. NEXT [B]ADD R1,R1,#-1[/B]
  35. [B]BRnzp SHIFTLOOP[/B]
  36.  
  37. ; We have completed the program
  38. DONE HALT
  39. .END
Last edited by WolfPack; Mar 21st, 2008 at 9:48 pm. Reason: Added code tags. Use them the next time you post code.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC