Page 212 - ARM 64 Bit Assembly Language
P. 212

200 Chapter 7

                  take some time to step through the algorithm using an example. Let us begin by dividing 94
                  by 7. The result is shown below:



                                                       94 ÷ 7 =

                                                            1101

                                                    111 1011110
                                                          111000
                                                          100110
                                                           11100
                                                            1010
                                                             111
                                                              11



                  To implement the algorithm, we need three registers, one for the dividend, one for the divisor,
                  and one for a counter. The dividend and divisor are loaded into their registers and the counter
                  is initialized to zero as shown below:

                                     Dividend:   0   1    0   1    1   1   1    0
                                       Divisor:  0   0    0   0    0   1   1    1
                                      Counter:   0   0    0   0    0   0   0    0


                  Next, the divisor is shifted left and the counter incremented repeatedly until the divisor is
                  greater than the dividend. This is shown in the following sequence:


                                     Dividend:   0   1    0   1    1   1   1    0
                                       Divisor:  0   0    0   0    1   1   1    0
                                      Counter:   0   0    0   0    0   0   0    1


                                     Dividend:   0   1    0   1    1   1   1    0
                                       Divisor:  0   0    0   1    1   1   0    0
                                      Counter:   0   0    0   0    0   0   1    0


                                     Dividend:   0   1    0   1    1   1   1    0
                                       Divisor:  0   0    1   1    1   0   0    0
                                      Counter:   0   0    0   0    0   0   1    1
   207   208   209   210   211   212   213   214   215   216   217