Page 271 - ARM 64 Bit Assembly Language
P. 271

260 Chapter 8














                  We can only remove five leading zero bits, because removing one more would change the sign
                  bit from 0 to 1, resulting in a completely different number. Note that the final format has three
                  “hidden” bits between the radix point and the sign bit. These bits are all copies of the sign bit.
                  It is an S(−4,8) number because the sign is four bits to the right of the radix point (resulting
                  in the three “hidden” bits). According to the rules of fixed point multiplication given earlier,
                  an S(7,0) number x multiplied by an S(−4,8) number R will yield an S(4,8) number y.The
                                3    x
                  value y will be 2 ×  because we have three “hidden” bits to the right of the radix point.
                                    23
                  Therefore,
                                                   x             −3
                                                     = R × x × 2   ,
                                                   23
                  indicating that after the multiplication, we must shift the result right by three bits to re-
                  store the radix. Since  1  is positive, the number R must be increased by one to avoid
                                     23
                  round-off error. Therefore, we will use R + 1 = 01011010 = 90 10 in our multiply op-
                  eration. To calculate y = 101 10 ÷ 23 10 , we can multiply and perform a shift as fol-
                  lows:


                                                          . 0 1100101
                                                         × 01011010
                                                         0. 11001010
                                                      011. 00101
                                                    0110. 0101
                                                 011001. 11
                                              00100100. 00000010


                  Because our task is to implement integer division, everything to the right of the radix point
                  can be immediately discarded, keeping only the upper eight bits as the integer portion of
                  the result. The integer portion, 100011 2 , shifted right three bits, is 100 2 = 4 10 . If the mod-
                  ulus is required, it can be calculated as: 101 − (4 × 23) = 9. Some processors, such as
                  the Motorola HC11, have a special multiply instruction which keeps only the upper half of
                  the result. This method would be especially efficient on that processor. Listing 8.2 shows
   266   267   268   269   270   271   272   273   274   275   276