In: Physics
Write in ARM assembly language the following operations without using multiplication instruction:
a) A * 17
b). A * 23
Code:
you can use an arm-*-*-gcc toolchain to get this kind of answers.
Multiplication without use of Mul Instruction: a * 17
$ cat m17.c
int f(int a) {
return a * 17;
}
$ arm-linux-gnueabihf-gcc -O3 -S m17.c
$ cat m17.s
<skipped>
f:
add r0, r0, r0, lsl #4
bx lr
Multiplication without use of Mul Instruction: a* 23
$ cat m23.c
int f(int a) {
return a * 23;
}
$ arm-linux-gnueabihf-gcc -O3 -S m23.c
$ cat m23.s
<skipped>
f:
add r0, r0, r0, lsl #4
bx lr