|
Lol that is Visual Basic code not C++. So the carrot operator ^ represents exponentiation.
Exponentiation by a positive integer constant is best done by exponentuation by squaring most efficient by finding an addition chain which minimizes the number of multiplications and additions or subtractions. 6=4+2 or 6=8-2 will both work but 4+2 is more efficient
So you use IMUL to multiply by itself once, store the square the multiply the result by itself again, and multiply those together to get the 6th power. Accumulate with ADD and use a counter register initialized to 6 which decreases with DEC each time though the loop and check loop exit condition with jump if zero JZ. This is a very basic assembly task if you've learned it. Addition chains are a more advanced topic if your exponents are huge e.g. in cryptography. There is no known efficient way to find them interestingly enough
|