Beispiel #1
0
static void
_pic14_finaliseOptions (void)
{
  struct dbuf_s dbuf;

  pCodeInitRegisters();

  port->mem.default_local_map = data;
  port->mem.default_globl_map = data;

  dbuf_init (&dbuf, 512);
  dbuf_printf (&dbuf, "-D__SDCC_PROCESSOR=\"%s\"", port->processor);
  addSet (&preArgvSet, Safe_strdup (dbuf_detach_c_str (&dbuf)));

    {
      char *upperProc, *p1, *p2;
      int len;

      dbuf_set_length (&dbuf, 0);
      len = strlen (port->processor);
      upperProc = Safe_malloc (len);
      for (p1 = port->processor, p2 = upperProc; *p1; ++p1, ++p2)
        {
          *p2 = toupper (*p1);
        }
      dbuf_append (&dbuf, "-D__SDCC_PIC", sizeof ("-D__SDCC_PIC") - 1);
      dbuf_append (&dbuf, upperProc, len);
      addSet (&preArgvSet, dbuf_detach_c_str (&dbuf));
    }

  if (!pic14_options.no_warn_non_free && !options.use_non_free)
    {
      fprintf(stderr,
              "WARNING: Command line option --use-non-free not present.\n"
              "         When compiling for PIC14/PIC16, please provide --use-non-free\n"
              "         to get access to device headers and libraries.\n"
              "         If you do not use these, you may provide --no-warn-non-free\n"
              "         to suppress this warning (not recommended).\n");
    } // if

}
Beispiel #2
0
/*-----------------------------------------------------------------*/
void
picglue ()
{
        FILE *asmFile;
        struct dbuf_s ovrBuf;
        struct dbuf_s vBuf;

        dbuf_init(&ovrBuf, 4096);
        dbuf_init(&vBuf, 4096);

        pCodeInitRegisters();

        /* check for main() */
        mainf = newSymbol ("main", 0);
        mainf->block = 0;
        mainf = findSymWithLevel (SymbolTab, mainf);

        if (!mainf || !IFFUNC_HASBODY(mainf->type))
        {
                /* main missing -- import stack from main module */
                //fprintf (stderr, "main() missing -- assuming we are NOT the main module\n");
                pic14_options.isLibrarySource = 1;
        }

        /* At this point we've got all the code in the form of pCode structures */
        /* Now it needs to be rearranged into the order it should be placed in the */
        /* code space */

        movepBlock2Head('P');              // Last
        movepBlock2Head(code->dbName);
        movepBlock2Head('X');
        movepBlock2Head(statsg->dbName);   // First


        /* print the global struct definitions */
        if (options.debug)
                cdbStructBlock (0);

        /* do the overlay segments */
        pic14emitOverlay(&ovrBuf);

        /* PENDING: this isnt the best place but it will do */
        if (port->general.glue_up_main) {
                /* create the interrupt vector table */
                pic14createInterruptVect (&vBuf);
        }

        AnalyzepCode('*');

        ReuseReg(); // ReuseReg where call tree permits

        InlinepCode();

        AnalyzepCode('*');

        if (options.debug) pcode_test();


        /* now put it all together into the assembler file */
        /* create the assembler file name */

        if ((noAssemble || options.c1mode) && fullDstFileName)
        {
                sprintf (buffer, "%s", fullDstFileName);
        }
        else
        {
                sprintf (buffer, "%s", dstFileName);
                strcat (buffer, ".asm");
        }

        if (!(asmFile = fopen (buffer, "w"))) {
                werror (E_FILE_OPEN_ERR, buffer);
                exit (1);
        }

        /* prepare statistics */
        resetpCodeStatistics ();

        /* initial comments */
        pic14initialComments (asmFile);

        /* print module name */
        fprintf (asmFile, "%s\t.file\t\"%s\"\n",
            options.debug ? "" : ";", fullSrcFileName);

        /* Let the port generate any global directives, etc. */
        if (port->genAssemblerPreamble)
        {
                port->genAssemblerPreamble(asmFile);
        }

        /* Put all variables into a cblock */
        AnalyzeBanking();

        /* emit initialized data */
        showAllMemmaps(asmFile);

        /* print the locally defined variables in this module */
        writeUsedRegs(asmFile);

        /* create the overlay segments */
        fprintf (asmFile, "%s", iComments2);
        fprintf (asmFile, "; overlayable items in internal ram \n");
        fprintf (asmFile, "%s", iComments2);
        dbuf_write_and_destroy (&ovrBuf, asmFile);

        /* copy the interrupt vector table */
        if (mainf && IFFUNC_HASBODY(mainf->type))
          dbuf_write_and_destroy (&vBuf, asmFile);
        else
          dbuf_destroy(&vBuf);

        /* create interupt ventor handler */
        pic14_emitInterruptHandler (asmFile);

        /* copy over code */
        fprintf (asmFile, "%s", iComments2);
        fprintf (asmFile, "; code\n");
        fprintf (asmFile, "%s", iComments2);
        fprintf (asmFile, "code_%s\t%s\n", moduleName, port->mem.code_name);

        /* unknown */
        copypCode(asmFile, 'X');

        /* _main function */
        copypCode(asmFile, 'M');

        /* other functions */
        copypCode(asmFile, code->dbName);

        /* unknown */
        copypCode(asmFile, 'P');

        dumppCodeStatistics (asmFile);

        fprintf (asmFile,"\tend\n");

        fclose (asmFile);
        pic14_debugLogClose();
}
Beispiel #3
0
static void
_pic14_init (void)
{
  asm_addTree (&asm_asxxxx_mapping);
  pCodeInitRegisters();
}