Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Bit-shifting done here!!!!!
  2.  
  3. ldi r22, 1 ;this register will store the data that will be put into portc
  4. ldi r23, 128 ;this is the upper-limit
  5. ldi r24, 1 ;this is the lower-limit
  6.  
  7. port_loop_left: ;loop to shift the bit all the way to the left
  8.     out portc, r22 ;put current value of r22 in portc
  9.     lsl r22 ;shift the bit left one
  10.     cpse r22, r23 ;has r22 reached the upper-limit of the bitshift? If y, skip next step
  11. rjmp port_loop_left
  12.  
  13. port_loop_right: ;loop to shift the bit all the way to the right
  14.     lsr r22 ;shift the bit to the right by one. Do this first because the bit is already at the left-most location
  15.     out portc, r22 ;put the value of r22 into portc
  16.     cpse r22, r24 ;has r22 reached the lower limit of the bit-shift possibility? if so, skip next command
  17. rjmp port_loop_right
  18. nop
  19. rjmp port_loop_left ;return to the loop that shifts the bit left. REPEAT FOREVAR!!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement