Guest User

Untitled

a guest
Jan 5th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (! code
  2. '(left-shift
  3. (popl %eax)         ; Pop value to be shifted into %EAX
  4. (popl %ebx)         ; Pop shift amount value into %EBX
  5. (andl %ebx %ebx)        ; checks to see if shift value is 0
  6. (je escape)         ; jumps if so
  7. (irmovl 1 %ecx)     ; moves the value 1 into %ECX so it can be used in subtraction
  8. subloop
  9.     (addl %eax %eax)    ; adds %EAX to itself, effectively multiplying by two, the equivilent of shifting left by 1
  10.     (subl %ecx %ebx)    ; subtracts 1 from %EBX
  11.     (andl %ebx %ebx)    ; checks to see if shift value is 0
  12.     (jne subloop)       ; if non-zero, repeat loop
  13. escape
  14. (pushl %eax)        ; Push the final result on the stack.
  15. ))
Add Comment
Please, Sign In to add comment