The commaSeparate Utility
摘要
The value returned by the factorial program was hard to read. We now present a utility to take a long integer n and return a string representing the long integer with commas inserted into the correct positions. The maximum value we can handle in a 64-bit register is 9 quintillion. Table 9-1 shows the algorithm. We use the temporary register r10 to keep track of whether a nonzero quotient has been found. Nowhere else in the program is r10 used, so there is no difficulty in using it as a temporary variable.