I've been helping with labs on a course in ARM7 assembly language and today encountered a problem where a student had entered the following expression:
MUL R0, R0, R1
The code didn't compile. The solution is to change the expression to:
MUL R0, R1, R0
i.e. the first two arguments of MUL cannot be the same register. I already knew this as it is part of the documentation for ARM: http://infocenter.arm.com/help/topic/com.arm.doc.dui0489i/DUI0489I_arm_assembler_reference.pdf
The student was happy enough that their problem was fixed, but I'm rather frustrated that I don't know why ARM7 requires that the arguments be passed like this. I thought that it might have something to do with one of the registers being used to store intermediate values while the multiplier was shifting and adding, but I'm not even sure if that's how multiplication works on ARM (in fact, I'm fairly sure it's not). Why is the order of the arguments so important here?