Page 215 - ARM 64 Bit Assembly Language
P. 215

Integer mathematics 203

                                                                     ⎫
                        Quotient:  0   0    0   0    0   0   0    0  ⎪
                                                                     ⎪
                                                                     ⎪
                       Dividend:   0   1    0   1    1   1   1    0  ⎬  Divisor > Dividend: shift Power
                         Divisor:  0   1    1   1    0   0   0    0  ⎪ right, shift Divisor right
                                                                     ⎪
                                                                     ⎪
                          Power:   0   0    0   1    0   0   0    0  ⎭
                                                                     ⎫
                        Quotient:  0   0    0   0    0   0   0    0  ⎪ Divisor ≤ Dividend:
                                                                     ⎪
                                                                     ⎪
                       Dividend:   0   1    0   1    1   1   1    0  ⎬   Dividend -= Divisor,
                         Divisor:  0   0    1   1    1   0   0    0  ⎪ Quotient += Power, shift Power
                                                                     ⎪
                          Power:   0   0    0   0    1   0   0    0  ⎭   right, shift Divisor right
                                                                     ⎪
                                                                     ⎫
                        Quotient:  0   0    0   0    1   0   0    0  ⎪ Divisor ≤ Dividend:
                                                                     ⎪
                                                                     ⎪
                       Dividend:   0   0    1   0    0   1   1    0  ⎬   Dividend -= Divisor,
                         Divisor:  0   0    0   1    1   1   0    0  ⎪ Quotient += Power, shift Power
                                                                     ⎪
                          Power:   0   0    0   0    0   1   0    0  ⎭   right, shift Divisor right
                                                                     ⎪
                                                                     ⎫
                        Quotient:  0   0    0   0    1   1   0    0  ⎪
                                                                     ⎪
                                                                     ⎪
                       Dividend:   0   0    0   0    1   0   1    0  ⎬  Divisor > Dividend: shift Power
                         Divisor:  0   0    0   0    1   1   1    0  ⎪ right, shift Divisor right
                                                                     ⎪
                                                                     ⎪
                          Power:   0   0    0   0    0   0   1    0  ⎭

                                                                     ⎫
                        Quotient:  0   0    0   0    1   1   0    0  ⎪ Divisor ≤ Dividend:
                                                                     ⎪
                                                                     ⎪
                       Dividend:   0   0    0   0    1   0   1    0  ⎬  Dividend -= Divisor,
                         Divisor:  0   0    0   0    0   1   1    1  ⎪ Quotient += Power, shift Power
                                                                     ⎪
                                                                     ⎪
                          Power:   0   0    0   0    0   0   0    1  ⎭  right, shift Divisor right
                                                                     ⎫
                        Quotient:  0   0    0   0    1   1   0    1  ⎪
                                                                     ⎪
                                                                     ⎪
                       Dividend:   0   0    0   0    0   0   1    1  ⎬
                                                                         Power = 0: We are finished
                         Divisor:  0   0    0   0    0   0   1    1
                                                                     ⎪
                                                                     ⎪
                                                                     ⎪
                          Power:   0   0    0   0    0   0   0    0  ⎭
                     As with the previous version, when the algorithm terminates, the quotient register contains
                     the result of the division, and the modulus (remainder) is in the dividend register. Listing 7.4
                     shows the AArch64 assembly code to implement this version of the division algorithm for
                     64-bit numbers, and the counting method for 128-bit numbers.
   210   211   212   213   214   215   216   217   218   219   220