Page 211 - ARM 64 Bit Assembly Language
P. 211

Integer mathematics 199























































                                             Figure 7.5: Flowchart for binary division.

                     7.3.2 Division by a variable

                     The algorithm for dividing binary numbers is somewhat more complicated than the algo-
                     rithm for multiplication. The algorithm consists of two main phases: The first phase is to shift
                     the divisor left until it is greater than the dividend, and count the number of shifts. The sec-
                     ond phase is to repeatedly shift the divisor back to the right and subtract whenever possible.
                     Fig. 7.5 shows the algorithm in more detail. Before we introduce the AArch64 code, we will
   206   207   208   209   210   211   212   213   214   215   216