I was reading The Definitive Guide to ARMCortexM0/M0+ by Joseph Yiu
In Chapter 21, under section 21.4.2 GNU Compiler Collection, there is a example function with inline assembly operation:
int my_mul_10(int DataIn) {
int DataOut; __asm(" movs r0, %0\n"
" movs r3, #10\n" " mul r0, r3\n" " movs %1, r0\n" :"=r" (DataOut) : "r" (DataIn) : "cc", "r0", "r3");
return DataOut; }
In the code example, %0 is the first input parameter and %1 is the first output parameter. Since the operand order is output _operands, input_operands, and clobbered_operands, “DataOut” is assigned to %0, and “DataIn” is assigned to %1. Since the code changes register R3, it needs to be added to the clobbered operand list.
Shouldn't "DataOut" is assigned to %1 and "DataIn" to %0?
Or am I missing something here?
Thanks a lot, Joseph. Learnt a lot from your book :)
Thanks for your feedback :-)