Example #1
0
void printOpSpecificUT(int type, Instr_Sel ops[MAX_OPS], int cnt)
{
    int i;
    char folName[40];

    for(i = 0; i < cnt; i++) {
        // create folder
        sprintf(folName, "test_%d%02d_%s", type, i, ops[i].instr.op_str);
        mkdir(folName, S_IRWXU|S_IRGRP|S_IXGRP);
        chdir(folName);

        // open output files
        openOutputFiles();

        // write instruction and endpgm
        randomizeOperand();
        ops[i].instr_func(ops[i].instr.opcode);
        instruction_sopp_endpgm();

        // write config and data.mem
        writeConfigFile();
        writeDataMemFile();

        // close output files
        closeOutputFiles();

        // go to parent folder
        chdir("..");
    }
}
Example #2
0
int main(int argc, char* argv[]) {
    parseArgs(argc, argv);
    openInputFile();
    openOutputFiles();
    skipLines();
    splitFile();
    fprintf(stdout, "Lines Skipped: %ld / Lines Processed: %llu\n", _linesSkipped, _linesProcessed);
    closeOutputFiles();
    closeInputFile();
    exit(EXIT_SUCCESS);
}
Example #3
0
int main(int argc, char *argv[])
{
  char filename [FNAME_SIZE+1];

  /* Parse command line arguments */

  parseArguments(argc, argv);

  /* Open all output files */

  openOutputFiles();

#if !LSTTOFILE
  lstFile = stdout;
#endif

  /* Open source file -- Use .PAS or command line extension, if supplied */

  (void)extension(sourceFileName, "PAS", filename, 0);
  fprintf(errFile, "%01x=%s\n", FP->include, filename);

  memset(FP, 0, sizeof(fileState_t));
  FP->stream = fopen(filename, "r");
  if (!FP->stream)
    {
      errmsg("Could not open source file '%s': %s\n",
             filename, strerror(errno));
      showUsage(); 
    }
   
  /* Initialization */

  primeSignalHandlers();
  primeSymbolTable(MAX_SYM);
  primeBuiltInProcedures();
  primeBuiltInFunctions();
  primeTokenizer(MAX_STRINGS);

  /* Initialize the POFF object */

  poffHandle = poffCreateHandle();
  if (poffHandle == NULL)
    fatal(eNOMEMORY);

  /* Save the soure file name in the POFF output file */

  FP->include = poffAddFileName(poffHandle, filename);

  /* Define standard input/output file characteristics */

  files[0].defined = -1;
  files[0].flevel  = level;
  files[0].ftype   = sCHAR;
  files[0].faddr   = dstack;
  files[0].fsize   = sCHAR_SIZE;
  dstack          += sCHAR_SIZE;

  /* We need the following in order to calculate relative stack positions. */

  FP->dstack       = dstack;

  /* Indicate that no WITH statement has been processed */

  memset(&withRecord, 0, sizeof(WTYPE));

  /* Process the pascal program
   *
   * FORM: pascal = program | unit
   * FORM: program = program-heading ';' [uses-section ] block '.'
   * FORM: program-heading = 'program' identifier [ '(' identifier-list ')' ]
   * FORM: unit = unit-heading ';' interface-section implementation-section init-section
   * FORM: unit-heading = 'unit' identifer
   */

  getToken();
  if (token == tPROGRAM)
    { 
      /* Compile a pascal program */

      FP->kind    = eIsProgram;
      FP->section = eIsProgramSection;
      getToken();
      program();
    }
  else if (token == tUNIT)
    {
      /* Compile a pascal unit */

      FP->kind    = eIsUnit;
      FP->section = eIsOtherSection;
      getToken();
      unitImplementation();
    }
  else
    {
      /* Expected 'program' or 'unit' */

      error(ePROGRAM);
    }

  /* Dump the symbol table content (debug only) */

#if CONFIG_DEBUG
  dumpTables();
#endif

  /* Write the POFF output file */

  poffWriteFile(poffHandle, poffFile);
  poffDestroyHandle(poffHandle);

  /* Close all output files */

  closeFiles();

  /* Write Closing Message */

  if (warn_count > 0)
    {
      printf("  %ld Warnings Issued\n", warn_count);
    } /* end if */

  if (err_count > 0)
    {
      printf("  %d Errors Detected\n\n", err_count);
      return -1;
    } /* end if */

  return 0;

} /* end main */