Page 166 - Programming Microcontrollers in C
P. 166

Small 8-Bit Systems    151

                              A pragma is a C preprocessor command not defined by the lan­
                          guage. As such, the compiler writer can use the #pragma command
                          to satisfy a need not specifically identified by the language. C6805
                          uses pragmas to identify microcontroller-specific characteristics.
                          Table 4-2 contains a list of pragmas used by C6805. The format of a
                          pragma directive here is
                              #pragma portxx portname @ address

                          where portxx can be portr, portw, or portrw which shows
                          whether the port is read, write, or both. portname is the name used
                          in the program for the port. The at symbol (@) identifies a memory
                          address. #pragma mor identifies the contents of the masked option
                          register used on field programmable chips. There are some instruc­
                          tions that are not found across the whole M68HC05 family. In
                          particular, some devices may not have the MUL, the DIV, the STOP,
                          and the WAIT instruction. The #pragma has a preprocessor call
                          that identifies the instructions from this set in the particular
                          microcontroller.

                            pragma                     Function
                            #pragma portxy
            I/O port definition
                            #pragma memory
            RAM/ROM definition
                            #pragma mor
               mask option register
                            #pragma has
               instruction set options
                            #pragma options
           compiler directives
                            #pragma vector
            interrupt vector definitions
                              Table 4-2: C6805 pragma Directives
                              This compiler has certain options that can be inserted from the
                          command line or, if needed by the programmer, the #pragma op­
                          tions preprocessor command can also be used to set the appropriate
                          compiler options. Finally, the #pragma vector identifies a given
                          function name as an interrupt service routine. When the compiler com­
                          piles the name specified, it will place the address of the function into
                          the defined vector location. Another modification in the compiled code
                          will take place when #pragma vector is used. All returns from a
                          function identified by a vector pragma will use the return from in­
                          terrupt instruction rather than the usual return from subroutine.
   161   162   163   164   165   166   167   168   169   170   171