Page 395 - Programming Microcontrollers in C
P. 395

380    Chapter 7  Advanced Topics

                       if(LIST_ENTRIES==0)
                        return;                  /* no entries to decode */
                       i=epro->header[k].dataindex;
                       j=decode(&epro->data[i],na);
                       puts(na);
                       putbcd(&epro->data[i+j+1],nu);
                       puts(nu);
                       k++;
                       if(++count==LIST_ENTRIES)
                       {
                        count=0;
                        k=0;
                       }
                   }


                   #ifdef DOS
                   void puts(char *s)
                   {
                       char *sp;
                       sp=s;


                       while(*sp!=’\n’ && *sp!=’\0')
                        putchar(*sp++);
                       putchar(‘\n’);
                   }
                   #endif
                              Listing 7-15: The printafter() Function

                              When developing and testing this program with the DOS system,
                          I found it necessary to include the new puts() function. When the
                          program is moved to operate on the HC12, it will be necessary to
                          include separate i/o functions to be discussed below. The i/o
                          functions are not included in the DOS version of the program.
                          Therefore, the puts() function that is added to the end of the
                          printafter() function above is included. This little function will
                          be discarded whenever the parameter DOS is not defined. In that
                          case, the i/o functions should be included.
   390   391   392   393   394   395   396   397   398   399   400