Exemplo n.º 1
0
Arquivo: Main.c Projeto: m1h4/Compiler
int main(void)
{
	LPCSTR input = "C:\\Test.asm";
	LPCSTR output = "C:\\Test.nb0";
	ASSEMBLER assembler;

	InitializeAssembler(&assembler);

	if(!AssembleFile(&assembler,input))
	{
		UninitializeAssembler(&assembler);
		system("pause");
		return 1;
	}

	if(!AssembleBinary(&assembler,output))
	{
		UninitializeAssembler(&assembler);
		system("pause");
		return 2;
	}

	UninitializeAssembler(&assembler);

	system("pause");
	return 0;
}
Exemplo n.º 2
0
static void Assemble (const char* File)
/* Assemble the given file */
{
    /* Remember the current assembler argument count */
    unsigned ArgCount = CA65.ArgCount;

    /* We aren't assembling an intermediate file, but one requested by the
    ** user. So add a few options here if they were given on the command
    ** line.
    */
    if (DepName && *DepName) {
        CmdAddArg2 (&CA65, "--create-dep", DepName);
    }
    if (FullDepName && *FullDepName) {
        CmdAddArg2 (&CA65, "--create-full-dep", FullDepName);
    }

    /* Use the common routine */
    AssembleFile (File, ArgCount);
}
Exemplo n.º 3
0
static void AssembleIntermediate (const char* SourceFile)
/* Assemble an intermediate file which was generated by a previous processing
** step with SourceFile as input. The -dep options won't be added and
** the intermediate assembler file is removed after assembly.
*/
{
    /* Generate the name of the assembler output file from the source file
    ** name. It's the same name with the extension replaced by ".s"
    */
    char* AsmName = MakeFilename (SourceFile, ".s");

    /* Assemble the intermediate assembler file */
    AssembleFile (AsmName, CA65.ArgCount);

    /* Remove the input file */
    if (remove (AsmName) < 0) {
        Warning ("Cannot remove temporary file `%s': %s",
                 AsmName, strerror (errno));
    }

    /* Free the assembler file name which was allocated from the heap */
    xfree (AsmName);
}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
	/* debugging */
	setbuf(stdout, NULL);
	setbuf(stderr, NULL);

	if(argc < 3){
		printf("Usage: u1comp <infile> <outfile>\n");
		//exit(1);
		
		printf("Interactive mode!\n");
		interactiveMode = 1; // make yyparse() abort after '\n'
		while (1) {
			printf("> ");
			yyparse();
			
			#if 1
			printf("// Prettyprinting...\n");
			prettySCRIPTCOLLECTION(thescriptcollection);
			errorCheck();
			#endif
		}
	} else {
		if(freopen(argv[1],"r",stdin) != NULL){
		printf("// Parsing...\n");
		lineno=1;
		yyparse(); /* Build AST */
		} else {
			printf("Couldn't open file %s\n",argv[1]);
			exit(1);
		}
	}
	errorCheck();

  printf("// Weeding...\n");
  weedSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  printf("// Symbolchecking...\n");
  symSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  printf("// Typechecking...\n");
  typeSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  #if 0
  printf("// Prettyprinting...\n");
  prettySCRIPTCOLLECTION(thescriptcollection);
  errorCheck();
  #endif
  
  printf("// Resource calculations...\n");
  resSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  printf("// Coding...\n");
  codeSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();

  printf("// Emitting (asm)...\n");
  emitSCRIPTCOLLECTION(thescriptcollection);
  errorCheck();
  
  printf("// Assembling...\n");
  AssembleFile(argv[2]);
  
    
 
 return 0;
}