3 ms·
>For example, C won't implement the "raise to nth power" >operator (in Python, 210 means 2 to the power of 10, for >example), because it can't be done with one
by zafka 16y ago
>For example, C won't implement the "raise to nth power" >operator (in Python, 210 means 2 to the power of 10, for >example), because it can't be done with one assembly >instruction, only with a loop.
Not a great example of your point. Here is Analog devices Assembly for the ADSP-2100 Family.
Assuming Ar is loaded with 2:
sr=LSHIFT ar by 10;
Even without the assumption, no loop is needed for raising 2 to some power.
- mansr 16y agoWhat you are doing there is multiplying something by a power of two, and 'ar' should have the value 1 for 'sr' to be set to two to the power of 10. Multiplying by a power of 2 is easily done in C using the shift operator.