# Execution begins at address 0 .pos 0 init: irmovl Stack, %esp # Set up Stack pointer irmovl Stack, %ebp # Set up base pointer irmovl $8,%eax # parameter value for pow pushl %eax # Push 8 call Pow # Pow(8) halt /* Subroutine Pow(x) computes 2 to the power x using the dbl instruction */ Pow: pushl %ebp rrmovl %esp,%ebp mrmovl 8(%ebp),%ecx # ecx = number of times to double irmovl $1,%eax # eax starts off as 1 Ploop: andl %ecx,%ecx # set CC from ecx je Pend dbl %eax,%ebx # double eax store result in ebx rrmovl %ebx,%eax # put result back in eax irmovl $-1,%edx addl %edx,%ecx # dec counter # note: the above could be just dbl %eax,%eax jmp Ploop Pend: popl %ebp ret .pos 0x100 Stack: # The stack goes here