# Compute a^b, where %rbx=a and %rcx=b # # Result is added to the accumulator (%rax) .globl _start .section .text _start: movq $2, %rbx # Base movq $5, %rcx # Exponent movq $1, %rax # Initialize accumulator, take advantage of the fact # that anything to the power of 0 is 1. # We just need to run this once, as decq will set ZF if %rcx reaches # zero, and the jmp instruction does nothing with the ZF cmpq $0, %rcx je complete mainloop: # Multiply %rbx by %rax, and stores the result in %rax # Hence %rax is the accumulator register mulq %rbx # loopq instruction is very nice, in a single instruction it does: # - decrement %rcx - The counter register - # - compare %rcx to zero # - Jump to the location specified if after decrementing %rcx is not 0 loopq mainloop complete: movq %rax, %rdi movq $60, %rax syscall