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