Recently, I had to compute large powers of integers in 65(C)02 assembler. This is actually not that difficult. However, the code can run rather slow, if not implemented efficiently. For example, one can trivially implement the power as a sequence of multiplications as:
This approach requires multiplications and can take quite some time to compute for large , especially since the 65(C)02 processor does not have a multiplication unit and multiplications have to be implemented using the Booth-algorithm or something similar.
We can do much better than this, if we utilize the following observation: