This is a good observation that the order of the operands vastly affects the run time of the "repeated addition" multiplication algorithm.

There are better algorithms for multiplication, one of which is presented in chapter 12 where you will be writing the OS's multiply function. These algorithms take approximately the same time to run regardless of the operand values.

This is analogous to the way that the standard decimal multiplication algorithm takes about the same amount of work to multiply 123*987 as it does for 987*123

123 987
x 987 x 123
------ ------
861 2961
984 1974
1107 987
------ ------
121401 121401

Usually OS and library functions are optimized so that application programmers don't need to worry about how things like argument order may affect performance.

--Mark