I'm trying to add the values in two registers, and modulo them by 8. So, in C code, it would be like this
a = a + b;
c = a % 8;
how to do this above operation in ARM assembly.
Not all ARM processors have a direct instruction for division or modulo, so in most cases, a call to the modulo operation would end up as a function call to e.g. ___modsi3.
In this particular case, when doing modulo for 8, if the values can be assumed to be nonnegative, you can do the % 8 part as & 7. In that case, the assembly for your case would be:
add rA, rA, rB
and rC, rA, #7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With