Page 340 - Programming Microcontrollers in C
P. 340

Table Look-Up    325

                          instruction. For example, an integer multiply instruction might require
                          five clock cycles. In that case, an instruction pipe five instructions long
                          would be implemented within the integer ALU. Therefore, a multiply
                          instruction would be launched into the instruction pipe for execution.
                          In the meantime, other instructions could execute while the multiply is
                          progressing through the pipe.
                              Compiler optimization for these machines must take into account
                          all of the pipes, the separate ALUs, and other unique operations when
                          creating the required assembly code. Clearly, a straightforward cre­
                          ation of code in the order that might seem to be natural to a
                          programmer will not necessarily create the quickest code for a RISC
                          machine. Here, speed optimization consists of arranging the code so
                          that, as nearly as possible, the maximum number of instructions are
                          launched each clock cycle. This rearrangement of your code will
                          make it extremely difficult to examine the assembly code version of
                          the program and even make sense of it. So long as the results are not
                          altered, the optimizer for a RISC machine will move instructions
                          around in the code stream to accomplish this end. Therefore, from a
                          practical sense, any debugging on a RISC machine will probably be
                          done with a source level debugger, and not an assembly language
                          version of the program.
                              The chip used in Chapter 8 is of the MCORE family of RISC
                          microcontrollers. We will see more of the above comments in that
                          chapter.


                          EXERCISE
                          1. Sometimes two input values are needed to specify a parameter.
                            For example, if you recall from Chapter 5, the change in pulse on
                            time to properly control the motor speed was given by

                                              ∆p
                              ∆p= 3809500
                                    –
                                 c             2
                                              p
                          create a sparse two-dimensional look-up table whose inputs are p and
                          ∆p and which provides ∆p  as the result of three interpolations. Is the
                                                   c
                          look-up table better than the calculation in any way—less code, quicker,
                          etc.? Why would you use a look- up table in a problem like this one?
   335   336   337   338   339   340   341   342   343   344   345