Updating Chapter 4

There are no changes required to the code in chapter 4 after the upgrade to MPLAB C30 v.3.02. But there are some changes in MPLAB 8.00 behavior that will have you puzzled when looking for the subroutines (library modules) used by the compiler for the long long (64-bit) integer multiplications.

In fact, the listing in the Disassembly window will not show anymore the long long multiplication routine muldi3.c as MPLAB 7.40 and older versions did. In a way the Disassembly listing has been cleaned up a bit, but don’t despair. If you follow the next few steps you’ll be able to find the missing routine anyway:

  1. Take note of the subroutine address, the number after the rcall mnemonic:
    (00280 in my case)
    long long mul
  2. Open the Program Memory Window and make sure to select the Symbolic view
    (use the tabs at the bottom left corner of the window)
  3. Press CTRL+F to open the search dialog box and type the address (00280) or simply scroll down the window until you reach the address.
  4. There you will recognize the label __muldi3 marking the entry point of the 64-bit multiplication routine used by the compiler. (That’s pretty dry reading, isn’t it?)

Looking at the exercises proposed in Chapter 4:

  1. Using Timer2 to self time the number of cycles used by each arithmetic operation is just a good idea. Exercise 4-1
    Most/all operations will fall withing the 16-bit resolution of the timer (within 65,536 cycles) so that it is easy to obtain all the cycle counts in a single watch window shot:
    Notice how some of the values changed a little bit since version 1.30 of the MPLAB C30 compiler?
  2. Checking all the divisions at once is just as simple now: Excercise 4-2
    Here are the results:
    Do you notice anything interesting? Who said float math has to be always slower than integer?
  3. Trigonometric operations (sin()) is performed using polynomial approximations and therefore multiple additions and multiplications. This has to be “hard”… Excercise 4-3
    Looking at these numbers you can almost guess the order of the polynomials…
  4. Complex math as well is composed of multiple operations of the fundamental type (integer/float): Excercise 4-4
This entry was posted in PIC24, Tips and Tricks. Bookmark the permalink.